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.1.0.alpha3~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a0c909a375a75e005b2048b2d143320678e11b9;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 dc790a304..8273e6ee2 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -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; diff --git a/src/lxc/conf.h b/src/lxc/conf.h index 97d9f9151..2223b2d6e 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -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 diff --git a/src/lxc/start.c b/src/lxc/start.c index 6fbe81cb5..b71af3787 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -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;