netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] ipnetns: do not check netns NAME when -all is specified
@ 2019-10-22 20:09 Michał Łyszczek
  2019-10-23 16:21 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Michał Łyszczek @ 2019-10-22 20:09 UTC (permalink / raw)
  To: netdev; +Cc: Michał Łyszczek

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>
---
 ip/ipnetns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 20110ef0..fc58a04b 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);
 	}
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH iproute2] ipnetns: do not check netns NAME when -all is specified
  2019-10-22 20:09 [PATCH iproute2] ipnetns: do not check netns NAME when -all is specified Michał Łyszczek
@ 2019-10-23 16:21 ` Stephen Hemminger
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Hemminger @ 2019-10-23 16:21 UTC (permalink / raw)
  To: Michał Łyszczek; +Cc: netdev

On Tue, 22 Oct 2019 22:09:23 +0200
Michał Łyszczek <michal.lyszczek@bofc.pl> wrote:

> 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>

Looks good, applied thanks


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-23 16:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-22 20:09 [PATCH iproute2] ipnetns: do not check netns NAME when -all is specified Michał Łyszczek
2019-10-23 16:21 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).