[lxc-devel] [RFC] [PATCH] attach: don't use confstr(_CS_PATH)

Serge Hallyn serge.hallyn at ubuntu.com
Thu Oct 23 04:34:05 UTC 2014


It is not system-definable, rather glibc sets that to bin:/usr/bin, which is
simply too restrictive.  So just always set our preferred path.

This was reported at:
https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1384327

Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
---
 src/lxc/attach.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/src/lxc/attach.c b/src/lxc/attach.c
index 7cadcbd..2318018 100644
--- a/src/lxc/attach.c
+++ b/src/lxc/attach.c
@@ -336,23 +336,8 @@ static int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char*
 		 * number of C programs out there that just assume
 		 * that getenv("PATH") is never NULL and then die a
 		 * painful segfault death. */
-		if (!path_kept) {
-#ifdef HAVE_CONFSTR
-			size_t n;
-			char *path_env;
-
-			n = confstr(_CS_PATH, NULL, 0);
-			path_env = malloc(n);
-			if (path_env) {
-				confstr(_CS_PATH, path_env, n);
-				setenv("PATH", path_env, 1);
-				free(path_env);
-			}
-			/* don't error out, this is just an extra service */
-#else
+		if (!path_kept)
 			setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 1);
-#endif
-		}
 	}
 
 	if (putenv("container=lxc")) {
-- 
2.1.0



More information about the lxc-devel mailing list