From cc174b4df09b16114ddbcf12c23a033e1e11fbb8 Mon Sep 17 00:00:00 2001 From: Avi Deitcher Date: Sun, 6 Aug 2017 10:00:15 +0300 Subject: [PATCH] test device exists before allowing getty to run Signed-off-by: Avi Deitcher --- pkg/getty/usr/bin/rungetty.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/getty/usr/bin/rungetty.sh b/pkg/getty/usr/bin/rungetty.sh index 1a474fb86..a75137ddb 100755 --- a/pkg/getty/usr/bin/rungetty.sh +++ b/pkg/getty/usr/bin/rungetty.sh @@ -15,6 +15,12 @@ start_getty() { term="linux" [ "$speed" = "$1" ] && speed=115200 + # 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 + return + fi + case "$tty" in ttyS*|ttyAMA*|ttyUSB*|ttyMFD*) line="-L" @@ -35,7 +41,7 @@ start_getty() { if ! grep -q -w "$tty" "$securetty"; then # we could not find the tty in securetty, so start a getty but warn that root login will not work - 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." > /dev/$tty + 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 infinite_loop setsid.getty -w /sbin/agetty $loginargs $line $speed $tty $term &