From: Christian Brauner Date: Thu, 15 Jul 2021 16:37:22 +0000 (+0200) Subject: terminal: log TIOCGPTPEER failure less alarmingly X-Git-Tag: lxc-5.0.0~137^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f382bcc6d820c46a54ec928ea7cbfaa3847adc66;p=thirdparty%2Flxc.git terminal: log TIOCGPTPEER failure less alarmingly This is not a fatal error and the fallback codepath is equally safe. When we use TIOCGPTPEER we're using a stashed fd to the container's devpts mount's ptmx device and allocating a new fd non-path based through this ioctl. If this ioctl can't be used we're falling back to allocating a pts device from the host's devpts mount's ptmx device which is path-based but is not under control of the container and so that's safe. The difference is just that the first method gets you a nice native terminal with all the pleasantries of having tty and friends working whereas the latter method does not. Fixes: #3625 Signed-off-by: Christian Brauner --- diff --git a/src/lxc/terminal.c b/src/lxc/terminal.c index 029e36bbb..6e1a2c288 100644 --- a/src/lxc/terminal.c +++ b/src/lxc/terminal.c @@ -931,7 +931,17 @@ static int lxc_terminal_create_native(const char *name, const char *lxcpath, str terminal->pty = ioctl(terminal->ptx, TIOCGPTPEER, O_RDWR | O_NOCTTY | O_CLOEXEC); if (terminal->pty < 0) { - SYSWARN("Failed to allocate new pty device"); + switch (errno) { + case ENOTTY: + SYSTRACE("Pure fd-based terminal allocation not possible"); + break; + case ENOSPC: + SYSTRACE("Exceeding number of allocatable terminals"); + break; + default: + SYSWARN("Failed to allocate new pty device"); + break; + } goto err; }