conf-files: drop use of CONF_FILES_CHASE_BASENAME in conf_files_list_with_replacement()
The flag has several potential issues, and will be dropped in the next
commit.
Follow-up for 41fb58595a.
This commit is contained in:
+1
-10
@@ -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);
|
||||
|
||||
+40
-40
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user