Bug 1225739 - RFE: Add age to remove file types opf systemd-tmpfiles
Summary: RFE: Add age to remove file types opf systemd-tmpfiles
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd
Version: 7.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: systemd-maint
QA Contact: Frantisek Sumsal
URL:
Whiteboard:
Depends On:
Blocks: 1298243 1393867 74systemd
TreeView+ depends on / blocked
 
Reported: 2015-05-28 07:12 UTC by Fred van Zwieten
Modified: 2017-08-01 09:09 UTC (History)
9 users (show)

Fixed In Version: systemd-219-35.el7
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-01 09:09:52 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:2297 normal SHIPPED_LIVE systemd bug fix and enhancement update 2017-08-01 12:40:16 UTC
Red Hat Knowledge Base (Solution) 1466913 None None None Never

Description Fred van Zwieten 2015-05-28 07:12:35 UTC
Description of problem:
There is a need to clean content from a directory based on age, but only if the directory exists. Filetype D in a tmpfiles.d conf file doesn't work, because it will create the directory if it doesn't exist. R doesn't use the age parameter.

Version-Release number of selected component (if applicable):


How reproducible:
Use a tmpfiles conf of:
D /root/saplogs 755 root root 5d -

Steps to Reproduce:
1. Create a /etc/tmpfiles.d/tmpfiles conf of: "D /root/saplogs 755 root root 5d -"
2. run systemd-tmpfiles --clean
3. look at /root, there how is a subdir "saplogs"

Actual results:
a directory /root/saplogs exists

Expected results:
nothing happened

Additional info:
Propose to have the age parameter also work for r and R filetypes. This is imo backwards compatible and as such an enhancement.

Comment 2 Lukáš Nykrýn 2015-05-28 09:29:00 UTC
What is the real use-case for this? Usually you want the directory there.

Comment 3 Fred van Zwieten 2015-06-01 20:41:28 UTC
application admin installs sap components using sudo. sap leaves install logs in /root in a subdir saplog/. application admins cannot remove those because of permissions. sys admins want this directory cleaned out after x days. If the subdir saplog/ doesn't exist, nothing have to happen.

Comment 5 Lukáš Nykrýn 2015-06-04 15:18:11 UTC
(In reply to Fred van Zwieten from comment #3)
Uh this is so wrong. User who does not have access to /root directory runs an application which writes logs to /root? At least please tell you customer to file a bug against sap to move those to /var.

Tmpfilesd is about actions which happens repeatedly, what you want to do is just plan some action to the future. Also remove actions are only bound to boot (we only call /usr/bin/systemd-tmpfiles --clean in the timer).

I spend quite a lot of time thinking about a sane use-case, but I haven't found one. I really think that introducing such possibility would lead to really bad practices like the one above.

Comment 6 Ron van der Wees 2015-07-01 15:57:11 UTC
(In reply to Lukáš Nykrýn from comment #5)
Reopening this bug as I think there is a valid use case.

> (In reply to Fred van Zwieten from comment #3)
> Uh this is so wrong. User who does not have access to /root directory runs
> an application which writes logs to /root?
You are absolutely right but there are other uses cases.
With RHEL7, systemd-tmpfiles seems to have deprecated tmpwatch. The latter is
not installed by default and for example the X11 lock files are now cleaned by
/usr/lib/tmpfiles.d/x11.conf. Lets say, the customer just wants to use the new
technology as shipped with RHEL7 to clean a file in some directory under, lets
say, /var. Though if it doesn't exists (i.e. some application did not create
the directory yet), it should not be created as part of a housekeeping job.

> Tmpfilesd is about actions which happens repeatedly, what you want to do is
> just plan some action to the future. Also remove actions are only bound to
> boot (we only call /usr/bin/systemd-tmpfiles --clean in the timer).
Yes, and when the r/R type has an age defined, they should be actioned by
--clean as well (triggered by the timer).

Comment 7 Ron van der Wees 2015-08-17 07:04:50 UTC
Hi Lukas, Appreciate your feedback on comment#6 with regards to the use case.

Comment 9 Jan Synacek 2016-11-10 12:01:09 UTC
I believe that what Fred asks for was already implemented upstream:

https://github.com/systemd/systemd/commit/df8dee85da5fa41e95dd7f536e67fcc6940a6488

Comment 12 Jan Synacek 2017-04-11 13:48:17 UTC
https://github.com/lnykryn/systemd-rhel/pull/106

Comment 13 Lukáš Nykrýn 2017-04-11 15:55:20 UTC
fix merged to upstream staging branch ->
https://github.com/lnykryn/systemd-rhel/commit/f2d7881cf56b2d1448b9e09c46c076a14a05011d
-> post

Comment 16 errata-xmlrpc 2017-08-01 09:09:52 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, 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-2017:2297


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