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.
Bug 1944468 - No difference between x and X type in systemd-tmpfiles
Summary: No difference between x and X type in systemd-tmpfiles
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: systemd
Version: 8.4
Hardware: x86_64
OS: All
medium
medium
Target Milestone: rc
: 8.5
Assignee: David Tardon
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-03-30 01:48 UTC by Masahiro Matsuya
Modified: 2022-05-10 16:44 UTC (History)
3 users (show)

Fixed In Version: systemd-239-57.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-10 15:25:47 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github redhat-plumbers systemd-rhel8 pull 212 0 None open tmpfiles: fix handling of X 2021-09-24 11:34:30 UTC
Github systemd systemd pull 19164 0 None open tmpfiles: use a entry in hashmap as ItemArray in read_config_file() 2021-03-31 05:36:51 UTC
Red Hat Product Errata RHBA-2022:2069 0 None None None 2022-05-10 15:26:21 UTC

Description Masahiro 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

Comment 8 Plumber Bot 2021-08-31 08:24:20 UTC
fix merged to github master branch -> https://github.com/redhat-plumbers/systemd-rhel8/pull/170

Comment 12 Plumber Bot 2022-01-24 13:40:51 UTC
fix merged to github master branch -> https://github.com/redhat-plumbers/systemd-rhel8/pull/212

Comment 17 errata-xmlrpc 2022-05-10 15:25:47 UTC
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


Note You need to log in before you can comment on or make changes to this bug.