]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
condition: check if path is absolute first
authorLennart Poettering <lennart@poettering.net>
Thu, 14 May 2020 07:18:58 +0000 (09:18 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 18 May 2020 17:55:56 +0000 (19:55 +0200)
We should do this check first since it is done on the string itself
without any conditioning of system state otherwise. It is a weird to do
this test only if /etc is read-only.

src/shared/condition.c

index c83a4ba0eb8a86a297e3a78e18d58a1ea53b595d..e5de303a4b66e348af32c067b90442cda17af0a9 100644 (file)
@@ -553,16 +553,15 @@ static int condition_test_needs_update(Condition *c, char **env) {
         assert(c->parameter);
         assert(c->type == CONDITION_NEEDS_UPDATE);
 
+        if (!path_is_absolute(c->parameter))
+                return true;
+
         /* If the file system is read-only we shouldn't suggest an update */
         if (path_is_read_only_fs(c->parameter) > 0)
                 return false;
 
-        /* Any other failure means we should allow the condition to be true,
-         * so that we rather invoke too many update tools than too
-         * few. */
-
-        if (!path_is_absolute(c->parameter))
-                return true;
+        /* Any other failure means we should allow the condition to be true, so that we rather invoke too
+         * many update tools than too few. */
 
         p = strjoina(c->parameter, "/.updated");
         if (lstat(p, &other) < 0)