manager: just warn about an invalid environment entry
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 23 Jun 2017 23:20:54 +0000 (19:20 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 24 Jun 2017 00:46:33 +0000 (20:46 -0400)
Apart from bugs (as in #6152), this can happen if we ever make
our requirements for environment entries more stringent. As with
the rest of deserialization, we should just warn and continue.

src/basic/env-util.c
src/core/manager.c

index e79b441..c2a6f6f 100644 (file)
@@ -788,7 +788,7 @@ int serialize_environment(FILE *f, char **environment) {
 }
 
 int deserialize_environment(char ***environment, const char *line) {
-        char *uce = NULL;
+        char *uce;
         int r;
 
         assert(line);
index 876210f..2837207 100644 (file)
@@ -2588,8 +2588,8 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
         m->n_reloading++;
 
         for (;;) {
-                char line[LINE_MAX], *l;
-                const char *val;
+                char line[LINE_MAX];
+                const char *val, *l;
 
                 if (!fgets(line, sizeof(line), f)) {
                         if (feof(f))
@@ -2665,8 +2665,10 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) {
                         dual_timestamp_deserialize(val, &m->units_load_finish_timestamp);
                 else if (startswith(l, "env=")) {
                         r = deserialize_environment(&m->environment, l);
+                        if (r == -ENOMEM)
+                                goto finish;
                         if (r < 0)
-                                return r;
+                                log_notice_errno(r, "Failed to parse environment entry: \"%s\": %m", l);
 
                 } else if ((val = startswith(l, "notify-fd="))) {
                         int fd;