tmpfiles: clean what an e entry with a glob matches

An e entry takes a glob, but cleaning looked for a directory with
the pattern as its name:

    e /var/cache/* - - - 10d

    tmpfiles --clean t.conf

This cleaned nothing.

Expand the glob and clean each directory it matches.  Also use the
age of a C entry, tmpfiles.d(5) has it clean what it copied.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-20 18:03:34 +01:00
1 parent 9d49eaf4c7
commit bccd04d81d
3 files changed
+16 -6

No files matched your search

+7 -3
View File
@@ -1198,11 +1198,15 @@ static void tmpfiles(char *line)
}
/* age-based cleanup logic */
if (clean_flag && strchr("dDe", type[0]) && !parse_age(age, &clean_age)) {
if (clean_flag && strchr("CdDe", type[0]) && !parse_age(age, &clean_age)) {
clean_now = time(NULL);
/* Nothing is older than the epoch */
if (clean_age.sec <= clean_now)
/* Only e takes a glob, and nothing is older than the epoch */
if (clean_age.sec > clean_now)
;
else if (type[0] == 'e')
glob_do(path, clean_dir);
else
clean_dir(path);
}