X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Flocale-setup.c;h=276deb9dc10d89d01176cb69ca0cc5bda1cce51e;hp=31374ac644feef90a2fc3261109d4e5a414340c5;hb=0e7be1293fe70eed47b20f70f74a2a67fc87be17;hpb=e21fea24ae2a7a04f6d5c9d2bbbaf5833d248952 diff --git a/src/core/locale-setup.c b/src/core/locale-setup.c index 31374ac64..276deb9dc 100644 --- a/src/core/locale-setup.c +++ b/src/core/locale-setup.c @@ -29,6 +29,7 @@ #include "virt.h" #include "fileio.h" #include "strv.h" +#include "env-util.h" enum { /* We don't list LC_ALL here on purpose. People should be @@ -69,7 +70,7 @@ static const char * const variable_names[_VARIABLE_MAX] = { }; int locale_setup(char ***environment) { - char **env; + char **add; char *variables[_VARIABLE_MAX] = {}; int r = 0, i; @@ -119,22 +120,44 @@ int locale_setup(char ***environment) { log_warning("Failed to read /etc/locale.conf: %s", strerror(-r)); } + add = NULL; for (i = 0; i < _VARIABLE_MAX; i++) { + char *s; + if (!variables[i]) continue; - env = strv_appendf(*environment, "%s=%s", variable_names[i], variables[i]); - if (!env) { + s = strjoin(variable_names[i], "=", variables[i], NULL); + if (!s) { + r = -ENOMEM; + goto finish; + } + + if (strv_push(&add, s) < 0) { + free(s); + r = -ENOMEM; + goto finish; + } + } + + if (!strv_isempty(add)) { + char **e; + + e = strv_env_merge(2, *environment, add); + if (!e) { r = -ENOMEM; goto finish; } - *environment = env; + strv_free(*environment); + *environment = e; } r = 0; finish: + strv_free(add); + for (i = 0; i < _VARIABLE_MAX; i++) free(variables[i]);