Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
DescriptionMasahiro Matsuya
2021-03-30 01:48:29 UTC
Description of problem:
Even with the 'X' type, the content in the specified directory are excluded.
From "man tmpfiles.d":
X
Ignore a path during cleaning. Use this type to exclude paths from clean-up as controlled with the Age parameter.
Unlike x, this parameter will not exclude the content if path is a directory, but only directory itself. Note that
lines of this type do not influence the effect of r or R lines. Lines of this type accept shell-style globs in
place of normal path names.
This was caused by the wrong usage of hashmap in read_config_file() of src/tmpfiles/tmpfiles.c.
This entry of this hashmap is ItemArray, but it is dealt with as Item.
static int read_config_file(char **config_dirs, const char *fn, bool ignore_enoent, bool *invalid_config) {
Item *i;
...
/* we have to determine age parameter for each entry of type X */
ORDERED_HASHMAP_FOREACH(i, globs, iterator) { <<====== This 'i' should be the variable of ItemArray structure.
Iterator iter;
Item *j, *candidate_item = NULL;
if (i->type != IGNORE_DIRECTORY_PATH) <<====== [A]
continue;
ORDERED_HASHMAP_FOREACH(j, items, iter) { <<====== This 'j' should be the variable of ItemArray structure.
if (!IN_SET(j->type, CREATE_DIRECTORY, TRUNCATE_DIRECTORY, CREATE_SUBVOLUME, CREATE_SUBVOLUME_INHERIT_QUOTA, CREATE_SUBVOLUME_NEW_QUOTA))
As a result, the condition in above [A] is *always* TRUE, even when the type is 'X' (IGNORE_DIRECTORY_PATH).
I created a proposed patch, and confirmed that it worked as expected.
Version-Release number of selected component (if applicable):
RHEL 8.3
How reproducible:
Always
Steps to Reproduce:
1. create /etc/tmpfiles.d/test.conf
# cat /etc/tmpfiles.d/test.conf
X /root/test/tmp
d /root/test - - - 0
2. make a directory and the contents for testing.
# mkdir -p ~/test/{tmp,tmp2}; touch ~/test/tmp/{x1,x2} ~/test/tmp2/{y1,y2} ~/test/{z1,z2}
3. Run systemd-tmpfiles
# systemd-tmpfiles --clean test.conf
Actual results:
The contents in the specified directory with 'X' type were excluded.
# tree ~/test
/root/test
└── tmp
├── x1
└── x2
Expected results:
The contents in the specified directory with 'X' type were not excluded for cleanup.
# tree ~/test
/root/test
└── tmp
Additional info:
It seems that the upstream has the same bug.
https://github.com/systemd/systemd/blob/main/src/tmpfiles/tmpfiles.c
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory (systemd bug fix and enhancement update), and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHBA-2022:2069
Description of problem: Even with the 'X' type, the content in the specified directory are excluded. From "man tmpfiles.d": X Ignore a path during cleaning. Use this type to exclude paths from clean-up as controlled with the Age parameter. Unlike x, this parameter will not exclude the content if path is a directory, but only directory itself. Note that lines of this type do not influence the effect of r or R lines. Lines of this type accept shell-style globs in place of normal path names. This was caused by the wrong usage of hashmap in read_config_file() of src/tmpfiles/tmpfiles.c. This entry of this hashmap is ItemArray, but it is dealt with as Item. static int read_config_file(char **config_dirs, const char *fn, bool ignore_enoent, bool *invalid_config) { Item *i; ... /* we have to determine age parameter for each entry of type X */ ORDERED_HASHMAP_FOREACH(i, globs, iterator) { <<====== This 'i' should be the variable of ItemArray structure. Iterator iter; Item *j, *candidate_item = NULL; if (i->type != IGNORE_DIRECTORY_PATH) <<====== [A] continue; ORDERED_HASHMAP_FOREACH(j, items, iter) { <<====== This 'j' should be the variable of ItemArray structure. if (!IN_SET(j->type, CREATE_DIRECTORY, TRUNCATE_DIRECTORY, CREATE_SUBVOLUME, CREATE_SUBVOLUME_INHERIT_QUOTA, CREATE_SUBVOLUME_NEW_QUOTA)) As a result, the condition in above [A] is *always* TRUE, even when the type is 'X' (IGNORE_DIRECTORY_PATH). I created a proposed patch, and confirmed that it worked as expected. Version-Release number of selected component (if applicable): RHEL 8.3 How reproducible: Always Steps to Reproduce: 1. create /etc/tmpfiles.d/test.conf # cat /etc/tmpfiles.d/test.conf X /root/test/tmp d /root/test - - - 0 2. make a directory and the contents for testing. # mkdir -p ~/test/{tmp,tmp2}; touch ~/test/tmp/{x1,x2} ~/test/tmp2/{y1,y2} ~/test/{z1,z2} 3. Run systemd-tmpfiles # systemd-tmpfiles --clean test.conf Actual results: The contents in the specified directory with 'X' type were excluded. # tree ~/test /root/test └── tmp ├── x1 └── x2 Expected results: The contents in the specified directory with 'X' type were not excluded for cleanup. # tree ~/test /root/test └── tmp Additional info: It seems that the upstream has the same bug. https://github.com/systemd/systemd/blob/main/src/tmpfiles/tmpfiles.c