Commit 1dd898cc by Stéphane Graber Committed by GitHub

Merge pull request #1553 from brauner/2017-05-12/allow_no_controlling_terminal

lxc-attach: allow for situations without /dev/tty
parents 66806d24 6f18b9c4
...@@ -441,7 +441,7 @@ static int lxc_console_peer_default(struct lxc_console *console) ...@@ -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)); console->peer = lxc_unpriv(open(path, O_CLOEXEC | O_RDWR | O_CREAT | O_APPEND, 0600));
if (console->peer < 0) { if (console->peer < 0) {
ERROR("failed to open \"%s\"", path); ERROR("failed to open \"%s\": %s", path, strerror(errno));
return -ENOTTY; return -ENOTTY;
} }
DEBUG("using \"%s\" as peer tty device", path); DEBUG("using \"%s\" as peer tty device", path);
......
...@@ -301,15 +301,12 @@ static int get_pty_on_host(struct lxc_container *c, struct wrapargs *wrap, int * ...@@ -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 /* 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 * 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) * lxc.console.path here and set it NULL. lxc_console_peer_default()
* prevent segfaults when the container has been setup with * will then try to open /dev/tty. If the process doesn't have a
* lxc.console = none and (b) provide an easy way to ensure that we * controlling terminal we should still proceed.
* always do the correct thing. strdup() must be used since console.path */
* is free()ed when we call lxc_container_put(). */
free(conf->console.path); free(conf->console.path);
conf->console.path = strdup("/dev/tty"); conf->console.path = NULL;
if (!conf->console.path)
return -1;
/* Create pty on the host. */ /* Create pty on the host. */
if (lxc_console_create(conf) < 0) if (lxc_console_create(conf) < 0)
......
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