Commit be97c20d by Serge Hallyn Committed by Stéphane Graber

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: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
parent 677a76dd
...@@ -4014,7 +4014,7 @@ void tmp_proc_unmount(struct lxc_conf *lxc_conf) ...@@ -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 */ /* walk /proc/mounts and change any shared entries to slave */
FILE *f = fopen("/proc/self/mountinfo", "r"); FILE *f = fopen("/proc/self/mountinfo", "r");
...@@ -4103,6 +4103,7 @@ static bool verify_start_hooks(struct lxc_conf *conf) ...@@ -4103,6 +4103,7 @@ static bool verify_start_hooks(struct lxc_conf *conf)
hookname); hookname);
return false; return false;
} }
return true;
} }
return true; return true;
......
...@@ -399,5 +399,6 @@ extern int userns_exec_1(struct lxc_conf *conf, int (*fn)(void *), void *data); ...@@ -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, extern int parse_mntopts(const char *mntopts, unsigned long *mntflags,
char **mntdata); char **mntdata);
extern void tmp_proc_unmount(struct lxc_conf *lxc_conf); extern void tmp_proc_unmount(struct lxc_conf *lxc_conf);
void remount_all_slave(void);
extern void suggest_default_idmap(void); extern void suggest_default_idmap(void);
#endif #endif
...@@ -1066,6 +1066,7 @@ int __lxc_start(const char *name, struct lxc_conf *conf, ...@@ -1066,6 +1066,7 @@ int __lxc_start(const char *name, struct lxc_conf *conf,
ERROR("Error unsharing mounts"); ERROR("Error unsharing mounts");
goto out_fini_nonet; goto out_fini_nonet;
} }
remount_all_slave();
if (do_rootfs_setup(conf, name, lxcpath) < 0) { if (do_rootfs_setup(conf, name, lxcpath) < 0) {
ERROR("Error setting up rootfs mount as root before spawn"); ERROR("Error setting up rootfs mount as root before spawn");
goto out_fini_nonet; goto out_fini_nonet;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment