valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

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

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