mon: Monitor: check caps considering command's requirements

Fixes: #5648

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: Monitor: purge old permission checking format on handle_command()

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: services: no longer needed to enforce caps on a per-service basis

We now perform all perm checks for commands on Monitor::handle_command().
Services no longer need to check them.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
mon: drop old _allowed_command()

Signed-off-by: Sage Weil <sage@inktank.com>
mon: AuthMonitor: change 'auth add' behaviour

If an entity already existed, 'auth add' would smash its key and caps
with whatever was on the supplied keyring file; if a keyring weren't
specified, we would simply generate a new key and destroy all existing
caps (unless caps were specified and happened to be different from the
already in-place caps).  This behaviour is obviously sketchy.

With this patch we now enforce the following behaviour:

- if entity does not exist in current state, check if we are about to
  create it (by checking the pending state); if so, wait for the new state
  to be committed and re-handle the command then, so we don't get bad
  results from pending request
- if the command reproduces the current state (same key, same caps), we
  return 0; else,
- if entity exists and supplied key OR caps are different, return -EINVAL
- else create a new entity.

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
qa: workunits: mon: workunit to stress the monitor's caps

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
test: mon: moncap: add 'allow command foo with arg="bar.baz"' tests

Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
Merge remote-tracking branch 'gh/wip-5648-c'

Reviewed-by: Sage Weil <sage@inktank.com>