diff --git a/stand/common/gfx_fb.c b/stand/common/gfx_fb.c --- a/stand/common/gfx_fb.c +++ b/stand/common/gfx_fb.c @@ -242,6 +242,7 @@ { const char *ptr; char env[10]; + int eflags = EV_VOLATILE | EV_NOKENV; bool from_env = false; ptr = getenv(envname); @@ -257,10 +258,16 @@ if (unsetenv(envname) != 0) return (true); from_env = true; + + /* + * If we're carrying over an existing value, we *do* want that + * to propagate to the kenv. + */ + eflags &= ~EV_NOKENV; } snprintf(env, sizeof(env), "%d", *cattr); - env_setenv(envname, EV_VOLATILE, env, sethook, unsethook); + env_setenv(envname, eflags, env, sethook, unsethook); return (from_env); } diff --git a/stand/common/modinfo.c b/stand/common/modinfo.c --- a/stand/common/modinfo.c +++ b/stand/common/modinfo.c @@ -172,6 +172,8 @@ /* Traverse the environment. */ for (ep = environ; ep != NULL; ep = ep->ev_next) { + if ((ep->ev_flags & EV_NOKENV) != 0) + continue; len = strlen(ep->ev_name); if ((size_t)archsw.arch_copyin(ep->ev_name, addr, len) != len) break; diff --git a/stand/libsa/environment.c b/stand/libsa/environment.c --- a/stand/libsa/environment.c +++ b/stand/libsa/environment.c @@ -65,6 +65,17 @@ struct env_var *ev, *curr, *last; 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 @@ free(ev->ev_value); ev->ev_value = NULL; ev->ev_flags &= ~EV_DYNAMIC; - } else { /* @@ -123,12 +133,13 @@ /* 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); } diff --git a/stand/libsa/stand.h b/stand/libsa/stand.h --- a/stand/libsa/stand.h +++ b/stand/libsa/stand.h @@ -352,6 +352,7 @@ #define EV_DYNAMIC (1<<0) /* value was dynamically allocated, free if changed/unset */ #define EV_VOLATILE (1<<1) /* value is volatile, make a copy of it */ #define EV_NOHOOK (1<<2) /* don't call hook when setting */ +#define EV_NOKENV (1<<3) /* don't add to kenv (loader-only) */ struct env_var; typedef char *(ev_format_t)(struct env_var *ev);