]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
conf-files: drop use of CONF_FILES_CHASE_BASENAME in conf_files_list_with_replacement()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 28 Jun 2025 13:58:05 +0000 (22:58 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 29 Jun 2025 01:15:56 +0000 (10:15 +0900)
The flag has several potential issues, and will be dropped in the next
commit.

Follow-up for 41fb58595a22d50ca79278a64de4bff28f6dfd24.

src/basic/conf-files.c
src/test/test-conf-files.c

index 3233679c745baf61c38782f1db3e234dc67e7327..48fabc04424d872f2fb1658cdc47b0d21136c89c 100644 (file)
@@ -295,15 +295,6 @@ static int conf_files_list_impl(
                 resolved_replacement = path_join(resolved_dirpath_replacement, filename_replacement);
                 if (!resolved_replacement)
                         return log_oom_debug();
-
-                if (FLAGS_SET(flags, CONF_FILES_CHASE_BASENAME)) {
-                        _cleanup_free_ char *p = NULL;
-                        r = chaseat(rfd, resolved_replacement, CHASE_AT_RESOLVE_IN_ROOT | CHASE_NONEXISTENT, &p, /* ret_fd = */ NULL);
-                        if (r < 0)
-                                return r;
-
-                        free_and_replace(resolved_replacement, p);
-                }
         }
 
         STRV_FOREACH(p, dirs) {
@@ -428,7 +419,7 @@ int conf_files_list_with_replacement(
 
         _cleanup_hashmap_free_ Hashmap *fh = NULL;
         _cleanup_free_ char *inserted = NULL;
-        ConfFilesFlags flags = CONF_FILES_REGULAR | CONF_FILES_CHASE_BASENAME | CONF_FILES_FILTER_MASKED_BY_SYMLINK;
+        ConfFilesFlags flags = CONF_FILES_REGULAR | CONF_FILES_FILTER_MASKED_BY_SYMLINK;
         int r;
 
         assert(ret_files);
index e7dd95f18cb3806f7f23866de3bc6dab1fbb68c4..90b2f2f9b91f469af796c66b49e916ca10419fa6 100644 (file)
@@ -332,12 +332,12 @@ TEST(conf_files_list) {
         strv_print(result);
         ASSERT_TRUE(strv_equal(result, STRV_MAKE(search1_a,
                                                  search2_aa,
-                                                 strjoina(t2, "/absolute-empty.real"),
-                                                 strjoina(t2, "/absolute-non-empty.real"),
+                                                 strjoina(search3, "absolute-empty.conf"),
+                                                 strjoina(search3, "absolute-non-empty.conf"),
                                                  search1_b,
                                                  strjoina(search2, "mm.conf"),
-                                                 strjoina(t2, "/relative-empty.real"),
-                                                 strjoina(t2, "/relative-non-empty.real"))));
+                                                 strjoina(search3, "relative-empty.conf"),
+                                                 strjoina(search3, "relative-non-empty.conf"))));
         ASSERT_STREQ(inserted, search1_a);
         result = strv_free(result);
         inserted = mfree(inserted);
@@ -346,12 +346,12 @@ TEST(conf_files_list) {
         strv_print(result);
         ASSERT_TRUE(strv_equal(result, STRV_MAKE(search1_a,
                                                  strjoina(search1, "aa.conf"),
-                                                 strjoina(t2, "/absolute-empty.real"),
-                                                 strjoina(t2, "/absolute-non-empty.real"),
+                                                 strjoina(search3, "absolute-empty.conf"),
+                                                 strjoina(search3, "absolute-non-empty.conf"),
                                                  search1_b,
                                                  strjoina(search2, "mm.conf"),
-                                                 strjoina(t2, "/relative-empty.real"),
-                                                 strjoina(t2, "/relative-non-empty.real"))));
+                                                 strjoina(search3, "relative-empty.conf"),
+                                                 strjoina(search3, "relative-non-empty.conf"))));
         ASSERT_STREQ(inserted, strjoina(search1, "aa.conf"));
         result = strv_free(result);
         inserted = mfree(inserted);
@@ -360,12 +360,12 @@ TEST(conf_files_list) {
         strv_print(result);
         ASSERT_TRUE(strv_equal(result, STRV_MAKE(search1_a,
                                                  search2_aa,
-                                                 strjoina(t2, "/absolute-empty.real"),
-                                                 strjoina(t2, "/absolute-non-empty.real"),
+                                                 strjoina(search3, "absolute-empty.conf"),
+                                                 strjoina(search3, "absolute-non-empty.conf"),
                                                  search1_b,
                                                  strjoina(search2, "mm.conf"),
-                                                 strjoina(t2, "/relative-empty.real"),
-                                                 strjoina(t2, "/relative-non-empty.real"))));
+                                                 strjoina(search3, "relative-empty.conf"),
+                                                 strjoina(search3, "relative-non-empty.conf"))));
         ASSERT_NULL(inserted);
         result = strv_free(result);
         inserted = mfree(inserted);
@@ -374,12 +374,12 @@ TEST(conf_files_list) {
         strv_print(result);
         ASSERT_TRUE(strv_equal(result, STRV_MAKE(search1_a,
                                                  search2_aa,
-                                                 strjoina(t2, "/absolute-empty.real"),
-                                                 strjoina(t2, "/absolute-non-empty.real"),
+                                                 strjoina(search3, "absolute-empty.conf"),
+                                                 strjoina(search3, "absolute-non-empty.conf"),
                                                  search1_b,
                                                  strjoina(search2, "mm.conf"),
-                                                 strjoina(t2, "/relative-empty.real"),
-                                                 strjoina(t2, "/relative-non-empty.real"))));
+                                                 strjoina(search3, "relative-empty.conf"),
+                                                 strjoina(search3, "relative-non-empty.conf"))));
         ASSERT_NULL(inserted);
         result = strv_free(result);
         inserted = mfree(inserted);
@@ -388,12 +388,12 @@ TEST(conf_files_list) {
         strv_print(result);
         ASSERT_TRUE(strv_equal(result, STRV_MAKE(search1_a,
                                                  search2_aa,
-                                                 strjoina(t2, "/absolute-empty.real"),
-                                                 strjoina(t2, "/absolute-non-empty.real"),
+                                                 strjoina(search3, "absolute-empty.conf"),
+                                                 strjoina(search3, "absolute-non-empty.conf"),
                                                  search1_b,
                                                  strjoina(search2, "mm.conf"),
-                                                 strjoina(t2, "/relative-empty.real"),
-                                                 strjoina(t2, "/relative-non-empty.real"),
+                                                 strjoina(search3, "relative-empty.conf"),
+                                                 strjoina(search3, "relative-non-empty.conf"),
                                                  strjoina(t, "/dir4/x.conf"))));
         ASSERT_STREQ(inserted, strjoina(t, "/dir4/x.conf"));
         result = strv_free(result);
@@ -403,11 +403,11 @@ TEST(conf_files_list) {
         strv_print(result);
         ASSERT_TRUE(strv_equal(result, STRV_MAKE(search1_a,
                                                  search2_aa,
-                                                 strjoina(t, "/absolute-empty-for-root.real"),
-                                                 strjoina(t, "/absolute-non-empty-for-root.real"),
+                                                 strjoina(search3, "absolute-empty-for-root.conf"),
+                                                 strjoina(search3, "absolute-non-empty-for-root.conf"),
                                                  search1_b,
-                                                 strjoina(t, "/relative-empty-for-root.real"),
-                                                 strjoina(t, "/relative-non-empty-for-root.real"))));
+                                                 strjoina(search3, "relative-empty-for-root.conf"),
+                                                 strjoina(search3, "relative-non-empty-for-root.conf"))));
         ASSERT_STREQ(inserted, search1_a);
         result = strv_free(result);
         inserted = mfree(inserted);
@@ -416,11 +416,11 @@ TEST(conf_files_list) {
         strv_print(result);
         ASSERT_TRUE(strv_equal(result, STRV_MAKE(search1_a,
                                                  strjoina(search1, "aa.conf"),
-                                                 strjoina(t, "/absolute-empty-for-root.real"),
-                                                 strjoina(t, "/absolute-non-empty-for-root.real"),
+                                                 strjoina(search3, "absolute-empty-for-root.conf"),
+                                                 strjoina(search3, "absolute-non-empty-for-root.conf"),
                                                  search1_b,
-                                                 strjoina(t, "/relative-empty-for-root.real"),
-                                                 strjoina(t, "/relative-non-empty-for-root.real"))));
+                                                 strjoina(search3, "relative-empty-for-root.conf"),
+                                                 strjoina(search3, "relative-non-empty-for-root.conf"))));
         ASSERT_STREQ(inserted, strjoina(search1, "aa.conf"));
         result = strv_free(result);
         inserted = mfree(inserted);
@@ -429,11 +429,11 @@ TEST(conf_files_list) {
         strv_print(result);
         ASSERT_TRUE(strv_equal(result, STRV_MAKE(search1_a,
                                                  search2_aa,
-                                                 strjoina(t, "/absolute-empty-for-root.real"),
-                                                 strjoina(t, "/absolute-non-empty-for-root.real"),
+                                                 strjoina(search3, "absolute-empty-for-root.conf"),
+                                                 strjoina(search3, "absolute-non-empty-for-root.conf"),
                                                  search1_b,
-                                                 strjoina(t, "/relative-empty-for-root.real"),
-                                                 strjoina(t, "/relative-non-empty-for-root.real"))));
+                                                 strjoina(search3, "relative-empty-for-root.conf"),
+                                                 strjoina(search3, "relative-non-empty-for-root.conf"))));
         ASSERT_NULL(inserted);
         result = strv_free(result);
         inserted = mfree(inserted);
@@ -442,11 +442,11 @@ TEST(conf_files_list) {
         strv_print(result);
         ASSERT_TRUE(strv_equal(result, STRV_MAKE(search1_a,
                                                  search2_aa,
-                                                 strjoina(t, "/absolute-empty-for-root.real"),
-                                                 strjoina(t, "/absolute-non-empty-for-root.real"),
+                                                 strjoina(search3, "absolute-empty-for-root.conf"),
+                                                 strjoina(search3, "absolute-non-empty-for-root.conf"),
                                                  search1_b,
-                                                 strjoina(t, "/relative-empty-for-root.real"),
-                                                 strjoina(t, "/relative-non-empty-for-root.real"))));
+                                                 strjoina(search3, "relative-empty-for-root.conf"),
+                                                 strjoina(search3, "relative-non-empty-for-root.conf"))));
         ASSERT_NULL(inserted);
         result = strv_free(result);
         inserted = mfree(inserted);
@@ -455,11 +455,11 @@ TEST(conf_files_list) {
         strv_print(result);
         ASSERT_TRUE(strv_equal(result, STRV_MAKE(search1_a,
                                                  search2_aa,
-                                                 strjoina(t, "/absolute-empty-for-root.real"),
-                                                 strjoina(t, "/absolute-non-empty-for-root.real"),
+                                                 strjoina(search3, "absolute-empty-for-root.conf"),
+                                                 strjoina(search3, "absolute-non-empty-for-root.conf"),
                                                  search1_b,
-                                                 strjoina(t, "/relative-empty-for-root.real"),
-                                                 strjoina(t, "/relative-non-empty-for-root.real"),
+                                                 strjoina(search3, "relative-empty-for-root.conf"),
+                                                 strjoina(search3, "relative-non-empty-for-root.conf"),
                                                  strjoina(t, "/dir4/x.conf"))));
         ASSERT_STREQ(inserted, strjoina(t, "/dir4/x.conf"));
         result = strv_free(result);