]> git.proxmox.com Git - pve-container.git/commitdiff
CentOS 6: add '--nohangup' as mingetty arg
authorStoiko Ivanov <s.ivanov@proxmox.com>
Wed, 22 Apr 2020 09:24:27 +0000 (11:24 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Wed, 22 Apr 2020 11:29:20 +0000 (13:29 +0200)
When creating an unprivileged container with CentOS 6 (which will be EOL in
Nov 2020 [0]) the console does not work.

The problem is mitigated by adding the --nohangup argument to the mingetty
invocations during bootup (in /etc/init/tty.conf).

The idea for the fix is based on the legacy template builder-scripts from
lxc:
https://github.com/lxc/lxc-templates/blob/master/templates/lxc-centos.in#L308

Since '/etc/init/tty.conf' is only written during container creation/restore
and since it is guarded to CentOS versions < 7, the potential for regression
should be rather small.

Tested by creating an unprivileged and a privileged CentOS6 container and
with nesting enabled and disabled for both - the console showed up in
all cases with this fix.

[0] https://wiki.centos.org/About/Product
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
src/PVE/LXC/Setup/CentOS.pm
src/test/test-centos6-001/etc/init/tty.conf.exp

index d73c0cff8294a5b5c8aa7d0c213b5c020f18c19b..1e6894b2b6f3e730607c785eb7355b418ffcd192 100644 (file)
@@ -46,7 +46,7 @@ stop on runlevel [S016]
 
 respawn
 instance \$TTY
-exec /sbin/mingetty \$TTY
+exec /sbin/mingetty --nohangup \$TTY
 usage 'tty TTY=/dev/ttyX  - where X is console id'
 __EOD__
     
@@ -88,8 +88,13 @@ sub template_fixup {
        $self->ct_make_path('/etc/init');
 
        my $filename = "/etc/init/tty.conf";
-       $self->ct_file_set_contents($filename, $tty_conf)
-           if ! $self->ct_file_exists($filename);
+       if ($self->ct_file_exists($filename)) {
+           my $data = $self->ct_file_get_contents($filename);
+           $data =~ s|^(exec /sbin/mingetty)(?!.*--nohangup) (.*)$|$1 --nohangup $2|gm;
+           $self->ct_file_set_contents($filename, $data);
+       } else {
+           $self->ct_file_set_contents($filename, $tty_conf);
+       }
 
        $filename = "/etc/init/start-ttys.conf";
        $self->ct_file_set_contents($filename, $start_ttys_conf)
index 5dcd7ad3cc78087225a5f97cf1908fe72a92af7e..efad24064dd6116d4a1edcc57b31aad17ec29922 100644 (file)
@@ -9,5 +9,5 @@ stop on runlevel [S016]
 
 respawn
 instance $TTY
-exec /sbin/mingetty $TTY
+exec /sbin/mingetty --nohangup $TTY
 usage 'tty TTY=/dev/ttyX  - where X is console id'