]> granicus.if.org Git - sudo/commitdiff
When merging the PAM environment, allow environment variables set
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 17 Aug 2013 12:34:09 +0000 (06:34 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 17 Aug 2013 12:34:09 +0000 (06:34 -0600)
in PAM to override ones set by sudo as long as they do not match
the env_keep or env_check lists.

plugins/sudoers/env.c
plugins/sudoers/sudoers.h

index 78cd2e60938745141f0ba0e42628f532cefec0b9..72218725a507549da212bd5790f7f1e4e49e6399 100644 (file)
@@ -544,21 +544,6 @@ sudo_getenv(const char *name)
     debug_return_str(val);
 }
 
-/*
- * Merge another environment with our private copy.
- */
-void
-env_merge(char * const envp[], bool overwrite)
-{
-    char * const *ep;
-    debug_decl(env_merge, SUDO_DEBUG_ENV)
-
-    for (ep = envp; *ep != NULL; ep++)
-       sudo_putenv(*ep, true, overwrite);
-
-    debug_return;
-}
-
 /*
  * Check the env_delete blacklist.
  * Returns true if the variable was found, else false.
@@ -695,6 +680,23 @@ env_should_keep(const char *var)
     debug_return_bool(keepit == true);
 }
 
+/*
+ * Merge another environment with our private copy.
+ * Only overwrite an existing variable if it is not
+ * being preserved from the user's environment.
+ */
+void
+env_merge(char * const envp[])
+{
+    char * const *ep;
+    debug_decl(env_merge, SUDO_DEBUG_ENV)
+
+    for (ep = envp; *ep != NULL; ep++)
+       sudo_putenv(*ep, true, !env_should_keep(*ep));
+
+    debug_return;
+}
+
 static void
 env_update_didvar(const char *ep, unsigned int *didvar)
 {
index 55287b51c8eb9e05ad73d5ca85bfe1752851ba4a..8118ea460bd6517aec4398d5fafb8f839d48bd97 100644 (file)
@@ -334,7 +334,7 @@ char *expand_iolog_path(const char *prefix, const char *dir, const char *file,
 
 /* env.c */
 char **env_get(void);
-void env_merge(char * const envp[], bool overwrite);
+void env_merge(char * const envp[]);
 void env_init(char * const envp[]);
 void init_envtables(void);
 void insert_env_vars(char * const envp[]);