aboutsummaryrefslogtreecommitdiff
path: root/stand/libsa/environment.c
diff options
context:
space:
mode:
Diffstat (limited to 'stand/libsa/environment.c')
-rw-r--r--stand/libsa/environment.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/stand/libsa/environment.c b/stand/libsa/environment.c
index 95ee1718f8d4..d139249a8e84 100644
--- a/stand/libsa/environment.c
+++ b/stand/libsa/environment.c
@@ -66,6 +66,17 @@ env_setenv(const char *name, int flags, const void *value,
if ((ev = env_getenv(name)) != NULL) {
/*
+ * If the new value doesn't have NOKENV set, we'll drop the flag
+ * if it's set on the entry so that the override propagates
+ * correctly. We do this *before* sending it to the hook in
+ * case the hook declines to operate on it (e.g., because the
+ * value matches what was already set) -- we would still want
+ * the explicitly set value to propagate.
+ */
+ if (!(flags & EV_NOKENV))
+ ev->ev_flags &= ~EV_NOKENV;
+
+ /*
* If there's a set hook, let it do the work
* (unless we are working for one already).
*/
@@ -77,7 +88,6 @@ env_setenv(const char *name, int flags, const void *value,
free(ev->ev_value);
ev->ev_value = NULL;
ev->ev_flags &= ~EV_DYNAMIC;
-
} else {
/*
@@ -123,12 +133,13 @@ env_setenv(const char *name, int flags, const void *value,
/* If we have a new value, use it */
if (flags & EV_VOLATILE) {
ev->ev_value = strdup(value);
- ev->ev_flags |= EV_DYNAMIC;
+ flags |= EV_DYNAMIC;
} else {
ev->ev_value = (char *)value;
- ev->ev_flags |= flags & EV_DYNAMIC;
}
+ ev->ev_flags |= flags & (EV_DYNAMIC | EV_NOKENV);
+
return (0);
}