rgw: clean up ops initialization, completion

ops init() was a reminiscent of an old design. Since we're
allocating new op for every request we can just init everything
in the constructor.

We now add a new complete() stage in request processing. By
default complete() will call send_response().

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
rgw: better protocols separation

This change will make it easier to add new protocol
handlers. We now determine which protocol handler to
use by querying the list of existing protocol handlers
whether the query belongs to that protocol. If so,
then just run the specific protocol's handler code.
Separated some mixed s3 and swift code into the specific
handlers.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
OSDCap: remove grants added during failed parsing

Parsing has side effects that must be undone if it fails.  A
capability string like 'allow rwx pool=bar' will add the grant for
'allow rwx' and then fail on the 'pool=bar'. Thus, the client will
effectively have 'rwx' permissions on all pools.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
OSDCap: fix typo in comment

The grammar uses auid, not uid.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
OSDCap: fix output operators for caps

OSD_CAP_ANY is not a flag, but a value (0xff) that will always
be true when treated as a mask with a non-zero rwxa_t.

Don't duplicate the rwxa_t output operator in the OSDCapSpec output
operator, just use it.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
OSDCaps: fix allow_all()

OSD_CAP_ANY is not a mask. Treating it as one made any allowance
equivalent to 'allow *'.

Fixes: #3228
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
test: add more OSDCap unit tests

Check that allow_all() returns false when 'allow *' is not specified.
This would have caught #3228.
Add tests for the output operators as well.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Makefile.am: recompile small file instead of libosd for unit test

Linking with libosd requires a lot more recompilation
when testing changes to OSDCap.cc.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
OSDCap: parse 'pool=<poolname>' in addition to 'pool <poolname>'

This was used in releases before 0.49, and was the documented way
to use it in several places, so support it again for backwards
compatibility.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
test: remove commented out test cases

These are copied from non-commented out ones a few lines above.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
OSDCap: parse spaces explicitly

This is necessary to avoid matching things like "allow r poolfoo".
It's also needed to distinguish "allow r class-read" from
"allow r class -read".

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
OSDCap: allow runs of spaces anywhere

I couldn't find a way to do this with skip parsers,
so these are explicitly included in the grammar.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
OSDCap: add separate caps for class read and class write

These are useful for rbd layering, since reading an rbd image
requires read-only class methods.

Fixes: #3167
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
objclass: require each class method to have a flag set

The osd depends on this to set the client op flags for class call ops.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
doc: update ceph-authtool man page for new osd caps

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
OSD: deprecate CLS_METHOD_PUBLIC flag

Remove all existing usage, but leave the definition so third-party
class plugins don't break.

The public flag let *any* user execute a class method, as long
as they had read and/or write access as the method required. This is
better managed by the new osd caps infrastructure, and it was
entirely undocumented and unused, so it should be safe to remove.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
doc: add rbd example to ceph-authtool man page

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
release: note possible osd caps incompatibilities

We can use this file to store release notes for the next release.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
Avoid sign-extension of non-magic Message* values

Cast to (unsigned long) when checking for magic values, so
real ptrs don't get sign-extended.  Avoids triggering
assert(inq == &local_queue) failure.

Fixes: #3251
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage.weil@inktank.com>
Merge branch 'wip-msgr' into next