]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Allow building without confstr
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 16 Aug 2013 14:40:48 +0000 (16:40 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 19 Aug 2013 12:33:31 +0000 (14:33 +0200)
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 <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
configure.ac
src/lxc/attach.c

index 031fc160b97f22a3b957d1a4863e21d231fe6e83..6b68703c9d0c4e28ff6f7a5742ccc189cb586f3d 100644 (file)
@@ -301,7 +301,7 @@ AC_CHECK_DECLS([PR_CAPBSET_DROP], [], [], [#include <sys/prctl.h>])
 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)
index 19fe61dfbd827a3b8ec1c56430e819a3144543bc..67eb0c7ad3cc1c149cccc3282e84085192221dde 100644 (file)
@@ -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
                }
        }