]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-start: don't re-try to mount rootfs if we already did so
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Tue, 14 Oct 2014 11:04:35 +0000 (11:04 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 27 Oct 2014 20:54:41 +0000 (16:54 -0400)
If we are root using a user namespace and are mounting a blockdev as rootfs,
then we do this before unsharing the userns, because we are not allowed to
do it in a userns.  But after unsharing the userns, we unconditionally
retried mounting the rootfs, resulting in failure.  stop that.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/conf.c
src/lxc/conf.h
src/lxc/start.c

index dc790a30453ca2b75385c2e9f21add0252f806a1..8273e6ee2eab26faa8e6aa716bae2a5dbf0f5eef 100644 (file)
@@ -3891,7 +3891,7 @@ void tmp_proc_unmount(struct lxc_conf *lxc_conf)
        }
 }
 
-static void remount_all_slave(void)
+void remount_all_slave(void)
 {
        /* walk /proc/mounts and change any shared entries to slave */
        FILE *f = fopen("/proc/self/mountinfo", "r");
@@ -4024,6 +4024,7 @@ static bool verify_start_hooks(struct lxc_conf *conf)
                                        hookname);
                        return false;
                }
+               return true;
        }
 
        return true;
index 97d9f9151a043afdbdf2a623269bd1b33742cded..2223b2d6ef37a8e626de3199cfe9aebe1bb648fd 100644 (file)
@@ -414,5 +414,6 @@ extern int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data);
 extern int parse_mntopts(const char *mntopts, unsigned long *mntflags,
                         char **mntdata);
 extern void tmp_proc_unmount(struct lxc_conf *lxc_conf);
+void remount_all_slave(void);
 extern void suggest_default_idmap(void);
 #endif
index 6fbe81cb5a2bd5af132e33ff32e786dfb2cadc23..b71af3787e7f90966bb5d042c6076a840c32f133 100644 (file)
@@ -1074,6 +1074,7 @@ int __lxc_start(const char *name, struct lxc_conf *conf,
                                ERROR("Error unsharing mounts");
                                goto out_fini_nonet;
                        }
+                       remount_all_slave();
                        if (do_rootfs_setup(conf, name, lxcpath) < 0) {
                                ERROR("Error setting up rootfs mount as root before spawn");
                                goto out_fini_nonet;