4 # Copyright 2001-2005 Double Precision, Inc. See COPYING for
5 # distribution information.
7 # This script attempts to change a system account password in an automated
8 # fashion. This implemention is an "expect" script for the passwd command.
10 # This script reads two lines of text from stdin: old password, new password
11 # then runs the passwd command to change the password, and we attempt to parse
12 # the output of passwd.
14 # This implementation is for the basic "passwd" command. If it doesn't work
15 # for you, sorry: you're on your own. Some common pitfalls:
17 # * Enhanced passwd implementations that reject passwords based on dictionary
18 # words, etc.. This can result in unexpected output from the passwd command
19 # that this script may not be able to handle. We attempt to catch the most
20 # common error messages, below. Finally, we use a 30 second timeout.
22 # * I dunno - there must be other problems with this.
28 -re "(.*)\n(.*)\n" { set oldpass "$expect_out(1,string)" ; set newpass "$expect_out(2,string)" }
33 set env(LC_ALL) "en_US"
37 -re "word:" { sleep 2; send "$oldpass\n" }
43 -re "nvalid" { exit 1 }
44 -re "word:" { sleep 2; send "$newpass\n" }
50 -re "nvalid" { exit 1 }
51 -re "NVALID" { exit 1 }
52 -re "bad pass" { exit 1 }
53 -re "BAD PASS" { exit 1 }
54 -re "dictionary" { exit 1 }
55 -re "common" { exit 1 }
56 -re "short" { exit 1 }
57 -re "word:" { sleep 2; send "$newpass\n" }
63 -re "nvalid" { exit 1 }
64 -re "nchange" { exit 1 }