summaryrefslogtreecommitdiff
path: root/usr.bin/doas/env.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/doas/env.c')
-rw-r--r--usr.bin/doas/env.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.bin/doas/env.c b/usr.bin/doas/env.c
index 7e419b8924f..88be5bbf698 100644
--- a/usr.bin/doas/env.c
+++ b/usr.bin/doas/env.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: env.c,v 1.8 2019/06/17 16:01:26 tedu Exp $ */
+/* $OpenBSD: env.c,v 1.9 2019/06/17 19:51:23 tedu Exp $ */
/*
* Copyright (c) 2016 Ted Unangst <tedu@openbsd.org>
*
@@ -28,6 +28,8 @@
#include "doas.h"
+const char *formerpath;
+
struct envnode {
RB_ENTRY(envnode) node;
const char *key;
@@ -198,8 +200,12 @@ 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);
}