File: authsystem.passwd.in

package info (click to toggle)
courier-authlib 0.58-4%2Betch3
  • links: PTS
  • area: main
  • in suites: etch
  • size: 16,212 kB
  • ctags: 1,896
  • sloc: ansic: 21,550; sh: 14,071; makefile: 866; perl: 842; cpp: 284
file content (71 lines) | stat: -rwxr-xr-x 1,828 bytes parent folder | download | duplicates (5)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! @EXPECT@ -f
#
# $Id: authsystem.passwd.in,v 1.2 2005/03/04 01:52:05 mrsam Exp $
#
# Copyright 2001-2005 Double Precision, Inc.  See COPYING for
# distribution information.
#
# This script attempts to change a system account password in an automated
# fashion.  This implemention is an "expect" script for the passwd command.
#
# This script reads two lines of text from stdin: old password, new password
# then runs the passwd command to change the password, and we attempt to parse
# the output of passwd.
#
# This implementation is for the basic "passwd" command.  If it doesn't work
# for you, sorry: you're on your own.  Some common pitfalls:
#
# * Enhanced passwd implementations that reject passwords based on dictionary
# words, etc..  This can result in unexpected output from the passwd command
# that this script may not be able to handle.  We attempt to catch the most
# common error messages, below.  Finally, we use a 30 second timeout.
#
# * I dunno - there must be other problems with this.
#

set timeout 30

expect {
	-re "(.*)\n(.*)\n" { set oldpass "$expect_out(1,string)" ; set newpass "$expect_out(2,string)" }
	eof { exit 1 }
	timeout { exit 1 }
}

set env(LC_ALL) "en_US"
spawn "@PASSWD@"

expect {
	-re "word:" { sleep 2; send "$oldpass\n" }
	eof { exit 1 }
	timeout { exit 1 }
}

expect {
	-re "nvalid" { exit 1 }
	-re "word:" { sleep 2; send "$newpass\n" }
	eof { exit 1 }
	timeout { exit 1 }
}

expect {
	-re "nvalid" { exit 1 }
	-re "NVALID" { exit 1 }
	-re "bad pass" { exit 1 }
	-re "BAD PASS" { exit 1 }
	-re "dictionary" { exit 1 }
	-re "common" { exit 1 }
	-re "short" { exit 1 }
	-re "word:" { sleep 2; send "$newpass\n" }
	eof { exit 1 }
	timeout { exit 1 }
}

expect {
	-re "nvalid" { exit 1 }
	-re "nchange" { exit 1 }
	-re "same" { exit 1 }
	eof { exit 0 }
	timeout { exit 1 }
}

exit 1