summaryrefslogtreecommitdiffstats
path: root/src/shared/unit-file.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-08-30 14:10:42 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-08-30 14:10:42 +0200
commit890befcf47b19c9aff4d9d92ab3a1231b29770ab (patch)
tree11a9d34b544e2c9d9a4402fd6488ac4d6e82ff1d /src/shared/unit-file.c
parentshared/unit-files: we must not filter out names starting with a dot (diff)
downloadsystemd-890befcf47b19c9aff4d9d92ab3a1231b29770ab.tar.xz
systemd-890befcf47b19c9aff4d9d92ab3a1231b29770ab.zip
shared/unit-files: only put valid unit paths and dropin dirs in the cache
Diffstat (limited to 'src/shared/unit-file.c')
-rw-r--r--src/shared/unit-file.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/shared/unit-file.c b/src/shared/unit-file.c
index b9b5268d0a..4a5f23e6c1 100644
--- a/src/shared/unit-file.c
+++ b/src/shared/unit-file.c
@@ -246,6 +246,15 @@ int unit_file_build_name_map(
char *filename;
_cleanup_free_ char *_filename_free = NULL, *simplified = NULL;
const char *suffix, *dst = NULL;
+ bool valid_unit_name;
+
+ valid_unit_name = unit_name_is_valid(de->d_name, UNIT_NAME_ANY);
+
+ /* We only care about valid units and dirs with certain suffixes, let's ignore the
+ * rest. */
+ if (!valid_unit_name &&
+ !ENDSWITH_SET(de->d_name, ".wants", ".requires", ".d"))
+ continue;
filename = path_join(*dir, de->d_name);
if (!filename)
@@ -260,7 +269,7 @@ int unit_file_build_name_map(
} else
_filename_free = filename; /* Make sure we free the filename. */
- if (!unit_name_is_valid(de->d_name, UNIT_NAME_ANY))
+ if (!valid_unit_name)
continue;
assert_se(suffix = strrchr(de->d_name, '.'));