summaryrefslogtreecommitdiff
path: root/src/core/manager.c
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2013-04-08 14:05:24 +0200
committerHarald Hoyer <harald@redhat.com>2013-04-08 14:45:19 +0200
commitb3680f49e20c51e31c8dea84a11207df7b8f0100 (patch)
tree400fa9847c6fe350078c08c01ab14737fd4112de /src/core/manager.c
parent9735bd12ab7668cc1b7b518299797b101f16bd58 (diff)
Do not serialize environment, when switching root
When switching root, i.e. LANG can be set to the locale of the initramfs or "C", if it was unset. When systemd deserializes LANG in the real root this would overwrite the setting previously gathered by locale_set(). To reproduce, boot with an initramfs without locale.conf or change /etc/locale.conf to a different language than the initramfs and check a daemon started by systemd: $ tr "$\000" '\n' </proc/$(pidof sshd)/environ | grep LANG LANG=C To prevent that, serialization of environment variables is skipped, when serializing for switching root. https://bugzilla.redhat.com/show_bug.cgi?id=949525
Diffstat (limited to 'src/core/manager.c')
-rw-r--r--src/core/manager.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/core/manager.c b/src/core/manager.c
index 549153e057..f8d097e368 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -2004,7 +2004,7 @@ int manager_open_serialization(Manager *m, FILE **_f) {
return 0;
}
-int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool serialize_jobs) {
+int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool switching_root) {
Iterator i;
Unit *u;
const char *t;
@@ -2032,12 +2032,14 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool serialize_jobs) {
dual_timestamp_serialize(f, "finish-timestamp", &m->finish_timestamp);
}
- STRV_FOREACH(e, m->environment) {
- _cleanup_free_ char *ce;
+ if (!switching_root) {
+ STRV_FOREACH(e, m->environment) {
+ _cleanup_free_ char *ce;
- ce = cescape(*e);
- if (ce)
- fprintf(f, "env=%s\n", *e);
+ ce = cescape(*e);
+ if (ce)
+ fprintf(f, "env=%s\n", *e);
+ }
}
fputc('\n', f);
@@ -2053,7 +2055,7 @@ int manager_serialize(Manager *m, FILE *f, FDSet *fds, bool serialize_jobs) {
fputs(u->id, f);
fputc('\n', f);
- if ((r = unit_serialize(u, f, fds, serialize_jobs)) < 0) {
+ if ((r = unit_serialize(u, f, fds, !switching_root)) < 0) {
m->n_reloading --;
return r;
}
@@ -2241,7 +2243,7 @@ int manager_reload(Manager *m) {
goto finish;
}
- r = manager_serialize(m, f, fds, true);
+ r = manager_serialize(m, f, fds, false);
if (r < 0) {
m->n_reloading --;
goto finish;