]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: Exclude APIVFS mountpoint directories 26500/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 20 Feb 2023 15:39:34 +0000 (16:39 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 22 Feb 2023 11:44:39 +0000 (12:44 +0100)
Also exclude APIVFS and temporary files directories from the copy
operation so that these files don't accidentally end up in images.

src/partition/repart.c
test/units/testsuite-58.sh

index 786f7d8da56fe82b67a3e2ea8d8d41d2a67a1475..4e0c5dd785cfaf2dce135fac52930141685fa80c 100644 (file)
@@ -4065,6 +4065,12 @@ static int make_copy_files_denylist(Context *context, const Partition *p, Hashma
                 }
         }
 
+        FOREACH_STRING(s, "proc", "sys", "dev", "tmp", "run", "var/tmp") {
+                r = add_exclude_path(s, &denylist, DENY_CONTENTS);
+                if (r < 0)
+                        return r;
+        }
+
         STRV_FOREACH(e, p->exclude_files) {
                 r = add_exclude_path(*e, &denylist, endswith(*e, "/") ? DENY_CONTENTS : DENY_INODE);
                 if (r < 0)
index 99f6223d402a7e7e1790a13aa645b48cef90a8ef..c58465356c2476a79aae929fe1e3cdc9cfa6be3b 100755 (executable)
@@ -852,6 +852,8 @@ test_exclude_files() {
     runas testuser mkdir "$root/usr"
     runas testuser touch "$root/usr/def"
     runas testuser touch "$root/usr/qed"
+    runas testuser mkdir "$root/tmp"
+    runas testuser touch "$root/tmp/prs"
 
     runas testuser tee "$defs/00-root.conf" <<EOF
 [Partition]
@@ -890,6 +892,10 @@ EOF
     assert_rc 0 ls "$imgs/mnt/usr"
     assert_rc 2 ls "$imgs/mnt/usr/def"
 
+    # Test that /tmp/prs did not end up in the root partition but /tmp did.
+    assert_rc 0 ls "$imgs/mnt/tmp"
+    assert_rc 2 ls "$imgs/mnt/tmp/prs"
+
     # Test that /usr/qed did not end up in the usr partition but /usr/def did.
     mount -t ext4 "${loop}p2" "$imgs/mnt/usr"
     assert_rc 0 ls "$imgs/mnt/usr/def"