]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
analyze: do not prepend the current working directory to SYSTEMD_UNIT_PATH needlessly 30172/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Nov 2023 20:22:33 +0000 (05:22 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Nov 2023 20:28:14 +0000 (05:28 +0900)
If the requested unit is not in the current working directory, it is not
necessary to include the current working directory in SYSTEMD_UNIT_PATH.

Follow-up for 45519d13a4f2a3c3585e672595762ca621abe65e.

Fixes #30166.

src/analyze/analyze-verify-util.c

index cfafbd4d44de03d857488e98f244695cd7097a79..f3ce0ad1f17e309e6117d4e94aee2555917a950d 100644 (file)
@@ -86,6 +86,9 @@ int verify_set_unit_path(char **filenames) {
                 if (r < 0)
                         return r;
 
+                if (access(a, F_OK) < 0)
+                        continue;
+
                 r = path_extract_directory(a, &t);
                 if (r < 0)
                         return r;
@@ -99,6 +102,9 @@ int verify_set_unit_path(char **filenames) {
         if (!joined)
                 return -ENOMEM;
 
+        if (isempty(joined))
+                return 0;
+
         /* First, prepend our directories. Second, if some path was specified, use that, and
          * otherwise use the defaults. Any duplicates will be filtered out in path-lookup.c.
          * Treat explicit empty path to mean that nothing should be appended. */