Merge pull request #2742 from deitch/getty-dedup

Keep track of processed ttys and only start same one once
This commit is contained in:
Avi Deitcher 2019-09-10 09:15:35 -04:00 committed by GitHub
commit c050fb7276
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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