Bug 1780979

Summary: [RFE] systemd-tmpfiles: allow systemd-tmpfiles to handle temporary read-only files owned by root
Product: Red Hat Enterprise Linux 7 Reporter: jcalhoun
Component: systemdAssignee: systemd-maint
Status: CLOSED WONTFIX QA Contact: Frantisek Sumsal <fsumsal>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.7CC: jsynacek, systemd-maint-list
Target Milestone: rcKeywords: FutureFeature
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-12-16 10:40:59 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:
Embargoed:

Description jcalhoun 2019-12-09 00:17:27 UTC
Description of problem:

Possible regression from BZ # 1533638. The previous BZ notes that the method of implementing this change would be through an environment variable configuration, but then the BZ was closed with an errata release of RHBA-2018:3245 - systemd-219-62 (Original BZ also shows fixed in systemd-219-58.el7)

The github commit appears to have removed that logic from tmpfiles.c altogether, I'm not seeing any record of the environment variable configuration changes mentioned in the original BZ.

https://github.com/lnykryn/systemd-rhel/pull/201/commits/5349b65d33560518d464490aa5a1a63e90295dc6

Customer is running systemd-219-67.el7_7.2 and is encountering "Ignoring: file read-only and owner by root." on files owned by root without the write bit.

This RFE pertains to SFDC # 02524658. Customer noticed certain tmp files were not being cleaned by systemd-tmpfiles:

$ stat old-test-file-owned-by-root 
  File: ‘old-test-file-owned-by-root’
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: fd00h/64768d    Inode: 1192819     Links: 1
Access: (0111/---x--x--x)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2019-10-22 18:39:24.676375622 +0100
Modify: 2019-10-22 18:39:24.676375622 +0100
Change: 2019-10-22 18:39:41.020368654 +0100
 Birth: -

It was noticed by GSS that this file did not have the write bit set and this logic exists in tmpfiles.c:

 /* Do not delete read-only files owned by root */
                if (s.st_uid == 0 && !(s.st_mode & S_IWUSR)) {
                        log_debug("Ignoring \"%s/%s\": read-only and owner by root.", p, dent->d_name);
                        continue;
                }

As such, customer was informed this was intended behavior. Customer requests an RFE to have this logic removed from future releases.

Customer reports this change has already been implemented upstream:

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

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

systemd-219-67.el7_7.2.x86_64

I believe this logic exists in all available versions of tmpfiles.c

How reproducible:

Always

Steps to Reproduce:
1. Remove the write bit from a temporary file owned by root that systemd-tmpfilesd is watching
2. Run systemd-tmpfiles --clean
3. "Ignoring: file read-only and owner by root." message reported

Actual results:

Systemd-tmpfilesd ignores and does not delete the temporary file.

Expected results:

Systemd-tmpfilesd deletes the file regardless of ownership or permissions.

Additional info:

Comment 3 Jan Synacek 2019-12-16 10:40:59 UTC
Red Hat Enterprise Linux version 7 entered the Maintenance Support 1 Phase in August 2019. In this phase only qualified Critical and Important Security errata advisories (RHSAs) and Urgent Priority Bug Fix errata advisories (RHBAs) may be released as they become available.