]> 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>
Tue, 25 Nov 2014 22:10:51 +0000 (17:10 -0500)
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 f2215a8afb6834bd28e10dcbbbe68570edccb32b..bd94b3d51d6d1a2fd5d44f12d35a2c54ec997b64 100644 (file)
@@ -4014,7 +4014,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");
@@ -4103,6 +4103,7 @@ static bool verify_start_hooks(struct lxc_conf *conf)
                                        hookname);
                        return false;
                }
+               return true;
        }
 
        return true;
index 7434748d0250fafe50886afd92dd06908aca94be..7fc6a8db65dbc2247af99a0c56e5d751a55c5dad 100644 (file)
@@ -399,5 +399,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 90572f0fa1bde368297849631868db5c5acaa219..77aa024f06ce26a9ebc0c440ccda7e9fd0437fc2 100644 (file)
@@ -1066,6 +1066,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;