]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ipnetns: do not check netns NAME when -all is specified
authorMichał Łyszczek <michal.lyszczek@bofc.pl>
Tue, 22 Oct 2019 20:09:23 +0000 (22:09 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 23 Oct 2019 16:18:08 +0000 (09:18 -0700)
When `-all' argument is specified netns runs cmd on all namespaces
and NAME is not used, but netns nevertheless checks if argv[1] is a
valid namespace name ignoring the fact that argv[1] contains cmd
and not NAME. This results in bug where user cannot specify
absolute path to command.

    # ip -all netns exec /usr/bin/whoami
    Invalid netns name "/usr/bin/whoami"

This forces user to have his command in PATH.

Solution is simply to not validate argv[1] when `-all' argument is
specified.

Signed-off-by: Michał Łyszczek <michal.lyszczek@bofc.pl>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/ipnetns.c

index 20110ef0f58ee571b826a3e1ea1d16f5a93fbba8..fc58a04b57de2a54d260bc2b76f8bd11ef718722 100644 (file)
@@ -994,7 +994,7 @@ int do_netns(int argc, char **argv)
                return netns_list(0, NULL);
        }
 
-       if (argc > 1 && invalid_name(argv[1])) {
+       if (!do_all && argc > 1 && invalid_name(argv[1])) {
                fprintf(stderr, "Invalid netns name \"%s\"\n", argv[1]);
                exit(-1);
        }