Commit 37903589 by Serge Hallyn

don't set up console for lxc-execute

Currently due to some safety checks for !rootfs.path, lxc-execute works ok if you do not set lxc.rootfs at all in your lxc.conf. But if you set lxc.rootfs = '/', then it sets up console, and when you do an lxc-execute, the console appears hung. However the lxc.rootfs NULL check was just incidental to not dereference a NULL pointer. In fact we should not be setting up a console if the container isn't running a full-fledged distro with a getty/login running on the container's /dev/console. Have lxc_execute() mark in lxc_conf that this is a lxc-execute and not an lxc-start, and don't set up the console. The issue is documented at https://sourceforge.net/p/lxc/bugs/67/ . Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com> Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarDwight Engen <dwight.engen@oracle.com>
parent b5159817
...@@ -2836,7 +2836,7 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf) ...@@ -2836,7 +2836,7 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf)
} }
} }
if (setup_console(&lxc_conf->rootfs, &lxc_conf->console, lxc_conf->ttydir)) { if (!lxc_conf->is_execute && setup_console(&lxc_conf->rootfs, &lxc_conf->console, lxc_conf->ttydir)) {
ERROR("failed to setup the console for '%s'", name); ERROR("failed to setup the console for '%s'", name);
return -1; return -1;
} }
...@@ -2846,7 +2846,7 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf) ...@@ -2846,7 +2846,7 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf)
ERROR("failed to setup kmsg for '%s'", name); ERROR("failed to setup kmsg for '%s'", name);
} }
if (setup_tty(&lxc_conf->rootfs, &lxc_conf->tty_info, lxc_conf->ttydir)) { if (!lxc_conf->is_execute && setup_tty(&lxc_conf->rootfs, &lxc_conf->tty_info, lxc_conf->ttydir)) {
ERROR("failed to setup the ttys for '%s'", name); ERROR("failed to setup the ttys for '%s'", name);
return -1; return -1;
} }
......
...@@ -251,6 +251,7 @@ struct saved_nic { ...@@ -251,6 +251,7 @@ struct saved_nic {
}; };
struct lxc_conf { struct lxc_conf {
int is_execute;
char *fstab; char *fstab;
int tty; int tty;
int pts; int pts;
......
...@@ -272,6 +272,11 @@ int lxc_console_mainloop_add(struct lxc_epoll_descr *descr, ...@@ -272,6 +272,11 @@ int lxc_console_mainloop_add(struct lxc_epoll_descr *descr,
struct lxc_conf *conf = handler->conf; struct lxc_conf *conf = handler->conf;
struct lxc_console *console = &conf->console; struct lxc_console *console = &conf->console;
if (conf->is_execute) {
INFO("no console for lxc-execute.");
return 0;
}
if (!conf->rootfs.path) { if (!conf->rootfs.path) {
INFO("no rootfs, no console."); INFO("no rootfs, no console.");
return 0; return 0;
...@@ -559,6 +564,11 @@ int lxc_console_create(struct lxc_conf *conf) ...@@ -559,6 +564,11 @@ int lxc_console_create(struct lxc_conf *conf)
{ {
struct lxc_console *console = &conf->console; struct lxc_console *console = &conf->console;
if (conf->is_execute) {
INFO("no console for lxc-execute.");
return 0;
}
if (!conf->rootfs.path) if (!conf->rootfs.path)
return 0; return 0;
......
...@@ -165,5 +165,6 @@ int lxc_execute(const char *name, char *const argv[], int quiet, ...@@ -165,5 +165,6 @@ int lxc_execute(const char *name, char *const argv[], int quiet,
if (lxc_check_inherited(conf, -1)) if (lxc_check_inherited(conf, -1))
return -1; return -1;
conf->is_execute = 1;
return __lxc_start(name, conf, &execute_start_ops, &args, lxcpath); return __lxc_start(name, conf, &execute_start_ops, &args, lxcpath);
} }
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