chiark / gitweb /
systemd-tmpfiles: Fix IGNORE_DIRECTORY_PATH age handling
authorRichard Weinberger <richard@nod.at>
Tue, 9 Sep 2014 09:09:37 +0000 (11:09 +0200)
committerTom Gundersen <teg@jklm.no>
Fri, 26 Sep 2014 15:38:40 +0000 (17:38 +0200)
If one has a config like:
d /tmp 1777 root root -
X /tmp/important_mount

All files below /tmp/important_mount will be deleted as the
/tmp/important_mount item will spuriously inherit a max age of 0
from /tmp.
/tmp has a max age of 0 but age_set is (of course) false.

This affects also the PrivateTmp feature of systemd.
All tmp files of such services will be deleted unconditionally
and can cause service failures and data loss.

Fix this by checking ->age_set in the IGNORE_DIRECTORY_PATH logic.

src/tmpfiles/tmpfiles.c

index f9830c431d2b905aa46fae305640930a5a93fd55..7eafd6bb30791eb3d1922d58f73a4fc9ccf06d2c 100644 (file)
@@ -1576,7 +1576,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
                                 candidate_item = j;
                 }
 
-                if (candidate_item) {
+                if (candidate_item && candidate_item->age_set) {
                         i->age = candidate_item->age;
                         i->age_set = true;
                 }