From 8c1908035c919da58d29fab87b42126754f84405 Mon Sep 17 00:00:00 2001 From: petervo Date: Wed, 10 Feb 2016 02:29:00 -0800 Subject: [PATCH] session: Make sure we set path in cockpit-session Reviewed-by: Marius Vollmer --- src/ws/session.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ws/session.c b/src/ws/session.c index e877f15..618ca2e 100644 --- a/src/ws/session.c +++ b/src/ws/session.c @@ -56,6 +56,7 @@ #define MAX_BUFFER 64 * 1024 #define AUTH_FD 3 #define EX 127 +#define DEFAULT_PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" static struct passwd *pwd; const char *rhost; @@ -898,6 +899,7 @@ static const char *env_names[] = { "G_DEBUG", "G_MESSAGES_DEBUG", "G_SLICE", + "PATH", NULL }; @@ -910,6 +912,9 @@ save_environment (void) const char *value; int i, j; + /* Force save our default path */ + setenv ("PATH", DEFAULT_PATH, 1); + for (i = 0, j = 0; env_names[i] != NULL; i++) { value = getenv (env_names[i]); @@ -957,7 +962,7 @@ main (int argc, } /* set a minimal environment */ - setenv ("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 1); + setenv ("PATH", DEFAULT_PATH, 1); if (setgid (0) != 0 || setuid (0) != 0) err (1, "couldn't switch permissions correctly"); -- 1.8.3.1