mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-01 05:47:04 +03:00
tmpfiles: use a entry in hashmap as ItemArray in read_config_file()
[zjs: squash commits and use size_t as appropriate. Bug seems to have been introduced in 811a15877825da9e53f9a2a8603da34589af6bbb. Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1944468.] (cherry picked from commit bec890e3cd6dac249cb12ce9430fdb78b6cf546b) (cherry picked from commit b266eeb0aee24a0c5868c3a46066c0329b2d1141)
This commit is contained in:
parent
651e479e29
commit
dbfb698668
@ -3173,7 +3173,7 @@ static int read_config_file(char **config_dirs, const char *fn, bool ignore_enoe
|
||||
_cleanup_fclose_ FILE *_f = NULL;
|
||||
unsigned v = 0;
|
||||
FILE *f;
|
||||
Item *i;
|
||||
ItemArray *ia;
|
||||
int r = 0;
|
||||
|
||||
assert(fn);
|
||||
@ -3226,32 +3226,37 @@ static int read_config_file(char **config_dirs, const char *fn, bool ignore_enoe
|
||||
}
|
||||
|
||||
/* we have to determine age parameter for each entry of type X */
|
||||
ORDERED_HASHMAP_FOREACH(i, globs) {
|
||||
Item *j, *candidate_item = NULL;
|
||||
ORDERED_HASHMAP_FOREACH(ia, globs)
|
||||
for (size_t ni = 0; ni < ia->n_items; ni++) {
|
||||
ItemArray *ja;
|
||||
Item *i = ia->items + ni, *candidate_item = NULL;
|
||||
|
||||
if (i->type != IGNORE_DIRECTORY_PATH)
|
||||
continue;
|
||||
|
||||
ORDERED_HASHMAP_FOREACH(j, items) {
|
||||
if (!IN_SET(j->type, CREATE_DIRECTORY, TRUNCATE_DIRECTORY, CREATE_SUBVOLUME, CREATE_SUBVOLUME_INHERIT_QUOTA, CREATE_SUBVOLUME_NEW_QUOTA))
|
||||
if (i->type != IGNORE_DIRECTORY_PATH)
|
||||
continue;
|
||||
|
||||
if (path_equal(j->path, i->path)) {
|
||||
candidate_item = j;
|
||||
break;
|
||||
ORDERED_HASHMAP_FOREACH(ja, items)
|
||||
for (size_t nj = 0; nj < ja->n_items; nj++) {
|
||||
Item *j = ja->items + nj;
|
||||
|
||||
if (!IN_SET(j->type, CREATE_DIRECTORY, TRUNCATE_DIRECTORY, CREATE_SUBVOLUME, CREATE_SUBVOLUME_INHERIT_QUOTA, CREATE_SUBVOLUME_NEW_QUOTA))
|
||||
continue;
|
||||
|
||||
if (path_equal(j->path, i->path)) {
|
||||
candidate_item = j;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((!candidate_item && path_startswith(i->path, j->path)) ||
|
||||
(candidate_item && path_startswith(j->path, candidate_item->path) && (fnmatch(i->path, j->path, FNM_PATHNAME | FNM_PERIOD) == 0)))
|
||||
candidate_item = j;
|
||||
}
|
||||
|
||||
if (candidate_item && candidate_item->age_set) {
|
||||
i->age = candidate_item->age;
|
||||
i->age_set = true;
|
||||
}
|
||||
|
||||
if ((!candidate_item && path_startswith(i->path, j->path)) ||
|
||||
(candidate_item && path_startswith(j->path, candidate_item->path) && (fnmatch(i->path, j->path, FNM_PATHNAME | FNM_PERIOD) == 0)))
|
||||
candidate_item = j;
|
||||
}
|
||||
|
||||
if (candidate_item && candidate_item->age_set) {
|
||||
i->age = candidate_item->age;
|
||||
i->age_set = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (ferror(f)) {
|
||||
log_error_errno(errno, "Failed to read from file %s: %m", fn);
|
||||
if (r == 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user