1#!/bin/sh 2# \ 3exec expect "$0" ${1+"$@"} 4# 5# Name: getpassck 6# 7# Description: 8# This script demonstrates when programs using getpass sometimes 9# fail. The reason is that some implementations of getpass prompt 10# before the pty/tty has completed the switch to no-echo. This may 11# not be obvious from examination of the implementation of getpass 12# itself because the driver itself may cut corners and be 13# responsible for allowing the call to return prematurely. 14# 15# Directions: 16# Simply run this script. It will loop 100 times attempting to 17# generate the getpass problem. If the bug cannot be reproduced, 18# you will see 100 failed attempts to su. If the bug can be 19# reproduced, the script exits as soon as it is detected. 20# 21# Author: Don Libes <don@libes.com> 22# Version: 1.0, Wed Mar 9 12:36:12 EST 2005 23# 24 25for {set i 0} {$i < 100} {incr i} { 26 spawn -noecho su 27 expect ": " ;# get password prompt as quickly as possible 28 send "X\r" ;# send password 29 expect X { 30 puts "Password was echoed! This system has the getpass problem." 31 exit 32 } "orry" { 33 close 34 wait 35 } 36} 37puts "Failed to reproduce getpass problem." 38