Zbigniew Jędrzejewski-Szmek 62fe94
From 9ed2a35e93f4a9e82585f860f54cdcbbdf3e1f86 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 62fe94
From: Richard Weinberger <richard@nod.at>
Zbigniew Jędrzejewski-Szmek 62fe94
Date: Tue, 9 Sep 2014 11:09:37 +0200
Zbigniew Jędrzejewski-Szmek 62fe94
Subject: [PATCH] systemd-tmpfiles: Fix IGNORE_DIRECTORY_PATH age handling
Zbigniew Jędrzejewski-Szmek 62fe94
Zbigniew Jędrzejewski-Szmek 62fe94
If one has a config like:
Zbigniew Jędrzejewski-Szmek 62fe94
d /tmp 1777 root root -
Zbigniew Jędrzejewski-Szmek 62fe94
X /tmp/important_mount
Zbigniew Jędrzejewski-Szmek 62fe94
Zbigniew Jędrzejewski-Szmek 62fe94
All files below /tmp/important_mount will be deleted as the
Zbigniew Jędrzejewski-Szmek 62fe94
/tmp/important_mount item will spuriously inherit a max age of 0
Zbigniew Jędrzejewski-Szmek 62fe94
from /tmp.
Zbigniew Jędrzejewski-Szmek 62fe94
/tmp has a max age of 0 but age_set is (of course) false.
Zbigniew Jędrzejewski-Szmek 62fe94
Zbigniew Jędrzejewski-Szmek 62fe94
This affects also the PrivateTmp feature of systemd.
Zbigniew Jędrzejewski-Szmek 62fe94
All tmp files of such services will be deleted unconditionally
Zbigniew Jędrzejewski-Szmek 62fe94
and can cause service failures and data loss.
Zbigniew Jędrzejewski-Szmek 62fe94
Zbigniew Jędrzejewski-Szmek 62fe94
Fix this by checking ->age_set in the IGNORE_DIRECTORY_PATH logic.
Zbigniew Jędrzejewski-Szmek 62fe94
---
Zbigniew Jędrzejewski-Szmek 62fe94
 src/tmpfiles/tmpfiles.c | 2 +-
Zbigniew Jędrzejewski-Szmek 62fe94
 1 file changed, 1 insertion(+), 1 deletion(-)
Zbigniew Jędrzejewski-Szmek 62fe94
Zbigniew Jędrzejewski-Szmek 62fe94
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
Zbigniew Jędrzejewski-Szmek 62fe94
index f9830c431d..7eafd6bb30 100644
Zbigniew Jędrzejewski-Szmek 62fe94
--- a/src/tmpfiles/tmpfiles.c
Zbigniew Jędrzejewski-Szmek 62fe94
+++ b/src/tmpfiles/tmpfiles.c
Zbigniew Jędrzejewski-Szmek 62fe94
@@ -1576,7 +1576,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
Zbigniew Jędrzejewski-Szmek 62fe94
                                 candidate_item = j;
Zbigniew Jędrzejewski-Szmek 62fe94
                 }
Zbigniew Jędrzejewski-Szmek 62fe94
 
Zbigniew Jędrzejewski-Szmek 62fe94
-                if (candidate_item) {
Zbigniew Jędrzejewski-Szmek 62fe94
+                if (candidate_item && candidate_item->age_set) {
Zbigniew Jędrzejewski-Szmek 62fe94
                         i->age = candidate_item->age;
Zbigniew Jędrzejewski-Szmek 62fe94
                         i->age_set = true;
Zbigniew Jędrzejewski-Szmek 62fe94
                 }