]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph.in: reject -w/--watch flags when used with subcommands 69652/head
authorYonatan Zaken <yzaken@redhat.com>
Mon, 22 Jun 2026 17:02:39 +0000 (20:02 +0300)
committerYonatan Zaken <yzaken@redhat.com>
Mon, 22 Jun 2026 17:02:39 +0000 (20:02 +0300)
parse_known_args() silently consumes -w and all --watch-* flags
before subcommand arguments reach the command validator. When a
user ran "ceph orch ps -w", the watch handler entered cluster log
streaming mode while discarding the subcommand entirely, with no
error or indication that the orch ps command was ignored.

Add a guard at the entry of the watch handler: if any watch flag
is active and childargs is non-empty, print "Invalid command:
unused arguments: [...]" and return EINVAL. This matches the
behaviour already seen when -s/--status is combined with a
subcommand.

Assisted-by: Claude:claude-4.6-sonnet
Fixes: https://tracker.ceph.com/issues/77121
Signed-off-by: Yonatan Zaken <yzaken@redhat.com>
src/ceph.in

index 4694da29db5fea32f5f6e7986920b60037d710d1..3379de7488e9099620f714828d737ac5fc840473 100755 (executable)
@@ -1131,6 +1131,9 @@ def main():
             elif k != "watch_channel":
                 level = k.replace('watch_', '')
     if level:
+        if childargs:
+            print('Invalid command: unused arguments: {0}'.format(childargs), file=sys.stderr)
+            return errno.EINVAL
         # an awfully simple callback
         def watch_cb(arg, line, channel, name, who, stamp_sec, stamp_nsec, seq, level, msg):
             # Filter on channel