]> git.proxmox.com Git - mirror_lxc.git/commitdiff
open the console later
authorDaniel Lezcano <daniel.lezcano@free.fr>
Mon, 22 Mar 2010 10:08:34 +0000 (11:08 +0100)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Mon, 22 Mar 2010 10:08:34 +0000 (11:08 +0100)
Open the console at the setup time, otherwise the openeded
file descriptor will be considered as an inherited fd and the
startup will fail.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/conf.c
src/lxc/conf.h
src/lxc/confile.c
src/lxc/console.c

index 26ddd03b36ab3789ada36d411e98ff5232382887..b843c089ba618540ed9d4ecc2b7e04eaa3fea8b3 100644 (file)
@@ -1093,6 +1093,7 @@ struct lxc_conf *lxc_conf_init(void)
        new->utsname = NULL;
        new->tty = 0;
        new->pts = 0;
+       new->console.path = NULL;
        new->console.peer = -1;
        new->console.master = -1;
        new->console.slave = -1;
index 822149a432041b88915d0dcb853ac392eb23ce84..3a560fda38e553fe21ebfada0c25cb5aeb49519b 100644 (file)
@@ -157,6 +157,7 @@ struct lxc_console {
        int slave;
        int master;
        int peer;
+       char *path;
        char name[MAXPATHLEN];
        struct termios *tios;
 };
index e24cc01ec06a77134b6943c1a6312ddc1d60362f..80da62540b4656105c5713c4c3939b12516b5988 100644 (file)
@@ -620,7 +620,7 @@ static int config_cap_drop(const char *key, char *value,
        return ret;
 }
 
-static int config_console(const char *key, char *value, struct lxc_conf *lxc_conf)
+static int _config_console(const char *key, char *value, struct lxc_conf *lxc_conf)
 {
        int fd;
 
@@ -635,6 +635,22 @@ static int config_console(const char *key, char *value, struct lxc_conf *lxc_con
        return 0;
 }
 
+static int config_console(const char *key, char *value,
+                         struct lxc_conf *lxc_conf)
+{
+       char *path;
+
+       path = strdup(value);
+       if (!path) {
+               SYSERROR("failed to strdup '%s': %m", value);
+               return -1;
+       }
+
+       lxc_conf->console.path = path;
+
+       return 0;
+}
+
 static int config_rootfs(const char *key, char *value, struct lxc_conf *lxc_conf)
 {
        if (strlen(value) >= MAXPATHLEN) {
index c2bc29bb42c7233fac77aca56e6b35840b23ac1a..16c5b590c296450b56826449d6fcdbe15303e8dc 100644 (file)
@@ -143,6 +143,7 @@ int lxc_create_console(struct lxc_conf *conf)
 {
        struct termios tios;
        struct lxc_console *console = &conf->console;
+       int fd;
 
        if (!conf->rootfs)
                return 0;
@@ -163,6 +164,14 @@ int lxc_create_console(struct lxc_conf *conf)
                goto err;
        }
 
+       fd = open(console->path, O_CLOEXEC | O_RDWR | O_CREAT | O_APPEND, 0600);
+       if (fd < 0) {
+               SYSERROR("failed to open '%s'", console->path);
+               goto err;
+       }
+
+       console->peer = fd;
+
        if (!isatty(console->peer))
                return 0;