mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
lxc: Don't make container's TTY a controlling TTY
Userspace does not expect that the initial console is a controlling TTY. systemd can deal with that, others not. On sysv init distros getty will fail to spawn a controlling on /dev/console or /dev/tty1. Which will cause to whole container to reboot upon ctrl-c. This patch changes the behavior of libvirt to match the kernel behavior where the initial TTY is also not controlling. The only user visible change should be that a container with bash as PID 1 would complain. But this matches exactly the kernel be behavior with init=/bin/bash. To get a controlling TTY for bash just run "setsid /bin/bash". Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
parent
bd3e16a3cf
commit
ea542455b4
@ -279,18 +279,6 @@ static int lxcContainerSetupFDs(int *ttyfd,
|
||||
"as the FDs are about to be closed for exec of "
|
||||
"the container init process");
|
||||
|
||||
if (setsid() < 0) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("setsid failed"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (ioctl(*ttyfd, TIOCSCTTY, NULL) < 0) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("ioctl(TIOCSCTTY) failed"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (dup2(*ttyfd, STDIN_FILENO) < 0) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("dup2(stdin) failed"));
|
||||
@ -2231,7 +2219,7 @@ static int lxcContainerChild(void *data)
|
||||
|
||||
VIR_DEBUG("Container TTY path: %s", ttyPath);
|
||||
|
||||
ttyfd = open(ttyPath, O_RDWR|O_NOCTTY);
|
||||
ttyfd = open(ttyPath, O_RDWR);
|
||||
if (ttyfd < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("Failed to open tty %s"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user