diff options
author | Kay Sievers <kay@vrfy.org> | 2013-07-26 05:22:22 +0200 |
---|---|---|
committer | Kay Sievers <kay@vrfy.org> | 2013-07-26 18:40:40 +0200 |
commit | e21fea24ae2a7a04f6d5c9d2bbbaf5833d248952 (patch) | |
tree | e73759c9e6d0f38074436f0a22745c9131dd5ef8 /src/core/locale-setup.c | |
parent | 68fee104e630eb19f04b8196a83c14c2c9c469e7 (diff) |
rework systemd's own process environment handling/passing
Stop importing non-sensical kernel-exported variables. All
parameters in the kernel command line are exported to the
initial environment of PID1, but suppressed if they are
recognized by kernel built-in code. The EFI booted kernel
will add further kernel-internal things which do not belong
into userspace.
The passed original environ data of the process is not touched
and preserved across re-execution, to allow external reading of
/proc/self/environ for process properties like container*=.
Diffstat (limited to 'src/core/locale-setup.c')
-rw-r--r-- | src/core/locale-setup.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c index daf81d080e..31374ac644 100644 --- a/src/core/locale-setup.c +++ b/src/core/locale-setup.c @@ -28,6 +28,7 @@ #include "macro.h" #include "virt.h" #include "fileio.h" +#include "strv.h" enum { /* We don't list LC_ALL here on purpose. People should be @@ -67,7 +68,8 @@ static const char * const variable_names[_VARIABLE_MAX] = { [VARIABLE_LC_IDENTIFICATION] = "LC_IDENTIFICATION" }; -int locale_setup(void) { +int locale_setup(char ***environment) { + char **env; char *variables[_VARIABLE_MAX] = {}; int r = 0, i; @@ -118,13 +120,16 @@ int locale_setup(void) { } for (i = 0; i < _VARIABLE_MAX; i++) { - if (variables[i]) { - if (setenv(variable_names[i], variables[i], 1) < 0) { - r = -errno; - goto finish; - } - } else - unsetenv(variable_names[i]); + if (!variables[i]) + continue; + + env = strv_appendf(*environment, "%s=%s", variable_names[i], variables[i]); + if (!env) { + r = -ENOMEM; + goto finish; + } + + *environment = env; } r = 0; |