From: Serge Hallyn Date: Tue, 14 Oct 2014 11:04:35 +0000 (+0000) Subject: lxc-start: don't re-try to mount rootfs if we already did so X-Git-Tag: lxc-1.0.7~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be97c20dbedf7e966a770e05983d749f55e918e2;p=thirdparty%2Flxc.git lxc-start: don't re-try to mount rootfs if we already did so 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 Acked-by: Stéphane Graber --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index f2215a8af..bd94b3d51 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -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; diff --git a/src/lxc/conf.h b/src/lxc/conf.h index 7434748d0..7fc6a8db6 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -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 diff --git a/src/lxc/start.c b/src/lxc/start.c index 90572f0fa..77aa024f0 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -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;