From 49ffa978d3befde22a010f52200498b786498609 Mon Sep 17 00:00:00 2001 From: Avi Deitcher Date: Wed, 15 Nov 2017 19:21:59 +0200 Subject: [PATCH] Keep track of processed ttys and only start same one once Signed-off-by: Avi Deitcher --- pkg/getty/usr/bin/rungetty.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/getty/usr/bin/rungetty.sh b/pkg/getty/usr/bin/rungetty.sh index a75137ddb..9a3ba9599 100755 --- a/pkg/getty/usr/bin/rungetty.sh +++ b/pkg/getty/usr/bin/rungetty.sh @@ -15,6 +15,14 @@ start_getty() { term="linux" [ "$speed" = "$1" ] && speed=115200 + # did we already process this tty? + if $(echo "${PROCESSEDTTY}" | grep -q -w "$tty"); then + echo "getty: already processed tty for $tty, not starting twice" | tee /dev/console + return + fi + # now indicate that we are processing it + PROCESSEDTTY="${PROCESSEDTTY} ${tty}" + # does the device even exist? if [ ! -c /dev/$tty ]; then echo "getty: cmdline has console=$tty but /dev/$tty is not a character device; not starting getty for $tty" | tee /dev/console @@ -44,6 +52,7 @@ start_getty() { echo "getty: cmdline has console=$tty but does not exist in $securetty; will not be able to log in as root on this tty $tty." | tee /dev/$tty fi # respawn forever + echo "getty: starting getty for $tty" | tee /dev/$tty infinite_loop setsid.getty -w /sbin/agetty $loginargs $line $speed $tty $term & } @@ -55,6 +64,8 @@ export PS1="(ns: getty) $PS1" EOF fi +PROCESSEDTTY= + # check if we have /etc/getty.shadow ROOTSHADOW=/hostroot/etc/getty.shadow if [ -f $ROOTSHADOW ]; then