From: Stéphane Graber Date: Fri, 16 Aug 2013 14:40:48 +0000 (+0200) Subject: Allow building without confstr X-Git-Tag: lxc-1.0.0.alpha1~1^2~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=511a6936c7062d59dd9335ef16d9165d19c45604;p=thirdparty%2Flxc.git Allow building without confstr We use confstr to grab the default PATH value. If it's not there, just use a standard one with bin and sbin for /, /usr and /usr/local. Signed-off-by: Stéphane Graber Acked-by: Serge E. Hallyn --- diff --git a/configure.ac b/configure.ac index 031fc160b..6b68703c9 100644 --- a/configure.ac +++ b/configure.ac @@ -301,7 +301,7 @@ AC_CHECK_DECLS([PR_CAPBSET_DROP], [], [], [#include ]) AC_CHECK_HEADERS([sys/signalfd.h pty.h ifaddrs.h sys/capability.h sys/personality.h utmpx.h sys/timerfd.h]) # Check for some syscalls functions -AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r]) +AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r confstr]) # Check for some functions AC_CHECK_LIB(util, openpty) diff --git a/src/lxc/attach.c b/src/lxc/attach.c index 19fe61dfb..67eb0c7ad 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -261,8 +261,6 @@ int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char** extra { if (policy == LXC_ATTACH_CLEAR_ENV) { char **extra_keep_store = NULL; - char *path_env; - size_t n; int path_kept = 0; if (extra_keep) { @@ -317,6 +315,10 @@ int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char** extra * 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) { @@ -325,6 +327,9 @@ int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char** extra free(path_env); } /* don't error out, this is just an extra service */ +#else + setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 1); +#endif } }