summaryrefslogtreecommitdiff
path: root/example/getpassck
diff options
context:
space:
mode:
Diffstat (limited to 'example/getpassck')
-rw-r--r--example/getpassck37
1 files changed, 37 insertions, 0 deletions
diff --git a/example/getpassck b/example/getpassck
new file mode 100644
index 0000000..9730e39
--- /dev/null
+++ b/example/getpassck
@@ -0,0 +1,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."