]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
path-lookup: add flag to optionally force checking split-usr unit dirs
authorLennart Poettering <lennart@poettering.net>
Mon, 16 Apr 2018 10:36:07 +0000 (12:36 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 24 May 2018 15:01:57 +0000 (17:01 +0200)
When we look into a portable service image it might contain the unit
files in split-usr directories rather than merged-usr directories as on
the host. Hence, let#s add a flag that checking all dirs can be forced.

src/shared/path-lookup.c
src/shared/path-lookup.h

index 9919b2f2c2869efd72d86701e3385c6fdf39b58d..e71af2f7cb707f544c6bfe37dc5afd35787035a3 100644 (file)
@@ -263,10 +263,8 @@ static int acquire_generator_dirs(
 
         if (tempdir)
                 prefix = tempdir;
-
         else if (scope == UNIT_FILE_SYSTEM)
                 prefix = "/run/systemd";
-
         else if (scope == UNIT_FILE_USER) {
                 const char *e;
 
@@ -484,6 +482,10 @@ int lookup_paths_init(
         assert(scope >= 0);
         assert(scope < _UNIT_FILE_SCOPE_MAX);
 
+#if HAVE_SPLIT_USR
+        flags |= LOOKUP_PATHS_SPLIT_USR;
+#endif
+
         if (!empty_or_root(root_dir)) {
                 if (scope == UNIT_FILE_USER)
                         return -EINVAL;
@@ -582,9 +584,7 @@ int lookup_paths_init(
                                         "/usr/local/lib/systemd/system",
                                         SYSTEM_DATA_UNIT_PATH,
                                         "/usr/lib/systemd/system",
-#if HAVE_SPLIT_USR
-                                        "/lib/systemd/system",
-#endif
+                                        STRV_IFNOTNULL(flags & LOOKUP_PATHS_SPLIT_USR ? "/lib/systemd/system" : NULL),
                                         STRV_IFNOTNULL(generator_late),
                                         NULL);
                         break;
index f5bba63f5b0b328df8a5910701b347973eb10f1c..357816fd08515fe695691565e2c95478c567cf43 100644 (file)
@@ -15,8 +15,9 @@ typedef struct LookupPaths LookupPaths;
 #include "macro.h"
 
 typedef enum LookupPathsFlags {
-        LOOKUP_PATHS_EXCLUDE_GENERATED   = 1 << 0,
-        LOOKUP_PATHS_TEMPORARY_GENERATED = 1 << 1,
+        LOOKUP_PATHS_EXCLUDE_GENERATED   = 1U << 0,
+        LOOKUP_PATHS_TEMPORARY_GENERATED = 1U << 1,
+        LOOKUP_PATHS_SPLIT_USR           = 1U << 2,
 } LookupPathsFlags;
 
 struct LookupPaths {