lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri,  5 Jul 2013 18:05:45 +0200
From:	Nicolas Dichtel <nicolas.dichtel@...nd.com>
To:	shemminger@...tta.com
Cc:	netdev@...r.kernel.org, junwei.zhang@...nd.com,
	Nicolas Dichtel <nicolas.dichtel@...nd.com>
Subject: [PATCH iproute2] ipbatch: fix use of 'ip netns exec'

From: JunweiZhang <junwei.zhang@...nd.com>

execvp() does not return when the command succeed, hence all commands in the
batch file after the line 'ip netns exec' are not executed.

Let's fork before calling execvp().

Signed-off-by: JunweiZhang <junwei.zhang@...nd.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@...nd.com>
---
 ip/ipnetns.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index fa2b681..a4a68a7 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -138,6 +138,7 @@ static int netns_exec(int argc, char **argv)
 	const char *name, *cmd;
 	char net_path[MAXPATHLEN];
 	int netns;
+	int pid, status;
 
 	if (argc < 1) {
 		fprintf(stderr, "No netns name specified\n");
@@ -185,10 +186,17 @@ static int netns_exec(int argc, char **argv)
 	/* Setup bind mounts for config files in /etc */
 	bind_etc(name);
 
-	if (execvp(cmd, argv + 1)  < 0)
+	pid = fork();
+	if (pid < 0)
+		return EXIT_FAILURE;
+	else if (pid > 0)
+		waitpid(pid, &status, 0);
+	else if (execvp(cmd, argv + 1)  < 0) {
 		fprintf(stderr, "exec of \"%s\" failed: %s\n",
 			cmd, strerror(errno));
-	return EXIT_FAILURE;
+		return EXIT_FAILURE;
+	}
+	return WIFEXITED(status) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
 static int is_pid(const char *str)
-- 
1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ