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

Stéphane Graber stgraber at ubuntu.com
Mon Oct 27 20:56:37 UTC 2014


On Thu, Oct 23, 2014 at 04:34:05AM +0000, Serge Hallyn wrote:
> 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>

Looks like a reasonable default path to me.

We may need some android-specific logic at some point for this, but the
Android kernel is currently too old to support attach so we'll fix that
later.

Acked-by: Stéphane Graber <stgraber 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
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20141027/fe8dbfc9/attachment.sig>


More information about the lxc-devel mailing list