]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
install: be more accurate when checking whether something is runtime configuration
authorLennart Poettering <lennart@poettering.net>
Wed, 24 Feb 2016 20:43:09 +0000 (21:43 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 12 Apr 2016 11:43:30 +0000 (13:43 +0200)
Let's actually check the runtime config dir, instead of just /run.

src/shared/install.c

index f80234339918e736e0b44fd8fd3bddb10f75a9d4..59582e573dbc65cd77d81e2c3b77db9a2e3e2949 100644 (file)
@@ -118,6 +118,22 @@ static int path_is_config(const LookupPaths *p, const char *path) {
                 path_equal(parent, p->runtime_config);
 }
 
+static int path_is_runtime(const LookupPaths *p, const char *path) {
+        _cleanup_free_ char *parent = NULL;
+
+        assert(p);
+        assert(path);
+
+        if (path_startswith(path, "/run"))
+                return true;
+
+        parent = dirname_malloc(path);
+        if (!parent)
+                return -ENOMEM;
+
+        return path_equal(parent, p->runtime_config);
+}
+
 static int verify_root_dir(UnitFileScope scope, const char **root_dir) {
         int r;
 
@@ -1950,7 +1966,11 @@ int unit_file_lookup_state(
         switch (i->type) {
 
         case UNIT_FILE_TYPE_MASKED:
-                state = path_startswith(i->path, "/run") ? UNIT_FILE_MASKED_RUNTIME : UNIT_FILE_MASKED;
+                r = path_is_runtime(paths, i->path);
+                if (r < 0)
+                        return r;
+
+                state = r > 0 ? UNIT_FILE_MASKED_RUNTIME : UNIT_FILE_MASKED;
                 break;
 
         case UNIT_FILE_TYPE_REGULAR: