]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
don't set up console for lxc-execute
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 13 Jun 2013 15:06:15 +0000 (10:06 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 13 Jun 2013 17:03:36 +0000 (12:03 -0500)
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: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
src/lxc/conf.c
src/lxc/conf.h
src/lxc/console.c
src/lxc/execute.c

index 90aea609c6f30e938ad44ce2824c7f4f1b5176ac..6a43aee739cf9c3234bff3a8c661688c582b70cc 100644 (file)
@@ -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);
                return -1;
        }
@@ -2846,7 +2846,7 @@ int lxc_setup(const char *name, struct lxc_conf *lxc_conf)
                        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);
                return -1;
        }
index 2fd3ab1ca8e6d27f60391972c740a4a4a8837d7b..9b1677e5de928e13dc302cdf235143463c05e448 100644 (file)
@@ -251,6 +251,7 @@ struct saved_nic {
 };
 
 struct lxc_conf {
+       int is_execute;
        char *fstab;
        int tty;
        int pts;
index 3720c5b06fba0acc974e5c8a2e697b70d128c5f7..f7a59d8b30ee37af5f97e76d1e47ee5c841c92df 100644 (file)
@@ -272,6 +272,11 @@ int lxc_console_mainloop_add(struct lxc_epoll_descr *descr,
        struct lxc_conf *conf = handler->conf;
        struct lxc_console *console = &conf->console;
 
+       if (conf->is_execute) {
+               INFO("no console for lxc-execute.");
+               return 0;
+       }
+
        if (!conf->rootfs.path) {
                INFO("no rootfs, no console.");
                return 0;
@@ -559,6 +564,11 @@ int lxc_console_create(struct lxc_conf *conf)
 {
        struct lxc_console *console = &conf->console;
 
+       if (conf->is_execute) {
+               INFO("no console for lxc-execute.");
+               return 0;
+       }
+
        if (!conf->rootfs.path)
                return 0;
 
index ec5cd29d9fd36e3e916a9dbb14affe599a7242cc..5f416793bcf34c02dbeeb6a7b10dea7212f484af 100644 (file)
@@ -165,5 +165,6 @@ int lxc_execute(const char *name, char *const argv[], int quiet,
        if (lxc_check_inherited(conf, -1))
                return -1;
 
+       conf->is_execute = 1;
        return __lxc_start(name, conf, &execute_start_ops, &args, lxcpath);
 }