]> git.ipfire.org Git - pakfire.git/commitdiff
execute: Disable mount propagation before calling pivot_root()
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jul 2022 12:13:54 +0000 (12:13 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 17 Jul 2022 12:13:54 +0000 (12:13 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/execute.c
src/libpakfire/include/pakfire/mount.h
src/libpakfire/mount.c

index 310ab737267d22d89aaebdfb450ff665e6b817a7..f4cde9465494849ffe7f823732b428dc72d2fe04 100644 (file)
@@ -561,6 +561,11 @@ static int pakfire_execute_fork(void* data) {
 
        // Change root (unless root is /)
        if (strcmp(root, "/") != 0) {
+               // Disable mount propagation on /
+               r = pakfire_disable_mount_propagation(pakfire, "/");
+               if (r)
+                       return r;
+
                // Mount everything
                r = pakfire_mount_all(pakfire, MOUNT_IN_NEW_NS);
                if (r)
index fba1ae735e1c17e7ac2a2a839a1d90f7dce7ec72..6f1b9a0568e0c204910a45687ecbce5667700b92 100644 (file)
@@ -30,6 +30,8 @@ enum pakfire_mount_flags {
        MOUNT_IN_NEW_NS = (1 << 0),
 };
 
+int pakfire_disable_mount_propagation(struct pakfire* pakfire, const char* path);
+
 int pakfire_mount_list(struct pakfire* pakfire);
 
 int pakfire_mount(struct pakfire* pakfire, const char* source, const char* target,
index 03995c80e4b1fab05f7bba6ff18766a31a6dec37..67313d4466a3dd277310caf939f20715344730e7 100644 (file)
@@ -77,6 +77,16 @@ static const struct pakfire_mountpoint {
        { NULL },
 };
 
+int pakfire_disable_mount_propagation(struct pakfire* pakfire, const char* path) {
+       DEBUG(pakfire, "Disabling mount propagation on %s\n", path);
+
+       int r = mount(NULL, path, NULL, MS_REC|MS_PRIVATE, NULL);
+       if (r)
+               ERROR(pakfire, "Failed to set mount propagation on %s to private: %m", path);
+
+       return r;
+}
+
 /*
        Easy way to iterate through all mountpoints
 */