]> git.armaanb.net Git - opendoas.git/blobdiff - env.c
briefly mention /etc/examples/ in the FILES section of all the manual pages that...
[opendoas.git] / env.c
diff --git a/env.c b/env.c
index f1fe45fbc83a6f51c7a2448209abe42b48f044f0..12909c6201cef0e9b1c0199cf13d641f89a152ad 100644 (file)
--- a/env.c
+++ b/env.c
@@ -29,6 +29,8 @@
 #include "doas.h"
 #include "includes.h"
 
+const char *formerpath;
+
 struct envnode {
        RB_ENTRY(envnode) node;
        const char *key;
@@ -199,10 +201,17 @@ fillenv(struct env *env, const char **envlist)
                /* assign value or inherit from environ */
                if (eq) {
                        val = eq + 1;
-                       if (*val == '$')
-                               val = getenv(val + 1);
+                       if (*val == '$') {
+                               if (strcmp(val + 1, "PATH") == 0)
+                                       val = formerpath;
+                               else
+                                       val = getenv(val + 1);
+                       }
                } else {
-                       val = getenv(name);
+                       if (strcmp(name, "PATH") == 0)
+                               val = formerpath;
+                       else
+                               val = getenv(name);
                }
                /* at last, we have something to insert */
                if (val) {