anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0614-tmpfiles-don-t-skip-cleanup-of-read-only-root-owned-.patch

aed857
From 38c68c3b13e278a77a4bd02d97f6b3f81db46288 Mon Sep 17 00:00:00 2001
aed857
From: Michal Sekletar <msekleta@redhat.com>
aed857
Date: Tue, 27 Mar 2018 10:34:06 +0200
aed857
Subject: [PATCH] tmpfiles: don't skip cleanup of read-only root owned files if
aed857
 TMPFILES_AGE_ALL is set
aed857
aed857
Resolves: #1533638
aed857
---
aed857
 src/tmpfiles/tmpfiles.c | 12 ++++++++----
aed857
 1 file changed, 8 insertions(+), 4 deletions(-)
aed857
aed857
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
aed857
index ddb274fce..5212d72f5 100644
aed857
--- a/src/tmpfiles/tmpfiles.c
aed857
+++ b/src/tmpfiles/tmpfiles.c
aed857
@@ -367,6 +367,7 @@ static int dir_cleanup(
aed857
                 struct stat s;
aed857
                 usec_t age;
aed857
                 _cleanup_free_ char *sub_path = NULL;
aed857
+                const char *e;
aed857
 
aed857
                 if (STR_IN_SET(dent->d_name, ".", ".."))
aed857
                         continue;
aed857
@@ -399,10 +400,13 @@ static int dir_cleanup(
aed857
                         continue;
aed857
                 }
aed857
 
aed857
-                /* Do not delete read-only files owned by root */
aed857
-                if (s.st_uid == 0 && !(s.st_mode & S_IWUSR)) {
aed857
-                        log_debug("Ignoring \"%s/%s\": read-only and owner by root.", p, dent->d_name);
aed857
-                        continue;
aed857
+                e = getenv("TMPFILES_AGE_ALL");
aed857
+                if (!e) {
aed857
+                        /* Do not delete read-only files owned by root */
aed857
+                        if (s.st_uid == 0 && !(s.st_mode & S_IWUSR)) {
aed857
+                                log_debug("Ignoring \"%s/%s\": read-only and owner by root.", p, dent->d_name);
aed857
+                                continue;
aed857
+                        }
aed857
                 }
aed857
 
aed857
                 sub_path = strjoin(p, "/", dent->d_name, NULL);