Add tests from the old svn tree
We're losing the svn history (which we could probably keep if we tried hard enough) but don't consider that worthwhile. Note these tests are destructive, so run them only in a throwaway environment like a chroot, container, or vm. The tests/run.all script should be the one which launches all the tests. Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
This testsuite is NOT SECURE: it will temporarily change your passwords file
|
||||
with known passwords.
|
||||
You should run it on a chroot, or on a secured dedicated system.
|
||||
|
||||
|
||||
|
||||
To test a Debian system:
|
||||
$ mkdir sid-chroot
|
||||
$ sudo debootstrap sid sid-chroot/ http://ftp.fr.debian.org/debian/
|
||||
edit or copy a sources.list
|
||||
$ sudo cp /etc/apt/sources.list sid-chroot/etc/apt/
|
||||
edit or copy a resolv.conf
|
||||
$ sudo cp /etc/resolv.conf sid-chroot/etc/
|
||||
$ su - root -c "chroot sid-chroot/ /bin/bash"
|
||||
# mount -t proc proc /proc
|
||||
# mount -t devpts devpts /dev/pts
|
||||
# aptitude update
|
||||
# aptitude install expect
|
||||
# cd /dev ; mknod --mode=666 /dev/ptmx c 5 2
|
||||
|
||||
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/expect -f
|
||||
|
||||
# This is a script for repeatedly logging into the localhost
|
||||
# using `rlogin` in order to apparently see a symptoms described
|
||||
# in bug #332198.
|
||||
# As described in the bug log, sometimes `rlogind` will fail to
|
||||
# establish a connection, because it starts "login" process and
|
||||
# the latter fails with "unable to determine TTY name, got /dev/pts/1"
|
||||
# message.
|
||||
#
|
||||
# BUGS
|
||||
#
|
||||
# * the script rlogins to localhost
|
||||
# * the script doesn't handle passwdord prompt, because it's intended
|
||||
# to use .rhosts auth and expects shell prompt immediately after
|
||||
# `rlogin`
|
||||
# * the regexp for shell prompt is hardcoded
|
||||
|
||||
log_user 0
|
||||
match_max 8192
|
||||
|
||||
while {1} {
|
||||
set rlogin_spawn [spawn rlogin localhost]
|
||||
if { $rlogin_spawn == 0 } { exit 1 }
|
||||
expect {
|
||||
-timeout 10 -re "^.*(Last login\[^\r\n\]*).*\n(\[^\r\n\]*\[#$\] )$" {
|
||||
send_error "$expect_out(1,string)\n"
|
||||
send_error "$expect_out(2,string)\n"
|
||||
# send_error "$expect_out(0,string)\n"
|
||||
}
|
||||
timeout {
|
||||
send_error "TIMEOUT/prompt\n"
|
||||
send_error "$expect_out(buffer)\n"
|
||||
send_error "RETRYING\n"
|
||||
log_user 1
|
||||
send "tty /\r"
|
||||
expect -timeout 2 -re "^.*\r?\n(\[^\r\n\]*# )$" {}
|
||||
send "tty /\r"
|
||||
expect -timeout 2 -re "^.*\r?\n(\[^\r\n\]*# )$" {}
|
||||
send_error "\n"
|
||||
exit 2
|
||||
}
|
||||
}
|
||||
send "tty\r"
|
||||
expect {
|
||||
-timeout 4 -re "tty\r?\n(\[^\r\n\]*)\r?\n(\[^\r\n\]*\[#$\] )$" {
|
||||
send_error "$expect_out(2,string)$expect_out(1,string)\n"
|
||||
# send_error "$expect_out(0,string)\n"
|
||||
}
|
||||
timeout { send_error "TIMEOUT/tty\n" ; exit 3 }
|
||||
}
|
||||
send "exit\r"
|
||||
expect {
|
||||
-timeout 2 eof {
|
||||
# send_error "OK4: EOF\n"
|
||||
}
|
||||
timeout { send_error "TIMEOUT/eof\n" ; exit 4 }
|
||||
}
|
||||
wait
|
||||
}
|
||||
# vi: set sw=4:
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/expect --
|
||||
|
||||
# This is a script for switching to another user and then
|
||||
# suspending (`suspend -f`) and resuming (`fg`) his shell
|
||||
|
||||
package require cmdline
|
||||
set opts {
|
||||
{s.arg "sudo su -" "user switching method"}
|
||||
{u.arg "" "username to switch to"}
|
||||
}
|
||||
set usage ": \[options]\noptions:"
|
||||
array set conf [::cmdline::getoptions argv $opts $usage]
|
||||
|
||||
log_user 1
|
||||
match_max 8192
|
||||
expect_after {
|
||||
timeout { send_error "TIMEOUT\n" ; exit 1 }
|
||||
eof { send_error "EXITED\n" ; exit 2 }
|
||||
}
|
||||
set timeout 2
|
||||
|
||||
# user switching command, by default `sudo su -`
|
||||
set swcmd $conf(s)
|
||||
# ending of typicall shell prompt (zsh/sh):
|
||||
set shpmt "(%|#|\\$) \\Z"
|
||||
catch {set shpmt $env(EXPECT_PROMPT)}
|
||||
# initial username:
|
||||
set user0 [exec id -un]
|
||||
# user we switch to (with $swcmd), by default initial user
|
||||
if {$conf(u) != ""} {set swuser $conf(u)} else {set swuser $user0}
|
||||
|
||||
# 1. start shell
|
||||
spawn bash
|
||||
expect -re "$shpmt" {}
|
||||
|
||||
# 2. sudo-ing swuser's shell:
|
||||
send "$swcmd $swuser\r"
|
||||
expect {
|
||||
-re "$swuser.*$shpmt" {}
|
||||
-re "assword: ?\\Z" {
|
||||
stty -echo
|
||||
expect_user -timeout -1 -re "(.*)\n" {set swpwd $expect_out(1,string)}
|
||||
stty echo
|
||||
send "$swpwd\r"
|
||||
expect -re "$swuser.*$shpmt" {}
|
||||
}
|
||||
}
|
||||
|
||||
# 3. getting pid and ppid of swuser's shell (needed for 5b):
|
||||
send "echo \$\$:\$PPID\r"
|
||||
expect -re "(?n)^(\[\[:digit:\]\]*):(\[\[:digit:\]\]*)\r?\n(.*)$shpmt" {}
|
||||
set swpid $expect_out(1,string)
|
||||
set swppid $expect_out(2,string)
|
||||
|
||||
#send_error "$user0:$swpid:$swppid\n"
|
||||
|
||||
# 4. suspending swuser's shell (trying to return to parent shell):
|
||||
send "suspend -f\r"
|
||||
expect {
|
||||
-re "$shpmt" {
|
||||
# 5a. got to parent shell -- resuming swuser's shell by `fg`:
|
||||
send "fg\r"
|
||||
set hung no
|
||||
}
|
||||
timeout {
|
||||
# 5b. `suspend -f` has hung -- resuming swuser's shell by SIGCONT:
|
||||
send_error "kill $swppid\n"
|
||||
send_error [exec kill -CONT $swppid]
|
||||
set hung yes
|
||||
}
|
||||
}
|
||||
expect -re "$shpmt" {}
|
||||
|
||||
# 6. exiting [both] shells
|
||||
#set swstat [wait -nowait]
|
||||
#send_error [pid]:[exp_pid]:$swstat\n
|
||||
send "exit\rexit\r"
|
||||
expect eof {}
|
||||
#send_error [wait -nowait]\n
|
||||
#exec kill -KILL -[exp_pid]
|
||||
if {$hung} {send_error "BUGGY\n" ; exit 3 }
|
||||
|
||||
# vi:set sw=4:
|
||||
@@ -0,0 +1,7 @@
|
||||
Last password change : Jul 27, 2005
|
||||
Password expires : never
|
||||
Password inactive : never
|
||||
Account expires : never
|
||||
Minimum number of days between password change : 0
|
||||
Maximum number of days between password change : 99999
|
||||
Number of days of warning before password expires : 7
|
||||
@@ -0,0 +1,7 @@
|
||||
Last password change : Jul 28, 2005
|
||||
Password expires : never
|
||||
Password inactive : never
|
||||
Account expires : never
|
||||
Minimum number of days between password change : 1
|
||||
Maximum number of days between password change : 99996
|
||||
Number of days of warning before password expires : 5
|
||||
@@ -0,0 +1,7 @@
|
||||
Last password change : Jul 27, 2005
|
||||
Password expires : never
|
||||
Password inactive : never
|
||||
Account expires : Jan 01, 1970
|
||||
Minimum number of days between password change : 0
|
||||
Maximum number of days between password change : 99999
|
||||
Number of days of warning before password expires : 7
|
||||
@@ -0,0 +1,7 @@
|
||||
Last password change : Jul 27, 2005
|
||||
Password expires : never
|
||||
Password inactive : never
|
||||
Account expires : Jan 02, 1970
|
||||
Minimum number of days between password change : 0
|
||||
Maximum number of days between password change : 99999
|
||||
Number of days of warning before password expires : 7
|
||||
@@ -0,0 +1,7 @@
|
||||
Last password change : Jul 27, 2005
|
||||
Password expires : never
|
||||
Password inactive : never
|
||||
Account expires : never
|
||||
Minimum number of days between password change : 0
|
||||
Maximum number of days between password change : 99999
|
||||
Number of days of warning before password expires : 7
|
||||
@@ -0,0 +1,7 @@
|
||||
Last password change : Jul 27, 2005
|
||||
Password expires : never
|
||||
Password inactive : never
|
||||
Account expires : never
|
||||
Minimum number of days between password change : 0
|
||||
Maximum number of days between password change : 99999
|
||||
Number of days of warning before password expires : 7
|
||||
@@ -0,0 +1,7 @@
|
||||
Last password change : Jul 27, 2005
|
||||
Password expires : never
|
||||
Password inactive : never
|
||||
Account expires : never
|
||||
Minimum number of days between password change : 0
|
||||
Maximum number of days between password change : 99999
|
||||
Number of days of warning before password expires : 7
|
||||
@@ -0,0 +1,7 @@
|
||||
Last password change : Jul 26, 2005
|
||||
Password expires : Aug 09, 2005
|
||||
Password inactive : Sep 13, 2005
|
||||
Account expires : Jul 27, 2012
|
||||
Minimum number of days between password change : 13
|
||||
Maximum number of days between password change : 14
|
||||
Number of days of warning before password expires : 9
|
||||
@@ -0,0 +1 @@
|
||||
chage: user 'myuser8' does not exist in /etc/passwd
|
||||
@@ -0,0 +1,42 @@
|
||||
root:x:0:
|
||||
daemon:x:1:
|
||||
bin:x:2:
|
||||
sys:x:3:
|
||||
adm:x:4:
|
||||
tty:x:5:
|
||||
disk:x:6:
|
||||
lp:x:7:
|
||||
mail:x:8:
|
||||
news:x:9:
|
||||
uucp:x:10:
|
||||
man:x:12:
|
||||
proxy:x:13:
|
||||
kmem:x:15:
|
||||
dialout:x:20:
|
||||
fax:x:21:
|
||||
voice:x:22:
|
||||
cdrom:x:24:
|
||||
floppy:x:25:
|
||||
tape:x:26:
|
||||
sudo:x:27:
|
||||
audio:x:29:
|
||||
dip:x:30:
|
||||
www-data:x:33:
|
||||
backup:x:34:
|
||||
operator:x:37:
|
||||
list:x:38:
|
||||
irc:x:39:
|
||||
src:x:40:
|
||||
gnats:x:41:
|
||||
shadow:x:42:
|
||||
utmp:x:43:
|
||||
video:x:44:
|
||||
sasl:x:45:
|
||||
plugdev:x:46:
|
||||
staff:x:50:
|
||||
games:x:60:
|
||||
users:x:100:
|
||||
nogroup:x:65534:
|
||||
crontab:x:101:
|
||||
Debian-exim:x:102:
|
||||
myuser:x:424242:
|
||||
@@ -0,0 +1,42 @@
|
||||
root:*::
|
||||
daemon:*::
|
||||
bin:*::
|
||||
sys:*::
|
||||
adm:*::
|
||||
tty:*::
|
||||
disk:*::
|
||||
lp:*::
|
||||
mail:*::
|
||||
news:*::
|
||||
uucp:*::
|
||||
man:*::
|
||||
proxy:*::
|
||||
kmem:*::
|
||||
dialout:*::
|
||||
fax:*::
|
||||
voice:*::
|
||||
cdrom:*::
|
||||
floppy:*::
|
||||
tape:*::
|
||||
sudo:*::
|
||||
audio:*::
|
||||
dip:*::
|
||||
www-data:*::
|
||||
backup:*::
|
||||
operator:*::
|
||||
list:*::
|
||||
irc:*::
|
||||
src:*::
|
||||
gnats:*::
|
||||
shadow:*::
|
||||
utmp:*::
|
||||
video:*::
|
||||
sasl:*::
|
||||
plugdev:*::
|
||||
staff:*::
|
||||
games:*::
|
||||
users:*::
|
||||
nogroup:*::
|
||||
crontab:x::
|
||||
Debian-exim:x::
|
||||
myuser:x::
|
||||
@@ -0,0 +1,26 @@
|
||||
root:x:0:0:root:/root:/bin/bash
|
||||
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
|
||||
bin:x:2:2:bin:/bin:/bin/sh
|
||||
sys:x:3:3:sys:/dev:/bin/sh
|
||||
sync:x:4:65534:sync:/bin:/bin/sync
|
||||
games:x:5:60:games:/usr/games:/bin/sh
|
||||
man:x:6:12:man:/var/cache/man:/bin/sh
|
||||
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
|
||||
mail:x:8:8:mail:/var/mail:/bin/sh
|
||||
news:x:9:9:news:/var/spool/news:/bin/sh
|
||||
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
|
||||
proxy:x:13:13:proxy:/bin:/bin/sh
|
||||
www-data:x:33:33:www-data:/var/www:/bin/sh
|
||||
backup:x:34:34:backup:/var/backups:/bin/sh
|
||||
list:x:38:38:Mailing List Manager:/var/list:/bin/sh
|
||||
irc:x:39:39:ircd:/var/run/ircd:/bin/sh
|
||||
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
|
||||
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
|
||||
Debian-exim:x:102:102::/var/spool/exim4:/bin/false
|
||||
myuser1:x:424242:424242::/home:/bin/bash
|
||||
myuser2:x:424243:424242::/home:/bin/bash
|
||||
myuser3:x:424244:424242::/home:/bin/bash
|
||||
myuser4:x:424245:424242::/home:/bin/bash
|
||||
myuser5:x:424246:424242::/home:/bin/bash
|
||||
myuser6:x:424247:424242::/home:/bin/bash
|
||||
myuser7:x:424248:424242::/home:/bin/bash
|
||||
@@ -0,0 +1,26 @@
|
||||
root:$1$NBLBLIXb$WUgojj1bNuxWEADQGt1m9.:12991:0:99999:7:::
|
||||
daemon:*:12977:0:99999:7:::
|
||||
bin:*:12977:0:99999:7:::
|
||||
sys:*:12977:0:99999:7:::
|
||||
sync:*:12977:0:99999:7:::
|
||||
games:*:12977:0:99999:7:::
|
||||
man:*:12977:0:99999:7:::
|
||||
lp:*:12977:0:99999:7:::
|
||||
mail:*:12977:0:99999:7:::
|
||||
news:*:12977:0:99999:7:::
|
||||
uucp:*:12977:0:99999:7:::
|
||||
proxy:*:12977:0:99999:7:::
|
||||
www-data:*:12977:0:99999:7:::
|
||||
backup:*:12977:0:99999:7:::
|
||||
list:*:12977:0:99999:7:::
|
||||
irc:*:12977:0:99999:7:::
|
||||
gnats:*:12977:0:99999:7:::
|
||||
nobody:*:12977:0:99999:7:::
|
||||
Debian-exim:!:12977:0:99999:7:::
|
||||
myuser1:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:12991:0:99999:7:::
|
||||
myuser2:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:12992:1:99996:5:::
|
||||
myuser3:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:12991:0:99999:7::0:
|
||||
myuser4:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:12991:0:99999:7::1:
|
||||
myuser5:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:12991:0:99999:7:0::
|
||||
myuser6:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:12991:0:99999:7:1::
|
||||
myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:12991:0:99999:7:1::
|
||||
@@ -0,0 +1,16 @@
|
||||
Usage: chage [options] LOGIN
|
||||
|
||||
Options:
|
||||
-d, --lastday LAST_DAY set date of last password change to LAST_DAY
|
||||
-E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE
|
||||
-h, --help display this help message and exit
|
||||
-I, --inactive INACTIVE set password inactive after expiration
|
||||
to INACTIVE
|
||||
-l, --list show account aging information
|
||||
-m, --mindays MIN_DAYS set minimum number of days before password
|
||||
change to MIN_DAYS
|
||||
-M, --maxdays MAX_DAYS set maximim number of days before password
|
||||
change to MAX_DAYS
|
||||
-R, --root CHROOT_DIR directory to chroot into
|
||||
-W, --warndays WARN_DAYS set expiration warning days to WARN_DAYS
|
||||
|
||||
Executable
+206
@@ -0,0 +1,206 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
# Rational:
|
||||
# Test chage options
|
||||
|
||||
# no testsuite password
|
||||
# root password: rootF00barbaz
|
||||
# myuser password: myuserF00barbaz
|
||||
|
||||
save()
|
||||
{
|
||||
[ ! -d tmp ] && mkdir tmp
|
||||
for i in passwd group shadow gshadow
|
||||
do
|
||||
[ -f /etc/$i ] && cp /etc/$i tmp/$i
|
||||
[ -f /etc/$i- ] && cp /etc/$i- tmp/$i-
|
||||
done
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
restore()
|
||||
{
|
||||
for i in passwd group shadow gshadow
|
||||
do
|
||||
[ -f tmp/$i ] && cp tmp/$i /etc/$i && rm tmp/$i
|
||||
[ -f tmp/$i- ] && cp tmp/$i- /etc/$i- && rm tmp/$i-
|
||||
done
|
||||
rm -f tmp/out
|
||||
rmdir tmp
|
||||
}
|
||||
|
||||
save
|
||||
|
||||
# restore the files on exit
|
||||
trap 'if [ "$?" != "0" ]; then echo "FAIL"; fi; restore' 0
|
||||
|
||||
for i in passwd group shadow gshadow
|
||||
do
|
||||
cp data/$i /etc
|
||||
done
|
||||
|
||||
echo -n "testing option -l"
|
||||
chage -l myuser1 > tmp/out
|
||||
diff -au data/chage1 tmp/out
|
||||
echo -n .
|
||||
chage -l myuser2 > tmp/out
|
||||
diff -au data/chage2 tmp/out
|
||||
echo -n .
|
||||
chage -l myuser3 > tmp/out
|
||||
diff -au data/chage3 tmp/out
|
||||
echo -n .
|
||||
chage -l myuser4 > tmp/out
|
||||
diff -au data/chage4 tmp/out
|
||||
echo -n .
|
||||
chage -l myuser5 > tmp/out
|
||||
diff -au data/chage5 tmp/out
|
||||
echo -n .
|
||||
chage -l myuser6 > tmp/out
|
||||
diff -au data/chage6 tmp/out
|
||||
echo -n .
|
||||
chage --list myuser7 > tmp/out
|
||||
diff -au data/chage7 tmp/out
|
||||
echo -n .
|
||||
msg=$(chage -l myuser8 2> tmp/out) || err=$?
|
||||
[ "$err" = "1" ] && [ "$msg" = "" ] || exit 1
|
||||
diff -au data/chage8 tmp/out
|
||||
echo .
|
||||
|
||||
echo "testing option -d"
|
||||
chage -d 2001-10-02 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:11597:0:99999:7:1::' ] || exit 1
|
||||
echo "testing option -d -1"
|
||||
chage -d -1 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.::0:99999:7:1::' ] || exit 1
|
||||
echo "testing option -d 0"
|
||||
chage -d 0 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:0:0:99999:7:1::' ] || exit 1
|
||||
echo "testing option --lastday"
|
||||
chage --lastday 2011-11-02 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:0:99999:7:1::' ] || exit 1
|
||||
|
||||
echo "testing option -E"
|
||||
chage -E 2010-10-02 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:0:99999:7:1:14884:' ] || exit 1
|
||||
echo "testing option -E -1"
|
||||
chage -E -1 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:0:99999:7:1::' ] || exit 1
|
||||
echo "testing option -E 0"
|
||||
chage -E 0 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:0:99999:7:1:0:' ] || exit 1
|
||||
echo "testing option --expiredate"
|
||||
chage --expiredate 2020-02-02 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:0:99999:7:1:18294:' ] || exit 1
|
||||
|
||||
echo "testing option -I"
|
||||
# NOTE: I could pass a date to -I
|
||||
chage -I 42 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:0:99999:7:42:18294:' ] || exit 1
|
||||
echo "testing option -I -1"
|
||||
# NOTE: this behavior is not documented
|
||||
chage -I -1 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:0:99999:7::18294:' ] || exit 1
|
||||
echo "testing option -I 0"
|
||||
# NOTE: We should check that this is the expected behavior
|
||||
chage -I 0 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:0:99999:7:0:18294:' ] || exit 1
|
||||
echo "testing option --inactive"
|
||||
chage --inactive 12 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:0:99999:7:12:18294:' ] || exit 1
|
||||
|
||||
echo "testing option -m"
|
||||
chage -m 24 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:24:99999:7:12:18294:' ] || exit 1
|
||||
echo "testing option -m -1"
|
||||
# NOTE: this behavior is not documented
|
||||
chage -m -1 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280::99999:7:12:18294:' ] || exit 1
|
||||
echo "testing option -m 0"
|
||||
chage -m 0 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:0:99999:7:12:18294:' ] || exit 1
|
||||
echo "testing option --mindays"
|
||||
chage --min 1 myuser7
|
||||
# NOTE: that shouldn't have work
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:1:99999:7:12:18294:' ] || exit 1
|
||||
|
||||
echo "testing option -M"
|
||||
chage -M 25 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:1:25:7:12:18294:' ] || exit 1
|
||||
echo "testing option -M -1"
|
||||
# NOTE: this behavior is not documented
|
||||
chage -M -1 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:1::7:12:18294:' ] || exit 1
|
||||
echo "testing option -M 0"
|
||||
chage -M 0 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:1:0:7:12:18294:' ] || exit 1
|
||||
echo "testing option --maxdays"
|
||||
chage --max 2 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:1:2:7:12:18294:' ] || exit 1
|
||||
|
||||
echo "testing option -W"
|
||||
chage -W 26 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:1:2:26:12:18294:' ] || exit 1
|
||||
echo "testing option -W -1"
|
||||
# NOTE: this behavior is not documented
|
||||
chage -W -1 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:1:2::12:18294:' ] || exit 1
|
||||
echo "testing option -W 0"
|
||||
chage -W 0 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:1:2:0:12:18294:' ] || exit 1
|
||||
echo "testing option --warndays"
|
||||
chage --warndays 3 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:15280:1:2:3:12:18294:' ] || exit 1
|
||||
|
||||
echo "testing with all options"
|
||||
chage -d 2030-03-02 -E 1979-11-24 -I 10 -m 11 -M 12 --warndays 4 myuser7
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:21975:11:12:4:10:3614:' ] || exit 1
|
||||
|
||||
echo "interractive test"
|
||||
./run1.exp
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:12990:13:14:9:35:15548:' ] || exit 1
|
||||
|
||||
echo "interractive test (default)"
|
||||
./run2.exp
|
||||
ent=$(getent shadow myuser7)
|
||||
[ "$ent" = 'myuser7:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:12990:13:14:9:35:15548:' ] || exit 1
|
||||
chage -l myuser7 > tmp/out
|
||||
diff -au data/chage7b tmp/out
|
||||
|
||||
echo "usage"
|
||||
chage -h > tmp/out || {
|
||||
if [ "$?" != "2" ]; then false; fi
|
||||
}
|
||||
diff -au data/usage tmp/out
|
||||
|
||||
echo "OK"
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 5
|
||||
|
||||
# I've not been able to put the opening bracket in the regular expressions
|
||||
# If anyone knows...
|
||||
|
||||
spawn /usr/bin/chage myuser7
|
||||
expect -re "Minimum Password Age .11\]: "
|
||||
send "13\r"
|
||||
expect -re "Maximum Password Age .12\]: "
|
||||
send "14\r"
|
||||
expect -re "Last Password Change \[(]YYYY-MM-DD\[)] .2030-03-02\]: "
|
||||
send "2005-07-26\r"
|
||||
expect -re "Password Expiration Warning .4\]: "
|
||||
send "9\r"
|
||||
expect -re "Password Inactive .10\]: "
|
||||
send "35\r"
|
||||
expect -re "Account Expiration Date \[(]YYYY-MM-DD\[)] .1979-11-24\]: "
|
||||
send "2012-07-27\r"
|
||||
expect {
|
||||
eof {
|
||||
} default {
|
||||
puts "\nFAIL"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/expect
|
||||
|
||||
set timeout 5
|
||||
|
||||
# I've not been able to put the opening bracket in the regular expressions
|
||||
# If anyone knows...
|
||||
|
||||
spawn /usr/bin/chage myuser7
|
||||
expect -re "Minimum Password Age .13\]: "
|
||||
send "\r"
|
||||
expect -re "Maximum Password Age .14\]: "
|
||||
send "\r"
|
||||
expect -re "Last Password Change \[(]YYYY-MM-DD\[)] .2005-07-26\]: "
|
||||
send "\r"
|
||||
expect -re "Password Expiration Warning .9\]: "
|
||||
send "\r"
|
||||
expect -re "Password Inactive .35\]: "
|
||||
send "\r"
|
||||
expect -re "Account Expiration Date \[(]YYYY-MM-DD\[)] .2012-07-27\]: "
|
||||
send "\r"
|
||||
expect {
|
||||
eof {
|
||||
} default {
|
||||
puts "\nFAIL"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
puts "\nPASS"
|
||||
exit 0
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
root:x:0:
|
||||
daemon:x:1:
|
||||
bin:x:2:
|
||||
sys:x:3:
|
||||
adm:x:4:
|
||||
tty:x:5:
|
||||
disk:x:6:
|
||||
lp:x:7:
|
||||
mail:x:8:
|
||||
news:x:9:
|
||||
uucp:x:10:
|
||||
man:x:12:
|
||||
proxy:x:13:
|
||||
kmem:x:15:
|
||||
dialout:x:20:
|
||||
fax:x:21:
|
||||
voice:x:22:
|
||||
cdrom:x:24:
|
||||
floppy:x:25:
|
||||
tape:x:26:
|
||||
sudo:x:27:
|
||||
audio:x:29:
|
||||
dip:x:30:
|
||||
www-data:x:33:
|
||||
backup:x:34:
|
||||
operator:x:37:
|
||||
list:x:38:
|
||||
irc:x:39:
|
||||
src:x:40:
|
||||
gnats:x:41:
|
||||
shadow:x:42:
|
||||
utmp:x:43:
|
||||
video:x:44:
|
||||
sasl:x:45:
|
||||
plugdev:x:46:
|
||||
staff:x:50:
|
||||
games:x:60:
|
||||
users:x:100:
|
||||
nogroup:x:65534:
|
||||
crontab:x:101:
|
||||
Debian-exim:x:102:
|
||||
myuser:x:424242:
|
||||
@@ -0,0 +1,42 @@
|
||||
root:*::
|
||||
daemon:*::
|
||||
bin:*::
|
||||
sys:*::
|
||||
adm:*::
|
||||
tty:*::
|
||||
disk:*::
|
||||
lp:*::
|
||||
mail:*::
|
||||
news:*::
|
||||
uucp:*::
|
||||
man:*::
|
||||
proxy:*::
|
||||
kmem:*::
|
||||
dialout:*::
|
||||
fax:*::
|
||||
voice:*::
|
||||
cdrom:*::
|
||||
floppy:*::
|
||||
tape:*::
|
||||
sudo:*::
|
||||
audio:*::
|
||||
dip:*::
|
||||
www-data:*::
|
||||
backup:*::
|
||||
operator:*::
|
||||
list:*::
|
||||
irc:*::
|
||||
src:*::
|
||||
gnats:*::
|
||||
shadow:*::
|
||||
utmp:*::
|
||||
video:*::
|
||||
sasl:*::
|
||||
plugdev:*::
|
||||
staff:*::
|
||||
games:*::
|
||||
users:*::
|
||||
nogroup:*::
|
||||
crontab:x::
|
||||
Debian-exim:x::
|
||||
myuser:x::
|
||||
@@ -0,0 +1,20 @@
|
||||
root:x:0:0:root:/root:/bin/bash
|
||||
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
|
||||
bin:x:2:2:bin:/bin:/bin/sh
|
||||
sys:x:3:3:sys:/dev:/bin/sh
|
||||
sync:x:4:65534:sync:/bin:/bin/sync
|
||||
games:x:5:60:games:/usr/games:/bin/sh
|
||||
man:x:6:12:man:/var/cache/man:/bin/sh
|
||||
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
|
||||
mail:x:8:8:mail:/var/mail:/bin/sh
|
||||
news:x:9:9:news:/var/spool/news:/bin/sh
|
||||
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
|
||||
proxy:x:13:13:proxy:/bin:/bin/sh
|
||||
www-data:x:33:33:www-data:/var/www:/bin/sh
|
||||
backup:x:34:34:backup:/var/backups:/bin/sh
|
||||
list:x:38:38:Mailing List Manager:/var/list:/bin/sh
|
||||
irc:x:39:39:ircd:/var/run/ircd:/bin/sh
|
||||
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
|
||||
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
|
||||
Debian-exim:x:102:102::/var/spool/exim4:/bin/false
|
||||
myuser:x:424248:424242::/home:/bin/bash
|
||||
@@ -0,0 +1,20 @@
|
||||
root:$1$NBLBLIXb$WUgojj1bNuxWEADQGt1m9.:12991:0:99999:7:::
|
||||
daemon:*:12977:0:99999:7:::
|
||||
bin:*:12977:0:99999:7:::
|
||||
sys:*:12977:0:99999:7:::
|
||||
sync:*:12977:0:99999:7:::
|
||||
games:*:12977:0:99999:7:::
|
||||
man:*:12977:0:99999:7:::
|
||||
lp:*:12977:0:99999:7:::
|
||||
mail:*:12977:0:99999:7:::
|
||||
news:*:12977:0:99999:7:::
|
||||
uucp:*:12977:0:99999:7:::
|
||||
proxy:*:12977:0:99999:7:::
|
||||
www-data:*:12977:0:99999:7:::
|
||||
backup:*:12977:0:99999:7:::
|
||||
list:*:12977:0:99999:7:::
|
||||
irc:*:12977:0:99999:7:::
|
||||
gnats:*:12977:0:99999:7:::
|
||||
nobody:*:12977:0:99999:7:::
|
||||
Debian-exim:!:12977:0:99999:7:::
|
||||
myuser:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:12991:0:99999:7:::
|
||||
Executable
+50
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||