ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
594167
From 8fa3444f3ca7add9af40ab565e045c2754e5a855 Mon Sep 17 00:00:00 2001
594167
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
594167
Date: Thu, 10 Mar 2022 16:47:51 +0100
594167
Subject: [PATCH] systemctl: fix silent failure when --root is not found
594167
594167
Some calls to lookup_path_init() were not followed by any log emission.
594167
E.g.:
594167
$ SYSTEMD_LOG_LEVEL=debug systemctl --root=/missing enable unit; echo $?
594167
1
594167
594167
Let's add a helper function and use it in various places.
594167
594167
$ SYSTEMD_LOG_LEVEL=debug build/systemctl --root=/missing enable unit; echo $?
594167
Failed to initialize unit search paths for root directory /missing: No such file or directory
594167
1
594167
$ SYSTEMCTL_SKIP_SYSV=1 build/systemctl --root=/missing enable unit; echo $?
594167
Failed to initialize unit search paths for root directory /missing: No such file or directory
594167
Failed to enable: No such file or directory.
594167
1
594167
594167
The repeated error in the second case is not very nice, but this is a niche
594167
case and I don't think it's worth the trouble to trying to avoid it.
594167
594167
(cherry picked from commit 99aad9a2b9e2c06023a2043976fd9395332ff097)
594167
594167
Related: #2082131
594167
---
594167
 src/basic/env-file.c                  | 83 +++++++++------------------
594167
 src/basic/path-lookup.c               | 56 ++++++++++--------
594167
 src/basic/path-lookup.h               |  3 +-
594167
 src/core/manager.c                    | 12 ++--
594167
 src/shared/condition.c                |  3 +-
594167
 src/shared/install.c                  |  2 +-
594167
 src/systemctl/systemctl-edit.c        |  8 +--
594167
 src/systemctl/systemctl-enable.c      |  2 +-
594167
 src/systemctl/systemctl-sysv-compat.c |  2 +-
594167
 src/sysv-generator/sysv-generator.c   |  4 +-
594167
 src/test/test-fileio.c                |  3 +-
594167
 src/test/test-os-util.c               |  7 +--
594167
 12 files changed, 84 insertions(+), 101 deletions(-)
594167
594167
diff --git a/src/basic/env-file.c b/src/basic/env-file.c
594167
index 0353f3f2a0..0e272da083 100644
594167
--- a/src/basic/env-file.c
594167
+++ b/src/basic/env-file.c
594167
@@ -16,9 +16,8 @@ static int parse_env_file_internal(
594167
                 FILE *f,
594167
                 const char *fname,
594167
                 int (*push) (const char *filename, unsigned line,
594167
-                             const char *key, char *value, void *userdata, int *n_pushed),
594167
-                void *userdata,
594167
-                int *n_pushed) {
594167
+                             const char *key, char *value, void *userdata),
594167
+                void *userdata) {
594167
 
594167
         size_t n_key = 0, n_value = 0, last_value_whitespace = SIZE_MAX, last_key_whitespace = SIZE_MAX;
594167
         _cleanup_free_ char *contents = NULL, *key = NULL, *value = NULL;
594167
@@ -100,7 +99,7 @@ static int parse_env_file_internal(
594167
                                 if (last_key_whitespace != SIZE_MAX)
594167
                                         key[last_key_whitespace] = 0;
594167
 
594167
-                                r = push(fname, line, key, value, userdata, n_pushed);
594167
+                                r = push(fname, line, key, value, userdata);
594167
                                 if (r < 0)
594167
                                         return r;
594167
 
594167
@@ -143,7 +142,7 @@ static int parse_env_file_internal(
594167
                                 if (last_key_whitespace != SIZE_MAX)
594167
                                         key[last_key_whitespace] = 0;
594167
 
594167
-                                r = push(fname, line, key, value, userdata, n_pushed);
594167
+                                r = push(fname, line, key, value, userdata);
594167
                                 if (r < 0)
594167
                                         return r;
594167
 
594167
@@ -262,7 +261,7 @@ static int parse_env_file_internal(
594167
                 if (last_key_whitespace != SIZE_MAX)
594167
                         key[last_key_whitespace] = 0;
594167
 
594167
-                r = push(fname, line, key, value, userdata, n_pushed);
594167
+                r = push(fname, line, key, value, userdata);
594167
                 if (r < 0)
594167
                         return r;
594167
 
594167
@@ -300,8 +299,7 @@ static int check_utf8ness_and_warn(
594167
 static int parse_env_file_push(
594167
                 const char *filename, unsigned line,
594167
                 const char *key, char *value,
594167
-                void *userdata,
594167
-                int *n_pushed) {
594167
+                void *userdata) {
594167
 
594167
         const char *k;
594167
         va_list aq, *ap = userdata;
594167
@@ -323,9 +321,6 @@ static int parse_env_file_push(
594167
                         free(*v);
594167
                         *v = value;
594167
 
594167
-                        if (n_pushed)
594167
-                                (*n_pushed)++;
594167
-
594167
                         return 1;
594167
                 }
594167
         }
594167
@@ -341,16 +336,13 @@ int parse_env_filev(
594167
                 const char *fname,
594167
                 va_list ap) {
594167
 
594167
-        int r, n_pushed = 0;
594167
+        int r;
594167
         va_list aq;
594167
 
594167
         va_copy(aq, ap);
594167
-        r = parse_env_file_internal(f, fname, parse_env_file_push, &aq, &n_pushed);
594167
+        r = parse_env_file_internal(f, fname, parse_env_file_push, &aq;;
594167
         va_end(aq);
594167
-        if (r < 0)
594167
-                return r;
594167
-
594167
-        return n_pushed;
594167
+        return r;
594167
 }
594167
 
594167
 int parse_env_file_sentinel(
594167
@@ -371,8 +363,7 @@ int parse_env_file_sentinel(
594167
 static int load_env_file_push(
594167
                 const char *filename, unsigned line,
594167
                 const char *key, char *value,
594167
-                void *userdata,
594167
-                int *n_pushed) {
594167
+                void *userdata) {
594167
         char ***m = userdata;
594167
         char *p;
594167
         int r;
594167
@@ -389,34 +380,28 @@ static int load_env_file_push(
594167
         if (r < 0)
594167
                 return r;
594167
 
594167
-        if (n_pushed)
594167
-                (*n_pushed)++;
594167
-
594167
         free(value);
594167
         return 0;
594167
 }
594167
 
594167
 int load_env_file(FILE *f, const char *fname, char ***rl) {
594167
-        char **m = NULL;
594167
+        _cleanup_strv_free_ char **m = NULL;
594167
         int r;
594167
 
594167
-        r = parse_env_file_internal(f, fname, load_env_file_push, &m, NULL);
594167
-        if (r < 0) {
594167
-                strv_free(m);
594167
+        r = parse_env_file_internal(f, fname, load_env_file_push, &m);
594167
+        if (r < 0)
594167
                 return r;
594167
-        }
594167
 
594167
-        *rl = m;
594167
+        *rl = TAKE_PTR(m);
594167
         return 0;
594167
 }
594167
 
594167
 static int load_env_file_push_pairs(
594167
                 const char *filename, unsigned line,
594167
                 const char *key, char *value,
594167
-                void *userdata,
594167
-                int *n_pushed) {
594167
+                void *userdata) {
594167
+
594167
         char ***m = ASSERT_PTR(userdata);
594167
-        bool added = false;
594167
         int r;
594167
 
594167
         r = check_utf8ness_and_warn(filename, line, key, value);
594167
@@ -427,49 +412,37 @@ static int load_env_file_push_pairs(
594167
         for (char **t = *m; t && *t; t += 2)
594167
                 if (streq(t[0], key)) {
594167
                         if (value)
594167
-                                r = free_and_replace(t[1], value);
594167
+                                return free_and_replace(t[1], value);
594167
                         else
594167
-                                r = free_and_strdup(t+1, "");
594167
-                        goto finish;
594167
+                                return free_and_strdup(t+1, "");
594167
                 }
594167
 
594167
         r = strv_extend(m, key);
594167
         if (r < 0)
594167
-                return -ENOMEM;
594167
+                return r;
594167
 
594167
         if (value)
594167
-                r = strv_push(m, value);
594167
+                return strv_push(m, value);
594167
         else
594167
-                r = strv_extend(m, "");
594167
-        added = true;
594167
- finish:
594167
-        if (r < 0)
594167
-                return r;
594167
-
594167
-        if (n_pushed && added)
594167
-                (*n_pushed)++;
594167
-        return 0;
594167
+                return strv_extend(m, "");
594167
 }
594167
 
594167
 int load_env_file_pairs(FILE *f, const char *fname, char ***rl) {
594167
-        char **m = NULL;
594167
+        _cleanup_strv_free_ char **m = NULL;
594167
         int r;
594167
 
594167
-        r = parse_env_file_internal(f, fname, load_env_file_push_pairs, &m, NULL);
594167
-        if (r < 0) {
594167
-                strv_free(m);
594167
+        r = parse_env_file_internal(f, fname, load_env_file_push_pairs, &m);
594167
+        if (r < 0)
594167
                 return r;
594167
-        }
594167
 
594167
-        *rl = m;
594167
+        *rl = TAKE_PTR(m);
594167
         return 0;
594167
 }
594167
 
594167
 static int merge_env_file_push(
594167
                 const char *filename, unsigned line,
594167
                 const char *key, char *value,
594167
-                void *userdata,
594167
-                int *n_pushed) {
594167
+                void *userdata) {
594167
 
594167
         char ***env = userdata;
594167
         char *expanded_value;
594167
@@ -498,7 +471,7 @@ static int merge_env_file_push(
594167
 
594167
         log_debug("%s:%u: setting %s=%s", filename, line, key, value);
594167
 
594167
-        return load_env_file_push(filename, line, key, value, env, n_pushed);
594167
+        return load_env_file_push(filename, line, key, value, env);
594167
 }
594167
 
594167
 int merge_env_file(
594167
@@ -510,7 +483,7 @@ int merge_env_file(
594167
          * plus "extended" substitutions, unlike other exported parsing functions.
594167
          */
594167
 
594167
-        return parse_env_file_internal(f, fname, merge_env_file_push, env, NULL);
594167
+        return parse_env_file_internal(f, fname, merge_env_file_push, env);
594167
 }
594167
 
594167
 static void write_env_var(FILE *f, const char *v) {
594167
diff --git a/src/basic/path-lookup.c b/src/basic/path-lookup.c
594167
index 921a30cef7..ab51955e34 100644
594167
--- a/src/basic/path-lookup.c
594167
+++ b/src/basic/path-lookup.c
594167
@@ -509,7 +509,7 @@ static int get_paths_from_environ(const char *var, char ***paths, bool *append)
594167
 }
594167
 
594167
 int lookup_paths_init(
594167
-                LookupPaths *p,
594167
+                LookupPaths *lp,
594167
                 UnitFileScope scope,
594167
                 LookupPathsFlags flags,
594167
                 const char *root_dir) {
594167
@@ -527,7 +527,7 @@ int lookup_paths_init(
594167
         _cleanup_strv_free_ char **paths = NULL;
594167
         int r;
594167
 
594167
-        assert(p);
594167
+        assert(lp);
594167
         assert(scope >= 0);
594167
         assert(scope < _UNIT_FILE_SCOPE_MAX);
594167
 
594167
@@ -717,7 +717,7 @@ int lookup_paths_init(
594167
         if (r < 0)
594167
                 return -ENOMEM;
594167
 
594167
-        *p = (LookupPaths) {
594167
+        *lp = (LookupPaths) {
594167
                 .search_path = strv_uniq(TAKE_PTR(paths)),
594167
 
594167
                 .persistent_config = TAKE_PTR(persistent_config),
594167
@@ -742,41 +742,51 @@ int lookup_paths_init(
594167
         return 0;
594167
 }
594167
 
594167
-void lookup_paths_free(LookupPaths *p) {
594167
-        if (!p)
594167
+int lookup_paths_init_or_warn(LookupPaths *lp, UnitFileScope scope, LookupPathsFlags flags, const char *root_dir) {
594167
+        int r;
594167
+
594167
+        r = lookup_paths_init(lp, scope, flags, root_dir);
594167
+        if (r < 0)
594167
+                return log_error_errno(r, "Failed to initialize unit search paths%s%s: %m",
594167
+                                       isempty(root_dir) ? "" : " for root directory ", strempty(root_dir));
594167
+        return r;
594167
+}
594167
+
594167
+void lookup_paths_free(LookupPaths *lp) {
594167
+        if (!lp)
594167
                 return;
594167
 
594167
-        p->search_path = strv_free(p->search_path);
594167
+        lp->search_path = strv_free(lp->search_path);
594167
 
594167
-        p->persistent_config = mfree(p->persistent_config);
594167
-        p->runtime_config = mfree(p->runtime_config);
594167
+        lp->persistent_config = mfree(lp->persistent_config);
594167
+        lp->runtime_config = mfree(lp->runtime_config);
594167
 
594167
-        p->persistent_attached = mfree(p->persistent_attached);
594167
-        p->runtime_attached = mfree(p->runtime_attached);
594167
+        lp->persistent_attached = mfree(lp->persistent_attached);
594167
+        lp->runtime_attached = mfree(lp->runtime_attached);
594167
 
594167
-        p->generator = mfree(p->generator);
594167
-        p->generator_early = mfree(p->generator_early);
594167
-        p->generator_late = mfree(p->generator_late);
594167
+        lp->generator = mfree(lp->generator);
594167
+        lp->generator_early = mfree(lp->generator_early);
594167
+        lp->generator_late = mfree(lp->generator_late);
594167
 
594167
-        p->transient = mfree(p->transient);
594167
+        lp->transient = mfree(lp->transient);
594167
 
594167
-        p->persistent_control = mfree(p->persistent_control);
594167
-        p->runtime_control = mfree(p->runtime_control);
594167
+        lp->persistent_control = mfree(lp->persistent_control);
594167
+        lp->runtime_control = mfree(lp->runtime_control);
594167
 
594167
-        p->root_dir = mfree(p->root_dir);
594167
-        p->temporary_dir = mfree(p->temporary_dir);
594167
+        lp->root_dir = mfree(lp->root_dir);
594167
+        lp->temporary_dir = mfree(lp->temporary_dir);
594167
 }
594167
 
594167
-void lookup_paths_log(LookupPaths *p) {
594167
-        assert(p);
594167
+void lookup_paths_log(LookupPaths *lp) {
594167
+        assert(lp);
594167
 
594167
-        if (strv_isempty(p->search_path)) {
594167
+        if (strv_isempty(lp->search_path)) {
594167
                 log_debug("Ignoring unit files.");
594167
-                p->search_path = strv_free(p->search_path);
594167
+                lp->search_path = strv_free(lp->search_path);
594167
         } else {
594167
                 _cleanup_free_ char *t = NULL;
594167
 
594167
-                t = strv_join(p->search_path, "\n\t");
594167
+                t = strv_join(lp->search_path, "\n\t");
594167
                 log_debug("Looking for unit files in (higher priority first):\n\t%s", strna(t));
594167
         }
594167
 }
594167
diff --git a/src/basic/path-lookup.h b/src/basic/path-lookup.h
594167
index af85dc7b4f..1f0e5ea271 100644
594167
--- a/src/basic/path-lookup.h
594167
+++ b/src/basic/path-lookup.h
594167
@@ -54,7 +54,8 @@ struct LookupPaths {
594167
         char *temporary_dir;
594167
 };
594167
 
594167
-int lookup_paths_init(LookupPaths *p, UnitFileScope scope, LookupPathsFlags flags, const char *root_dir);
594167
+int lookup_paths_init(LookupPaths *lp, UnitFileScope scope, LookupPathsFlags flags, const char *root_dir);
594167
+int lookup_paths_init_or_warn(LookupPaths *lp, UnitFileScope scope, LookupPathsFlags flags, const char *root_dir);
594167
 
594167
 int xdg_user_dirs(char ***ret_config_dirs, char ***ret_data_dirs);
594167
 int xdg_user_runtime_dir(char **ret, const char *suffix);
594167
diff --git a/src/core/manager.c b/src/core/manager.c
594167
index 12c49e7fca..22bd0866c5 100644
594167
--- a/src/core/manager.c
594167
+++ b/src/core/manager.c
594167
@@ -1756,11 +1756,11 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds, const char *roo
594167
 
594167
         /* If we are running in test mode, we still want to run the generators,
594167
          * but we should not touch the real generator directories. */
594167
-        r = lookup_paths_init(&m->lookup_paths, m->unit_file_scope,
594167
-                              MANAGER_IS_TEST_RUN(m) ? LOOKUP_PATHS_TEMPORARY_GENERATED : 0,
594167
-                              root);
594167
+        r = lookup_paths_init_or_warn(&m->lookup_paths, m->unit_file_scope,
594167
+                                      MANAGER_IS_TEST_RUN(m) ? LOOKUP_PATHS_TEMPORARY_GENERATED : 0,
594167
+                                      root);
594167
         if (r < 0)
594167
-                return log_error_errno(r, "Failed to initialize path lookup table: %m");
594167
+                return r;
594167
 
594167
         dual_timestamp_get(m->timestamps + manager_timestamp_initrd_mangle(MANAGER_TIMESTAMP_GENERATORS_START));
594167
         r = manager_run_environment_generators(m);
594167
@@ -3302,9 +3302,9 @@ int manager_reload(Manager *m) {
594167
         m->uid_refs = hashmap_free(m->uid_refs);
594167
         m->gid_refs = hashmap_free(m->gid_refs);
594167
 
594167
-        r = lookup_paths_init(&m->lookup_paths, m->unit_file_scope, 0, NULL);
594167
+        r = lookup_paths_init_or_warn(&m->lookup_paths, m->unit_file_scope, 0, NULL);
594167
         if (r < 0)
594167
-                log_warning_errno(r, "Failed to initialize path lookup table, ignoring: %m");
594167
+                return r;
594167
 
594167
         (void) manager_run_environment_generators(m);
594167
         (void) manager_run_generators(m);
594167
diff --git a/src/shared/condition.c b/src/shared/condition.c
594167
index 68fbbf643a..21f3714eba 100644
594167
--- a/src/shared/condition.c
594167
+++ b/src/shared/condition.c
594167
@@ -787,7 +787,8 @@ static int condition_test_needs_update(Condition *c, char **env) {
594167
         if (r < 0) {
594167
                 log_debug_errno(r, "Failed to parse timestamp file '%s', using mtime: %m", p);
594167
                 return true;
594167
-        } else if (r == 0) {
594167
+        }
594167
+        if (isempty(timestamp_str)) {
594167
                 log_debug("No data in timestamp file '%s', using mtime.", p);
594167
                 return true;
594167
         }
594167
diff --git a/src/shared/install.c b/src/shared/install.c
594167
index a541d32fb7..f1a8b7eb9b 100644
594167
--- a/src/shared/install.c
594167
+++ b/src/shared/install.c
594167
@@ -2615,7 +2615,7 @@ int unit_file_enable(
594167
         assert(scope >= 0);
594167
         assert(scope < _UNIT_FILE_SCOPE_MAX);
594167
 
594167
-        r = lookup_paths_init(&lp, scope, 0, root_dir);
594167
+        r = lookup_paths_init_or_warn(&lp, scope, 0, root_dir);
594167
         if (r < 0)
594167
                 return r;
594167
 
594167
diff --git a/src/systemctl/systemctl-edit.c b/src/systemctl/systemctl-edit.c
594167
index a97aa7be4c..92abd15636 100644
594167
--- a/src/systemctl/systemctl-edit.c
594167
+++ b/src/systemctl/systemctl-edit.c
594167
@@ -38,9 +38,9 @@ int cat(int argc, char *argv[], void *userdata) {
594167
         if (arg_transport != BUS_TRANSPORT_LOCAL)
594167
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Cannot remotely cat units.");
594167
 
594167
-        r = lookup_paths_init(&lp, arg_scope, 0, arg_root);
594167
+        r = lookup_paths_init_or_warn(&lp, arg_scope, 0, arg_root);
594167
         if (r < 0)
594167
-                return log_error_errno(r, "Failed to determine unit paths: %m");
594167
+                return r;
594167
 
594167
         r = acquire_bus(BUS_MANAGER, &bus;;
594167
         if (r < 0)
594167
@@ -511,9 +511,9 @@ int edit(int argc, char *argv[], void *userdata) {
594167
         if (arg_transport != BUS_TRANSPORT_LOCAL)
594167
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Cannot edit units remotely.");
594167
 
594167
-        r = lookup_paths_init(&lp, arg_scope, 0, arg_root);
594167
+        r = lookup_paths_init_or_warn(&lp, arg_scope, 0, arg_root);
594167
         if (r < 0)
594167
-                return log_error_errno(r, "Failed to determine unit paths: %m");
594167
+                return r;
594167
 
594167
         r = mac_selinux_init();
594167
         if (r < 0)
594167
diff --git a/src/systemctl/systemctl-enable.c b/src/systemctl/systemctl-enable.c
594167
index dcbe2c7302..7860f3dc6c 100644
594167
--- a/src/systemctl/systemctl-enable.c
594167
+++ b/src/systemctl/systemctl-enable.c
594167
@@ -142,7 +142,7 @@ int enable_unit(int argc, char *argv[], void *userdata) {
594167
                         char **name;
594167
                         _cleanup_(lookup_paths_free) LookupPaths lp = {};
594167
 
594167
-                        r = lookup_paths_init(&lp, arg_scope, 0, arg_root);
594167
+                        r = lookup_paths_init_or_warn(&lp, arg_scope, 0, arg_root);
594167
                         if (r < 0)
594167
                                 return r;
594167
 
594167
diff --git a/src/systemctl/systemctl-sysv-compat.c b/src/systemctl/systemctl-sysv-compat.c
594167
index 017dba2034..c6e8defd1b 100644
594167
--- a/src/systemctl/systemctl-sysv-compat.c
594167
+++ b/src/systemctl/systemctl-sysv-compat.c
594167
@@ -128,7 +128,7 @@ int enable_sysv_units(const char *verb, char **args) {
594167
                         "is-enabled"))
594167
                 return 0;
594167
 
594167
-        r = lookup_paths_init(&paths, arg_scope, LOOKUP_PATHS_EXCLUDE_GENERATED, arg_root);
594167
+        r = lookup_paths_init_or_warn(&paths, arg_scope, LOOKUP_PATHS_EXCLUDE_GENERATED, arg_root);
594167
         if (r < 0)
594167
                 return r;
594167
 
594167
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
594167
index e9976540b5..bb74b486be 100644
594167
--- a/src/sysv-generator/sysv-generator.c
594167
+++ b/src/sysv-generator/sysv-generator.c
594167
@@ -894,9 +894,9 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
594167
 
594167
         assert_se(arg_dest = dest_late);
594167
 
594167
-        r = lookup_paths_init(&lp, UNIT_FILE_SYSTEM, LOOKUP_PATHS_EXCLUDE_GENERATED, NULL);
594167
+        r = lookup_paths_init_or_warn(&lp, UNIT_FILE_SYSTEM, LOOKUP_PATHS_EXCLUDE_GENERATED, NULL);
594167
         if (r < 0)
594167
-                return log_error_errno(r, "Failed to find lookup paths: %m");
594167
+                return r;
594167
 
594167
         all_services = hashmap_new(&string_hash_ops);
594167
         if (!all_services)
594167
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
594167
index 4f91d94709..238ae8f586 100644
594167
--- a/src/test/test-fileio.c
594167
+++ b/src/test/test-fileio.c
594167
@@ -110,8 +110,7 @@ TEST(parse_env_file) {
594167
                        "eleven", &eleven,
594167
                        "twelve", &twelve,
594167
                        "thirteen", &thirteen);
594167
-
594167
-        assert_se(r >= 0);
594167
+        assert_se(r == 0);
594167
 
594167
         log_info("one=[%s]", strna(one));
594167
         log_info("two=[%s]", strna(two));
594167
diff --git a/src/test/test-os-util.c b/src/test/test-os-util.c
594167
index d6336c53e9..2cee6470c4 100644
594167
--- a/src/test/test-os-util.c
594167
+++ b/src/test/test-os-util.c
594167
@@ -18,7 +18,7 @@ TEST(path_is_os_tree) {
594167
 TEST(parse_os_release) {
594167
         /* Let's assume that we're running in a valid system, so os-release is available */
594167
         _cleanup_free_ char *id = NULL, *id2 = NULL, *name = NULL, *foobar = NULL;
594167
-        assert_se(parse_os_release(NULL, "ID", &id) == 1);
594167
+        assert_se(parse_os_release(NULL, "ID", &id) == 0);
594167
         log_info("ID: %s", id);
594167
 
594167
         assert_se(setenv("SYSTEMD_OS_RELEASE", "/dev/null", 1) == 0);
594167
@@ -31,7 +31,7 @@ TEST(parse_os_release) {
594167
                                 "NAME=the-name") == 0);
594167
 
594167
         assert_se(setenv("SYSTEMD_OS_RELEASE", tmpfile, 1) == 0);
594167
-        assert_se(parse_os_release(NULL, "ID", &id, "NAME", &name) == 2);
594167
+        assert_se(parse_os_release(NULL, "ID", &id, "NAME", &name) == 0);
594167
         log_info("ID: %s NAME: %s", id, name);
594167
         assert_se(streq(id, "the-id"));
594167
         assert_se(streq(name, "the-name"));
594167
@@ -43,8 +43,7 @@ TEST(parse_os_release) {
594167
                                 "NAME='the-name'") == 0);
594167
 
594167
         assert_se(setenv("SYSTEMD_OS_RELEASE", tmpfile2, 1) == 0);
594167
-        // FIXME: we return 3, which means that the return value is useless in face of repeats
594167
-        assert_se(parse_os_release(NULL, "ID", &id, "NAME", &name) == 3);
594167
+        assert_se(parse_os_release(NULL, "ID", &id, "NAME", &name) == 0);
594167
         log_info("ID: %s NAME: %s", id, name);
594167
         assert_se(streq(id, "the-id"));
594167
         assert_se(streq(name, "the-name"));