From: Evgeni Golov Date: Thu, 16 Aug 2012 21:45:14 +0000 (+0200) Subject: don't fail to ask for a password if there is no TTY X-Git-Tag: v0.55~2 X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=commitdiff_plain;h=a93156ca9d385302a8b2f8092c15a2ca47306910;hp=488643ab1a3e97a77bdb01f1070c8e83c6b346f9 don't fail to ask for a password if there is no TTY When running grml-debootrap over ssh like ssh root@grml grml-debootstrap ... the password promt for the root user would fail, as you cannot stty without a tty. The user should actually have called ssh -t root@grml grml-debootstrap ... which would have allocated a TTY and all would have worked. Display a warning to the user and fall back to displaying the entered password when he continues to use grml-debootstrap w/o a TTY. Closes: issue1200 --- diff --git a/chroot-script b/chroot-script index d3535b0..86f1535 100755 --- a/chroot-script +++ b/chroot-script @@ -55,9 +55,9 @@ stage() { askpass() { # read -s emulation for dash. result is in $resp. set -o noglob - stty -echo + [ -t 0 ] && stty -echo read resp - stty echo + [ -t 0 ] && stty echo set +o noglob } # }}} diff --git a/grml-debootstrap b/grml-debootstrap index 6b5fa17..cbd1938 100755 --- a/grml-debootstrap +++ b/grml-debootstrap @@ -730,6 +730,12 @@ else # if not running automatic installation display configuration and prompt fo [ -n "$VMSIZE" ] && echo " Using Virtual Disk file with size of ${VMSIZE}." fi + if [ ! -t 0 -a -z "$ROOTPASSWORD" -a -z "$NOPASSWORD" ] ; then + echo + echo " You do not have a TTY allocated, your password will be shown in" + echo " plaintext on the terminal! If you are using SSH, try its -t option!" + fi + echo echo " Important! Continuing will delete all data from ${TARGET}!"