chiark / gitweb /
Do not serialize environment, when switching root
[elogind.git] / src / core / manager.c
index 549153e057493d2b9db7c06511f1f7bee0375c01..f8d097e368aac39c8925f53016dd4012ffe349e1 100644 (file)
@@ -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;