naccyde / rpms / systemd

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