Bug 999831

Summary: systemd-tmpfiles doesn't exclude directory contents from clean-up for x rules
Product: Red Hat Enterprise Linux 7 Reporter: Jakub Filak <jfilak>
Component: systemdAssignee: Václav Pavlín <vpavlin>
Status: CLOSED CURRENTRELEASE QA Contact: Petr Sklenar <psklenar>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: aschorr, jberan, jfilak, jscotka, lnykryn, systemd-maint-list, vpavlin
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: systemd-207-9.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 11:17:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
an example of tmpfiles.d configuration file none

Description Jakub Filak 2013-08-22 08:41:06 UTC
Created attachment 789098 [details]
an example of tmpfiles.d configuration file

Description of problem:
path of x rules should be ignored during cleaning and if path is directory, all its contents should be ignored too.

Version-Release number of selected component (if applicable):
systemd-206-4.el7.x86_64

How reproducible:
always

Steps to Reproduce:
1. $ touch /var/tmp/abrt/foo
2. put the attached config file to /usr/lib/tmpfiles.d/
2. $ systemd-tmpfiles --create --clean --remove abrt.conf 
3. $ ls /var/tmp/abrt

Actual results:
ls: cannot access /var/tmp/abrt/foo: No such file or directory

Expected results:
/var/tmp/abrt/foo

Comment 2 Lukáš Nykrýn 2013-08-22 08:55:40 UTC
As we have discussed, current behavior is correct. If you don't want to delete whole directory, you have to use glob /var/tmp/abrt/*. This is mentioned in the manpage, but it is not obvious on the first sight. 
So I would suggest to add this scenario to examples.

Comment 3 Jakub Filak 2013-08-22 10:03:34 UTC
(In reply to Lukáš Nykrýn from comment #2)
Adding more examples would be great. Thank you!

Comment 5 Andrew J. Schorr 2013-09-30 13:43:10 UTC
I find the current man page very confusing on this point.  Here is the man page
section describing the "x" and "X" types:

       x
           Ignore a path during cleaning. Use this type to exclude paths from
           clean-up as controlled with the Age parameter. 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.

       X
           Ignore a path during cleanup. Use this type to prevent path removal
           as controlled with the Age parameter. Note that if path is a
           directory, content of a directory is not excluded from clean-up,
           only directory itself. Lines of this type accept shell-style globs
           in place of normal path names.

The only meaningful difference in the descriptions is that "X" says that the "content of a directory is not excluded from clean-up, only directory itself".
This suggests that "x" (as opposed to "X") does include the contents of the directory.  And I have done some limited testing in F19 to suggest that this is true.

A patch to the man page to clarify these behaviors and the differences between "x" and "X" would be really helpful.

Thanks,
Andy

Comment 6 Václav Pavlín 2013-10-08 08:31:21 UTC
Andrew, patch that should clarify the differences was committed upstream -> http://cgit.freedesktop.org/systemd/systemd/commit/?id=e776c8cfcdd65d243ba3f156ded905c589cab24f

Comment 7 Andrew J. Schorr 2013-10-08 12:49:26 UTC
Hi Václav, thanks for that clarification.  I think it's a big improvement in the man page.

But how does this relate to Comment 2 above which says that one must use globbing to prevent the contents of a directory from being deleted?  Is comment #2 incorrect?  In other words, was this a valid bug to begin with?

Thanks,
Andy

Comment 13 Ludek Smid 2014-06-13 11:17:53 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.