]> git.proxmox.com Git - mirror_lxc.git/commitdiff
conf: ensure mount tunnel is a dependent mount
authorChristian Brauner <brauner@kernel.org>
Tue, 29 Nov 2022 20:36:43 +0000 (21:36 +0100)
committerChristian Brauner (Microsoft) <christian.brauner@ubuntu.com>
Tue, 29 Nov 2022 20:36:43 +0000 (21:36 +0100)
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
src/lxc/conf.c

index 63b697f9fe4c62d557df40046257d2b7400be535..960aa4648df620332bb1ba37f4acaf9a120478e0 100644 (file)
@@ -4345,6 +4345,14 @@ static int setup_capabilities(struct lxc_conf *conf)
        return 0;
 }
 
+static int make_shmount_dependent_mount(const struct lxc_conf *conf)
+{
+       if (!(conf->auto_mounts & LXC_AUTO_SHMOUNTS_MASK))
+               return 0;
+
+       return mount(NULL, conf->shmount.path_cont, NULL, MS_REC | MS_SLAVE, 0);
+}
+
 int lxc_setup(struct lxc_handler *handler)
 {
        int ret;
@@ -4474,6 +4482,11 @@ int lxc_setup(struct lxc_handler *handler)
        if (ret < 0)
                return log_error(-1, "Failed to pivot root into rootfs");
 
+       ret = make_shmount_dependent_mount(lxc_conf);
+       if (ret < 0)
+               return log_error(-1, "Failed to turn mount tunnel \"%s\" into dependent mount",
+                                lxc_conf->shmount.path_cont);
+
        /* Setting the boot-id is best-effort for now. */
        if (lxc_conf->autodev > 0)
                (void)lxc_setup_boot_id();