blob: 0dbb27d0f3031d83dcfd4285500300b5832677c5 (
plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
|
#!/usr/bin/expect
set timeout 5
proc expect_error {} {
expect {
"chage: error changing fields" {
expect {
eof {
} default {
puts "\nFAIL"
exit 1
}
}
} default {
puts "\nFAIL"
exit 1
}
}
}
# I've not been able to put the opening bracket in the regular expressions
# If anyone knows...
spawn /usr/bin/chage myuser
expect -re "Minimum Password Age .0\]: "
send -- "-2\r"
expect_error
spawn /usr/bin/chage myuser
expect -re "Minimum Password Age .0\]: "
send "foo\r"
expect_error
# chage accepts to be given only spaces
#spawn /usr/bin/chage myuser
#expect -re "Minimum Password Age .0\]: "
#send -- " \r"
#expect_error
#
#chage may not parse all the arguments.
#This may be a problem is a date is provided instead of just a number
#spawn /usr/bin/chage myuser
#expect -re "Minimum Password Age .0\]: "
#send -- "1 2\r"
#expect_error
spawn /usr/bin/chage myuser
expect -re "Minimum Password Age .0\]: "
send "11\r"
expect -re "Maximum Password Age .99999\]: "
send -- "-2\r"
expect_error
spawn /usr/bin/chage myuser
expect -re "Minimum Password Age .0\]: "
send "\r"
expect -re "Maximum Password Age .99999\]: "
send "foo\r"
expect_error
# chage should verify the range of the arguments
#spawn /usr/bin/chage myuser
#expect -re "Minimum Password Age .0\]: "
#send "\r"
#expect -re "Maximum Password Age .99999\]: "
#send "100000\r"
#expect_error
#spawn /usr/bin/chage myuser
#expect -re "Minimum Password Age .0\]: "
#send "\r"
#expect -re "Maximum Password Age .99999\]: "
#send "\r"
#expect -re "Last Password Change \[(]YYYY-MM-DD\[)] .2005-07-25]: "
#send "12\n"
#expect_error
puts "\nPASS"
exit 0
|