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>
OSD: separate class caps from normal read/write

This properly accounts for multi-op requests. Use MOSDOp->rmw_flags for
internal caps requirements, leaving MOSDOp->flags for client specified
options. Use accessors so the flags don't need to be known by the callers.

Also separate capability checks (need_*_cap) from the nature of the MOSDOp
(may_{read,write}). This preserves the semantics of may_{read,write},
which are used in several places outside of capability checks.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
ceph-create-keys: Create a bootstrap-osd key too.

Signed-off-by: Tommi Virtanen <tv@inktank.com>
ceph-create-keys: Refactor to share wait_for_quorum call.

Signed-off-by: Tommi Virtanen <tv@inktank.com>
ceph-disk-activate, upstart: Use "initctl emit" to start OSDs.

This avoids an error if the daemon was running already, and is
already being done with the other services.

Signed-off-by: Tommi Virtanen <tv@inktank.com>