]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
pybind: ceph_argparse: validate incorrectly formed targets 3285/head
authorJoao Eduardo Luis <joao@redhat.com>
Fri, 2 Jan 2015 17:39:36 +0000 (17:39 +0000)
committerJoao Eduardo Luis <joao@redhat.com>
Fri, 16 Jan 2015 16:41:40 +0000 (16:41 +0000)
commitc4548f68ca9565febe167d6ae2f2c96f550051e7
tree359746eaa99483e8a83702bdec2049f2056ae178
parent8618a5373e61035d9112ba024eda78792561c265
pybind: ceph_argparse: validate incorrectly formed targets

Prior to this patch find_cmd_target() would perform the following
parsing for any given command:

- check if it's a "tell" to a parseable CephName
  (i.e., ceph tell <type.id> ...)
  - if so, return <type>, <id>

- check if it's a "tell" to a parseable PG id
  (e.g., ceph tell 0.4a)
  - if so, return 'pg', <pgid>

- check if it's a "pg" command to a parseable PG id
  (e.g., ceph pg 0.4a)
  - if so, return 'pg', <pgid>

- otherwise return 'mon', ''

However, parsing of CephName and CephPgid is performed in a relaxed
fashion, and tightening those checks requirements end up having
nefarious effects on properly formed commands, whereas keeping them
relaxed ends up having us returning 'mon','' in the end for a clearly
malformed target (e.g., 'ceph tell foo ...').

This patch fixes this behavior by adding a new check:

- if command is a "tell" and we were not able to parse either a CephName
  nor a PG id, then explicitely validate the target as a CephName (given
  we would be sending to a monitor anyway, we can just as well validate
  a 'tell' as a CephName).
  - if validation fails, we will propagate exceptions referring to the
    cause of the validation failure.

Fixes: #10439
Signed-off-by: Joao Eduardo Luis <joao@redhat.com>
src/ceph.in
src/pybind/ceph_argparse.py