[Pkg-shadow-commits] r589 - in trunk: . tests tests/chage tests/chage/01 tests/chage/01/data tests/chage/02 tests/chage/02/data tests/chsh tests/chsh/01 tests/chsh/01/data tests/convtools tests/convtools/01 tests/convtools/01/data tests/convtools/01/data/1 tests/convtools/01/data/2 tests/su tests/su/01 tests/su/01/data tests/su/02 tests/su/02/data

Nicolas FRANCOIS nekral-guest at costa.debian.org
Tue Oct 11 22:10:06 UTC 2005


Author: nekral-guest
Date: 2005-10-11 22:10:04 +0000 (Tue, 11 Oct 2005)
New Revision: 589

Added:
   trunk/tests/
   trunk/tests/README
   trunk/tests/chage/
   trunk/tests/chage/01/
   trunk/tests/chage/01/data/
   trunk/tests/chage/01/data/chage1
   trunk/tests/chage/01/data/chage2
   trunk/tests/chage/01/data/chage3
   trunk/tests/chage/01/data/chage4
   trunk/tests/chage/01/data/chage5
   trunk/tests/chage/01/data/chage6
   trunk/tests/chage/01/data/chage7
   trunk/tests/chage/01/data/chage7b
   trunk/tests/chage/01/data/chage8
   trunk/tests/chage/01/data/group
   trunk/tests/chage/01/data/passwd
   trunk/tests/chage/01/data/usage
   trunk/tests/chage/01/run
   trunk/tests/chage/01/run1.exp
   trunk/tests/chage/01/run2.exp
   trunk/tests/chage/02/
   trunk/tests/chage/02/data/
   trunk/tests/chage/02/data/group
   trunk/tests/chage/02/data/passwd
   trunk/tests/chage/02/run
   trunk/tests/chage/02/run.exp
   trunk/tests/chsh/
   trunk/tests/chsh/01/
   trunk/tests/chsh/01/data/
   trunk/tests/chsh/01/data/chsh1
   trunk/tests/chsh/01/data/chsh2
   trunk/tests/chsh/01/data/group
   trunk/tests/chsh/01/data/passwd
   trunk/tests/chsh/01/data/shells
   trunk/tests/chsh/01/run
   trunk/tests/chsh/01/run.exp
   trunk/tests/convtools/
   trunk/tests/convtools/01/
   trunk/tests/convtools/01/data/
   trunk/tests/convtools/01/data/1/
   trunk/tests/convtools/01/data/1/group
   trunk/tests/convtools/01/data/1/passwd
   trunk/tests/convtools/01/data/2/
   trunk/tests/convtools/01/data/2/group
   trunk/tests/convtools/01/data/2/passwd
   trunk/tests/convtools/01/run
   trunk/tests/run_all
   trunk/tests/su/
   trunk/tests/su/01/
   trunk/tests/su/01/data/
   trunk/tests/su/01/data/group
   trunk/tests/su/01/data/passwd
   trunk/tests/su/01/run
   trunk/tests/su/01/run_su
   trunk/tests/su/02/
   trunk/tests/su/02/data/
   trunk/tests/su/02/data/group
   trunk/tests/su/02/data/passwd
   trunk/tests/su/02/run
   trunk/tests/su/02/run.exp
Log:
First release of the testsuite.


Added: trunk/tests/README
===================================================================
--- trunk/tests/README	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/README	2005-10-11 22:10:04 UTC (rev 589)
@@ -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 sarge-chroot
+	$ sudo debootstrap sarge sarge-chroot/ http://ftp.fr.debian.org/debian/
+(sarge can be replaced by sid)
+edit or copy a sources.list
+	$ sudo cp /etc/apt/sources.list sarge-chroot/etc/apt/
+edit or copy a resolv.conf
+	$ sudo cp /etc/resolv.conf sarge-chroot/etc/
+	$ su - root -c "chroot sarge-chroot/ /bin/bash"
+	# mount -t proc proc /proc
+	# cd /dev; ./MAKEDEV generic
+	# base-config
+	# aptitude update
+	# aptitude install expect
+

Added: trunk/tests/chage/01/data/chage1
===================================================================
--- trunk/tests/chage/01/data/chage1	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/data/chage1	2005-10-11 22:10:04 UTC (rev 589)
@@ -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

Added: trunk/tests/chage/01/data/chage2
===================================================================
--- trunk/tests/chage/01/data/chage2	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/data/chage2	2005-10-11 22:10:04 UTC (rev 589)
@@ -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

Added: trunk/tests/chage/01/data/chage3
===================================================================
--- trunk/tests/chage/01/data/chage3	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/data/chage3	2005-10-11 22:10:04 UTC (rev 589)
@@ -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

Added: trunk/tests/chage/01/data/chage4
===================================================================
--- trunk/tests/chage/01/data/chage4	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/data/chage4	2005-10-11 22:10:04 UTC (rev 589)
@@ -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

Added: trunk/tests/chage/01/data/chage5
===================================================================
--- trunk/tests/chage/01/data/chage5	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/data/chage5	2005-10-11 22:10:04 UTC (rev 589)
@@ -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

Added: trunk/tests/chage/01/data/chage6
===================================================================
--- trunk/tests/chage/01/data/chage6	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/data/chage6	2005-10-11 22:10:04 UTC (rev 589)
@@ -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

Added: trunk/tests/chage/01/data/chage7
===================================================================
--- trunk/tests/chage/01/data/chage7	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/data/chage7	2005-10-11 22:10:04 UTC (rev 589)
@@ -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

Added: trunk/tests/chage/01/data/chage7b
===================================================================
--- trunk/tests/chage/01/data/chage7b	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/data/chage7b	2005-10-11 22:10:04 UTC (rev 589)
@@ -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

Added: trunk/tests/chage/01/data/chage8
===================================================================
--- trunk/tests/chage/01/data/chage8	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/data/chage8	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1 @@
+chage: unknown user myuser8

Added: trunk/tests/chage/01/data/group
===================================================================
--- trunk/tests/chage/01/data/group	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/data/group	2005-10-11 22:10:04 UTC (rev 589)
@@ -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:

Added: trunk/tests/chage/01/data/passwd
===================================================================
--- trunk/tests/chage/01/data/passwd	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/data/passwd	2005-10-11 22:10:04 UTC (rev 589)
@@ -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

Added: trunk/tests/chage/01/data/usage
===================================================================
--- trunk/tests/chage/01/data/usage	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/data/usage	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,14 @@
+Usage: chage [options] user
+
+Options:
+  -d, --lastday LAST_DAY	set 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
+  -W, --warndays WARN_DAYS	set expiration warning days to WARN_DAYS

Added: trunk/tests/chage/01/run
===================================================================
--- trunk/tests/chage/01/run	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/run	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,203 @@
+#!/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
+
+cp data/{passwd,group,shadow,gshadow} /etc/
+
+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 bahavior
+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 2> tmp/out || {
+	if [ "$?" != "2" ]; then false; fi
+}
+diff -au data/usage tmp/out
+
+echo "OK"


Property changes on: trunk/tests/chage/01/run
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/chage/01/run1.exp
===================================================================
--- trunk/tests/chage/01/run1.exp	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/run1.exp	2005-10-11 22:10:04 UTC (rev 589)
@@ -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
+


Property changes on: trunk/tests/chage/01/run1.exp
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/chage/01/run2.exp
===================================================================
--- trunk/tests/chage/01/run2.exp	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/01/run2.exp	2005-10-11 22:10:04 UTC (rev 589)
@@ -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
+


Property changes on: trunk/tests/chage/01/run2.exp
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/chage/02/data/group
===================================================================
--- trunk/tests/chage/02/data/group	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/02/data/group	2005-10-11 22:10:04 UTC (rev 589)
@@ -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:

Added: trunk/tests/chage/02/data/passwd
===================================================================
--- trunk/tests/chage/02/data/passwd	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/02/data/passwd	2005-10-11 22:10:04 UTC (rev 589)
@@ -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

Added: trunk/tests/chage/02/run
===================================================================
--- trunk/tests/chage/02/run	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/02/run	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+set -e
+
+cd $(dirname $0)
+
+# Rational:
+# Test chage with bogus inputs
+
+# 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
+
+cp data/{passwd,group,shadow,gshadow} /etc/
+
+echo "interractive test"
+./run.exp $(date "+%Y-%m-%d")
+
+echo "OK"


Property changes on: trunk/tests/chage/02/run
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/chage/02/run.exp
===================================================================
--- trunk/tests/chage/02/run.exp	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chage/02/run.exp	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,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
+


Property changes on: trunk/tests/chage/02/run.exp
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/chsh/01/data/chsh1
===================================================================
--- trunk/tests/chsh/01/data/chsh1	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chsh/01/data/chsh1	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1 @@
+You may not change the shell for myuser.

Added: trunk/tests/chsh/01/data/chsh2
===================================================================
--- trunk/tests/chsh/01/data/chsh2	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chsh/01/data/chsh2	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1 @@
+You may not change the shell for myuser2.

Added: trunk/tests/chsh/01/data/group
===================================================================
--- trunk/tests/chsh/01/data/group	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chsh/01/data/group	2005-10-11 22:10:04 UTC (rev 589)
@@ -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:

Added: trunk/tests/chsh/01/data/passwd
===================================================================
--- trunk/tests/chsh/01/data/passwd	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chsh/01/data/passwd	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,21 @@
+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:424242:424242::/home:/bin/bash
+myuser2:x:424243:424242::/home:/bin/sh

Added: trunk/tests/chsh/01/data/shells
===================================================================
--- trunk/tests/chsh/01/data/shells	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chsh/01/data/shells	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,16 @@
+# /etc/shells: valid login shells
+/bin/ash
+/bin/csh
+/bin/sh
+/usr/bin/es
+/usr/bin/ksh
+/bin/ksh
+/usr/bin/rc
+/usr/bin/tcsh
+/bin/tcsh
+/usr/bin/zsh
+/bin/sash
+/bin/zsh
+/usr/bin/esh
+/bin/bash
+/bin/rbash

Added: trunk/tests/chsh/01/run
===================================================================
--- trunk/tests/chsh/01/run	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chsh/01/run	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,139 @@
+#!/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 shells
+	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 shells
+	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
+	rm -f tmp/shell tmp/sh:ell
+	rmdir tmp
+}
+
+save
+
+# restore the files on exit
+trap 'if [ "$?" != "0" ]; then echo "FAIL"; fi; restore' 0
+
+cp data/{passwd,group,shadow,gshadow,shells} /etc/
+
+echo -n "changing to a restricted shell, by root..."
+cp /bin/bash tmp/shell
+chsh -s $(pwd)/tmp/shell myuser
+ent=$(getent passwd myuser)
+[ "$ent" = "myuser:x:424242:424242::/home:"$(pwd)"/tmp/shell" ] || exit 1
+echo "OK"
+
+echo -n "changing from a restricted shell, by myuser..."
+su myuser -c "chsh -s /bin/bash" 2> tmp/out && exit 1
+ent=$(getent passwd myuser)
+[ "$ent" = "myuser:x:424242:424242::/home:"$(pwd)"/tmp/shell" ] || exit 1
+diff -au data/chsh1 tmp/out
+echo "OK"
+
+echo -n "changing from a restricted shell, by root..."
+chsh -s /bin/bash myuser
+ent=$(getent passwd myuser)
+[ "$ent" = "myuser:x:424242:424242::/home:/bin/bash" ] || exit 1
+echo "OK"
+
+echo -n "changing to a restricted shell, by myuser..."
+su myuser -c "chsh -s $(pwd)/tmp/shell" 2> tmp/out && exit 1
+ent=$(getent passwd myuser)
+[ "$ent" = "myuser:x:424242:424242::/home:/bin/bash" ] || exit 1
+grep "/tmp/shell is an invalid shell." tmp/out > /dev/null
+[ $(wc -l tmp/out| cut -d" " -f1) = "1" ] || exit 1
+echo "OK"
+
+echo -n "changing to a new valid shell, by myuser..."
+echo $(pwd)/tmp/shell >> /tmp/shells
+su myuser -c "chsh -s $(pwd)/tmp/shell" 2> tmp/out && exit 1
+ent=$(getent passwd myuser)
+[ "$ent" = "myuser:x:424242:424242::/home:/bin/bash" ] || exit 1
+grep "/tmp/shell is an invalid shell." tmp/out > /dev/null
+[ $(wc -l tmp/out| cut -d" " -f1) = "1" ] || exit 1
+echo "OK"
+
+echo -n "changing another user's shell..."
+su myuser -c "chsh -s /bin/sh myuser2" 2> tmp/out && exit 1
+ent=$(getent passwd myuser2)
+[ "$ent" = "myuser2:x:424243:424242::/home:/bin/sh" ] || exit 1
+diff -au data/chsh2 tmp/out
+echo "OK"
+
+echo -n "changing to a non-executable shell..."
+chmod a-x tmp/shell
+su myuser -c "chsh -s $(pwd)/tmp/shell myuser" 2> tmp/out && exit 1
+ent=$(getent passwd myuser)
+[ "$ent" = "myuser:x:424242:424242::/home:/bin/bash" ] || exit 1
+grep "/tmp/shell is an invalid shell." tmp/out > /dev/null
+[ $(wc -l tmp/out| cut -d" " -f1) = "1" ] || exit 1
+echo "OK"
+
+echo -n "changing to an invalid shell name..."
+cp /bin/bash tmp/sh:ell
+echo $(pwd)/tmp/sh:ell >> /etc/shells
+chsh -s $(pwd)/tmp/sh:ell myuser 2> tmp/out && exit 1
+ent=$(getent passwd myuser)
+[ "$ent" = "myuser:x:424242:424242::/home:/bin/bash" ] || exit 1
+egrep "chsh: Invalid entry: .*/tmp/sh:ell" tmp/out > /dev/null
+[ $(wc -l tmp/out| cut -d" " -f1) = "1" ] || exit 1
+echo "OK"
+
+echo "testing the interactive mode (1)..."
+rm -f tmp/out
+./run.exp /bin/bash myuser
+[ -f tmp/out ] && exit 1
+ent=$(getent passwd myuser)
+[ "$ent" = "myuser:x:424242:424242::/home:/bin/bash" ] || exit 1
+echo "OK"
+
+echo "testing the interactive mode (2)..."
+rm -f tmp/out
+su myuser -c "./run.exp /bin/bash"
+[ -f tmp/out ] && exit 1
+ent=$(getent passwd myuser)
+[ "$ent" = "myuser:x:424242:424242::/home:/bin/bash" ] || exit 1
+echo "OK"
+
+echo "testing the interactive mode (3)..."
+rm -f tmp/out
+./run.exp /bin/sh myuser
+[ -f tmp/out ] && exit 1
+ent=$(getent passwd myuser)
+[ "$ent" = "myuser:x:424242:424242::/home:/bin/sh" ] || exit 1
+echo "OK"
+
+echo "testing the interactive mode (4)..."
+rm -f tmp/out
+./run.exp $(pwd)/tmp/sh:ell myuser && exit 1
+egrep "chsh: Invalid entry: .*/tmp/sh:ell" tmp/out > /dev/null
+ent=$(getent passwd myuser)
+[ "$ent" = "myuser:x:424242:424242::/home:/bin/sh" ] || exit 1
+echo "OK"
+


Property changes on: trunk/tests/chsh/01/run
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/chsh/01/run.exp
===================================================================
--- trunk/tests/chsh/01/run.exp	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/chsh/01/run.exp	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,38 @@
+#!/usr/bin/expect
+
+set timeout 5
+
+if {$argc < 1} {
+	puts "usage: run.exp \[shell] \[user]"
+	exit 1
+}
+set shell     [lindex $argv 0]
+
+if {$argc == 2} {
+	spawn /usr/bin/chsh [lindex $argv 1]
+} else {
+	spawn /usr/bin/chsh
+}
+
+expect "Changing the login shell for myuser"
+expect "Enter the new value, or press ENTER for the default"
+expect -re "Login Shell .*\]: "
+send "$shell\r"
+expect "$shell\r\n"
+expect {
+	eof {
+		if ([string compare $expect_out(buffer) ""]) {
+			set fp [open "tmp/out" w]
+			puts $fp "$expect_out(buffer)"
+			puts "\nFAIL"
+			exit 1
+		}
+	} default {
+		puts "\nFAIL"
+		exit 1
+	}
+}
+
+puts "\nPASS"
+exit 0
+


Property changes on: trunk/tests/chsh/01/run.exp
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/convtools/01/data/1/group
===================================================================
--- trunk/tests/convtools/01/data/1/group	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/convtools/01/data/1/group	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,42 @@
+root:*:0:
+daemon:*:1:
+bin:*:2:
+sys:*:3:
+adm:*:4:
+tty:*:5:
+disk:*:6:
+lp:*:7:
+mail:*:8:
+news:*:9:
+uucp:*:10:
+man:*:12:
+proxy:*:13:
+kmem:*:15:
+dialout:*:20:
+fax:*:21:
+voice:*:22:
+cdrom:*:24:
+floppy:*:25:
+tape:*:26:
+sudo:*:27:
+audio:*:29:
+dip:*:30:
+www-data:*:33:
+backup:*:34:
+operator:*:37:
+list:*:38:
+irc:*:39:
+src:*:40:
+gnats:*:41:
+shadow:*:42:
+utmp:*:43:
+video:*:44:
+sasl:*:45:
+plugdev:*:46:
+staff:*:50:
+games:*:60:
+users:*:100:
+nogroup:*:65534:
+crontab:x:101:
+Debian-exim:x:102:
+myuser:x:424242:

Added: trunk/tests/convtools/01/data/1/passwd
===================================================================
--- trunk/tests/convtools/01/data/1/passwd	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/convtools/01/data/1/passwd	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,21 @@
+root:$1$NBLBLIXb$WUgojj1bNuxWEADQGt1m9.:0:0:root:/root:/bin/bash
+daemon:*:1:1:daemon:/usr/sbin:/bin/sh
+bin:*:2:2:bin:/bin:/bin/sh
+sys:*:3:3:sys:/dev:/bin/sh
+sync:*:4:65534:sync:/bin:/bin/sync
+games:*:5:60:games:/usr/games:/bin/sh
+man:*:6:12:man:/var/cache/man:/bin/sh
+lp:*:7:7:lp:/var/spool/lpd:/bin/sh
+mail:*:8:8:mail:/var/mail:/bin/sh
+news:*:9:9:news:/var/spool/news:/bin/sh
+uucp:*:10:10:uucp:/var/spool/uucp:/bin/sh
+proxy:*:13:13:proxy:/bin:/bin/sh
+www-data:*:33:33:www-data:/var/www:/bin/sh
+backup:*:34:34:backup:/var/backups:/bin/sh
+list:*:38:38:Mailing List Manager:/var/list:/bin/sh
+irc:*:39:39:ircd:/var/run/ircd:/bin/sh
+gnats:*:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
+nobody:*:65534:65534:nobody:/nonexistent:/bin/sh
+Debian-exim:!:102:102::/var/spool/exim4:/bin/false
+myuser:$1$yQnIAZWV$gDAMB2IkqaONgrQiRdo4y.:424242:424242::/home:/bin/bash
+testsuite::424243:424243::/home:/bin/bash

Added: trunk/tests/convtools/01/data/2/group
===================================================================
--- trunk/tests/convtools/01/data/2/group	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/convtools/01/data/2/group	2005-10-11 22:10:04 UTC (rev 589)
@@ -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:

Added: trunk/tests/convtools/01/data/2/passwd
===================================================================
--- trunk/tests/convtools/01/data/2/passwd	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/convtools/01/data/2/passwd	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,21 @@
+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:424242:424242::/home:/bin/bash
+testsuite:x:424243:424243::/home:/bin/bash

Added: trunk/tests/convtools/01/run
===================================================================
--- trunk/tests/convtools/01/run	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/convtools/01/run	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+set -e
+
+cd $(dirname $0)
+
+# Rational:
+# Test that su can be used to switch to root and to a normal account
+
+# 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
+	DATE=$(date '+%s')
+	DATE=$(( DATE/3600/24 ))
+	WARN=$( egrep "^PASS_WARN_AGE" /etc/login.defs | { read var val ; echo $val; } )
+	saveifs=$IFS
+	IFS=":"
+	cat data/2/shadow |
+		while read f1 f2 f3 f4 f5 f6 f7 f8 fres
+		do
+			echo "$f1:$f2:$DATE:$f4:$f5:$WARN:::"
+		done > tmp/shadow.2
+	IFS=$saveifs
+}
+
+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 tmp/shadow.2
+	rmdir tmp
+}
+
+save
+
+# restore the files on exit
+trap 'restore' 0
+
+rm -f /etc/{passwd,shadow,group,gshadow}
+cp data/1/{passwd,group} /etc/
+
+echo -n "pwconv "
+pwconv
+echo -n "checking..."
+diff -au /etc/passwd  data/2/passwd
+diff -au /etc/shadow  tmp/shadow.2
+diff -au /etc/group   data/1/group
+if [ -f /etc/gshadow ]
+then
+	echo "/etc/gshadow should not exist. "
+	exit 1
+fi
+echo "OK"
+
+echo -n "grpconv "
+grpconv
+echo -n "checking..."
+diff -au /etc/passwd  data/2/passwd
+diff -au /etc/shadow  tmp/shadow.2
+diff -au /etc/group   data/2/group
+diff -au /etc/gshadow data/2/gshadow
+echo "OK"
+
+echo -n "pwunconv "
+pwunconv
+echo -n "checking..."
+diff -au /etc/passwd  data/1/passwd
+if [ -f /etc/shadow ]
+then
+	echo "/etc/shadow should not exist. "
+	exit 1
+fi
+diff -au /etc/group   data/2/group
+diff -au /etc/gshadow data/2/gshadow
+echo "OK"
+
+echo -n "grpunconv "
+grpunconv
+echo -n "checking..."
+diff -au /etc/passwd  data/1/passwd
+if [ -f /etc/shadow ]
+then
+	echo "/etc/shadow should not exist. "
+	exit 1
+fi
+diff -au /etc/group   data/1/group
+if [ -f /etc/gshadow ]
+then
+	echo "/etc/gshadow should not exist. "
+	exit 1
+fi
+echo "OK"
+


Property changes on: trunk/tests/convtools/01/run
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/run_all
===================================================================
--- trunk/tests/run_all	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/run_all	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+set -e
+
+succeded=0
+failed=0
+
+run_test()
+{
+	if $1 >> testsuite.log
+	then
+		succeded=$((succeded+1))
+	else
+		failed=$((failed+1))
+	fi
+}
+
+> testsuite.log
+run_test ./su/01/run
+run_test ./su/02/run
+run_test ./convtools/01/run
+run_test ./chage/01/run
+run_test ./chage/02/run
+run_test ./chsh/01/run
+
+echo "$succeded test(s) passed"
+echo "$failed test(s) failed"
+echo "log written in 'testsuite.log'"


Property changes on: trunk/tests/run_all
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/su/01/data/group
===================================================================
--- trunk/tests/su/01/data/group	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/su/01/data/group	2005-10-11 22:10:04 UTC (rev 589)
@@ -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:

Added: trunk/tests/su/01/data/passwd
===================================================================
--- trunk/tests/su/01/data/passwd	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/su/01/data/passwd	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,21 @@
+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:424242:424242::/home:/bin/bash
+testsuite::424243:424243::/home:/bin/bash

Added: trunk/tests/su/01/run
===================================================================
--- trunk/tests/su/01/run	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/su/01/run	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+set -e
+
+cd $(dirname $0)
+
+# Rational:
+# Test that su can be used to switch to root and to a normal account
+
+# 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
+	done
+
+	true
+}
+
+restore()
+{
+	for i in passwd group shadow gshadow
+	do
+		[ -f tmp/$i  ] && cp tmp/$i  /etc/$i  && rm tmp/$i
+	done
+	rmdir tmp
+}
+
+save
+
+# restore the files on exit
+trap 'restore' 0
+
+cp data/{passwd,shadow,group,gshadow} /etc/
+
+./run_su root rootF00barbaz '# '
+
+./run_su myuser myuserF00barbaz '$ '
+


Property changes on: trunk/tests/su/01/run
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/su/01/run_su
===================================================================
--- trunk/tests/su/01/run_su	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/su/01/run_su	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,47 @@
+#!/usr/bin/expect
+
+set timeout 2
+
+if {$argc != 3} {
+	puts "usage: run_su <user> <password> <prompt>"
+	exit 1
+}
+
+set user     [lindex $argv 0]
+set password [lindex $argv 1]
+set prompt   [lindex $argv 2]
+
+# First, switch to the testsuite user
+# (otherwise, no password will be asked)
+spawn /bin/su testsuite
+expect "$ "			;# Wait for the prompt
+send "id\r"			;# Verify we are really testsuite
+expect {
+	timeout {
+		puts "\ntimeout...FAIL"
+		exit 1
+	}
+	"uid=424243(testsuite) gid=424243 groups=424243"
+}
+
+send "su $user\r"		;# Switch to the user
+expect "Password: "		;# Wait for the Password: prompt
+# Wait a little bit more (su is not ready to receive the password)
+sleep 0.1
+send "$password\r"		;# Send the password
+
+expect {
+	# Wait for the new prompt
+	"$prompt" {
+		send "id\r"	;# Verify the id
+		expect {
+			-re "\\($user\\).*\\($user\\).*\\($user\\)" {
+				puts "PASS"
+				exit 0
+			}
+		}
+	}
+}
+
+puts "\ntimeout...FAIL"
+exit 1


Property changes on: trunk/tests/su/01/run_su
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/su/02/data/group
===================================================================
--- trunk/tests/su/02/data/group	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/su/02/data/group	2005-10-11 22:10:04 UTC (rev 589)
@@ -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:

Added: trunk/tests/su/02/data/passwd
===================================================================
--- trunk/tests/su/02/data/passwd	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/su/02/data/passwd	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,21 @@
+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:424242:424242::/home/:
+testsuite::424242:424242::/home/:

Added: trunk/tests/su/02/run
===================================================================
--- trunk/tests/su/02/run	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/su/02/run	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+set -e
+cd $(dirname $0)
+
+# Rational:
+# Test that su can be used to switch to root and to a normal account
+
+# 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
+	done
+
+	true
+}
+
+restore()
+{
+	for i in passwd group shadow gshadow
+	do
+		[ -f tmp/$i  ] && cp tmp/$i  /etc/$i  && rm tmp/$i
+	done
+	rmdir tmp
+}
+
+save
+
+# restore the files on exit
+trap 'restore' 0
+
+cp data/{passwd,shadow,group,gshadow} /etc/
+
+./run.exp
+


Property changes on: trunk/tests/su/02/run
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/tests/su/02/run.exp
===================================================================
--- trunk/tests/su/02/run.exp	2005-10-11 17:49:05 UTC (rev 588)
+++ trunk/tests/su/02/run.exp	2005-10-11 22:10:04 UTC (rev 589)
@@ -0,0 +1,173 @@
+#!/usr/bin/expect
+
+set timeout 2
+
+spawn /bin/bash
+expect "# "
+
+send "id\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"uid=0(root) gid=0(root) groups=0(root)\r"
+}
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"# "
+}
+
+send "export FOO=bar\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"# "
+}
+
+#=============================================================================
+#
+# Regular su, preserve environment
+#
+#=============================================================================
+send "/bin/su myuser\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"$ "
+}
+
+send "id\n"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
+}
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"$ "
+}
+
+send "echo \"FOO=\\\"\$FOO\\\"\"\r"
+expect "FOO=\"bar\"\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"$ "
+}
+
+send "exit\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"# "
+}
+
+#=============================================================================
+#
+# su -, make a login shell
+#
+#=============================================================================
+send "/bin/su - myuser\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"$ "
+}
+
+send "id\n"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
+}
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"$ "
+}
+
+send "echo \"FOO=\\\"\$FOO\\\"\"\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"FOO=\"\"\r"
+}
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"$ "
+}
+
+send "exit\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"# "
+}
+
+#=============================================================================
+#
+# su -m, as for regular su, environment is preserved
+#
+#=============================================================================
+send "/bin/su -m myuser\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"$ "
+}
+
+send "id\n"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
+}
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"$ "
+}
+
+send "echo \"FOO=\\\"\$FOO\\\"\"\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"FOO=\"bar\"\r"
+}
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"$ "
+}
+
+send "exit\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"# "
+}
+
+
+#=============================================================================
+#
+# su -m -, make a login shell, but preserve environment
+#
+#=============================================================================
+send "/bin/su -p - myuser\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"$ "
+}
+
+send "id\n"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"uid=424242(myuser) gid=424242(myuser) groups=424242(myuser)\r"
+}
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"$ "
+}
+
+send "echo \"FOO=\\\"\$FOO\\\"\"\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"FOO=\"bar\"\r"
+}
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"$ "
+}
+
+send "exit\r"
+expect {
+	default {puts "\nFAIL"; exit 1}
+	"# "
+}
+
+
+puts "\nPASS"
+exit 0
+


Property changes on: trunk/tests/su/02/run.exp
___________________________________________________________________
Name: svn:executable
   + *




More information about the Pkg-shadow-commits mailing list