summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2016-02-21 18:35:01 +0000
committerian <ian@FreeBSD.org>2016-02-21 18:35:01 +0000
commitc764d7edd246d0ad10fefcab37d3af93d525a819 (patch)
treec6779962ece85488d51630d4abb9c83cea087f58
parent4543e2c4ad52ae45c4b3cc6aa0f87c0684131b92 (diff)
downloadFreeBSD-src-c764d7edd246d0ad10fefcab37d3af93d525a819.zip
FreeBSD-src-c764d7edd246d0ad10fefcab37d3af93d525a819.tar.gz
Allow a dynamic env to override a compiled-in static env by passing in the
override indication in the env data. Submitted by: bde
-rw-r--r--sys/kern/kern_environment.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c
index cd6930b..511ab69 100644
--- a/sys/kern/kern_environment.c
+++ b/sys/kern/kern_environment.c
@@ -217,6 +217,9 @@ done:
* environment obtained from a boot loader, or to provide an empty buffer into
* which MD code can store an initial environment using kern_setenv() calls.
*
+ * When a copy of an initial environment is passed in, we start by scanning that
+ * env for overrides to the compiled-in envmode and hintmode variables.
+ *
* If the global envmode is 1, the environment is initialized from the global
* static_env[], regardless of the arguments passed. This implements the env
* keyword described in config(5). In this case env_pos is set to env_len,
@@ -238,6 +241,14 @@ done:
void
init_static_kenv(char *buf, size_t len)
{
+ char *cp;
+
+ for (cp = buf; cp != NULL && cp[0] != '\0'; cp += strlen(cp) + 1) {
+ if (strcmp(cp, "static_env.disabled=1") == 0)
+ envmode = 0;
+ if (strcmp(cp, "static_hints.disabled=1") == 0)
+ hintmode = 0;
+ }
if (envmode == 1) {
kern_envp = static_env;
OpenPOWER on IntegriCloud