]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-attach: allow for situations without /dev/tty 1553/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 12 May 2017 14:33:23 +0000 (16:33 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 12 May 2017 14:58:09 +0000 (16:58 +0200)
Closes #1552.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/console.c
src/lxc/tools/lxc_attach.c

index 3baaed49844199df3b8bb62489b62ce3afe07b2b..8eae7c4a9a04e217a493e9d5f645621e153129d9 100644 (file)
@@ -441,7 +441,7 @@ static int lxc_console_peer_default(struct lxc_console *console)
 
        console->peer = lxc_unpriv(open(path, O_CLOEXEC | O_RDWR | O_CREAT | O_APPEND, 0600));
        if (console->peer < 0) {
-               ERROR("failed to open \"%s\"", path);
+               ERROR("failed to open \"%s\": %s", path, strerror(errno));
                return -ENOTTY;
        }
        DEBUG("using \"%s\" as peer tty device", path);
index c5e319fdfa14afca776c6760809fdc91004834dd..d35ec88c10525aa1f43e1c6ecf3f8ea9d2d688d8 100644 (file)
@@ -301,15 +301,12 @@ static int get_pty_on_host(struct lxc_container *c, struct wrapargs *wrap, int *
 
        /* In the case of lxc-attach our peer pty will always be the current
         * controlling terminal. We clear whatever was set by the user for
-        * lxc.console.path here and set it to "/dev/tty". Doing this will (a)
-        * prevent segfaults when the container has been setup with
-        * lxc.console = none and (b) provide an easy way to ensure that we
-        * always do the correct thing. strdup() must be used since console.path
-        * is free()ed when we call lxc_container_put(). */
+        * lxc.console.path here and set it NULL. lxc_console_peer_default()
+        * will then try to open /dev/tty. If the process doesn't have a
+        * controlling terminal we should still proceed.
+        */
        free(conf->console.path);
-       conf->console.path = strdup("/dev/tty");
-       if (!conf->console.path)
-               return -1;
+       conf->console.path = NULL;
 
        /* Create pty on the host. */
        if (lxc_console_create(conf) < 0)