File: getpassck

package info (click to toggle)
expect 5.45.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,016 kB
  • sloc: ansic: 17,965; sh: 7,445; tcl: 384; makefile: 191; exp: 10
file content (37 lines) | stat: -rw-r--r-- 1,156 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
# \
exec expect "$0" ${1+"$@"}
#
# Name: getpassck
#
# Description:
#    This script demonstrates when programs using getpass sometimes
#    fail.  The reason is that some implementations of getpass prompt
#    before the pty/tty has completed the switch to no-echo.  This may
#    not be obvious from examination of the implementation of getpass
#    itself because the driver itself may cut corners and be
#    responsible for allowing the call to return prematurely.
#
# Directions:
#   Simply run this script.  It will loop 100 times attempting to
#   generate the getpass problem.  If the bug cannot be reproduced,
#   you will see 100 failed attempts to su.  If the bug can be
#   reproduced, the script exits as soon as it is detected.
#
# Author: Don Libes <don@libes.com>
# Version: 1.0, Wed Mar  9 12:36:12 EST 2005
# 

for {set i 0} {$i < 100} {incr i} {
 spawn -noecho su
 expect ": "      ;# get password prompt as quickly as possible
 send "X\r"       ;# send password
 expect X {
  puts "Password was echoed!  This system has the getpass problem."
  exit
 } "orry" {
  close
  wait
 }
}
puts "Failed to reproduce getpass problem."