From: Michał Łyszczek Date: Tue, 22 Oct 2019 20:09:23 +0000 (+0200) Subject: ipnetns: do not check netns NAME when -all is specified X-Git-Tag: v5.4.0~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7f28e0bd92eae7f03afc7f13ac19b5e64902ef8;p=thirdparty%2Fiproute2.git ipnetns: do not check netns NAME when -all is specified 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 Signed-off-by: Stephen Hemminger --- diff --git a/ip/ipnetns.c b/ip/ipnetns.c index 20110ef0f..fc58a04b5 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -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); }