diff --git a/tests/usertools/01/01_useradd_add_user.test b/tests/usertools/01/01_useradd_add_user.test new file mode 100755 index 00000000..dfd0366a --- /dev/null +++ b/tests/usertools/01/01_useradd_add_user.test @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1)..." +useradd test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 01_useradd_add_user/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 01_useradd_add_user/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 01_useradd_add_user/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 01_useradd_add_user/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/01_useradd_add_user/group b/tests/usertools/01/01_useradd_add_user/group new file mode 100644 index 00000000..ff319127 --- /dev/null +++ b/tests/usertools/01/01_useradd_add_user/group @@ -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: +test1:x:1000: diff --git a/tests/usertools/01/01_useradd_add_user/gshadow b/tests/usertools/01/01_useradd_add_user/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/01_useradd_add_user/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/01_useradd_add_user/passwd b/tests/usertools/01/01_useradd_add_user/passwd new file mode 100644 index 00000000..0b4b0fa8 --- /dev/null +++ b/tests/usertools/01/01_useradd_add_user/passwd @@ -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 +test1:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/01_useradd_add_user/shadow b/tests/usertools/01/01_useradd_add_user/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/01_useradd_add_user/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/01_userdel_delete_user.test b/tests/usertools/01/01_userdel_delete_user.test new file mode 100755 index 00000000..132e16aa --- /dev/null +++ b/tests/usertools/01/01_userdel_delete_user.test @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Delete user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1)..." +useradd test1 +echo "OK" +echo -n "Delete user test1 (userdel test1)..." +userdel test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl config/etc/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl config/etc/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl config/etc/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl config/etc/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/02_useradd_recreate_deleted_user.test b/tests/usertools/01/02_useradd_recreate_deleted_user.test new file mode 100755 index 00000000..44721f59 --- /dev/null +++ b/tests/usertools/01/02_useradd_recreate_deleted_user.test @@ -0,0 +1,48 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1)..." +useradd test1 +echo "OK" +echo -n "Delete user test1 (userdel test1)..." +userdel test1 +echo "OK" +echo -n "Create user test2 (useradd test1)..." +useradd test2 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 02_useradd_recreate_deleted_user/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 02_useradd_recreate_deleted_user/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 02_useradd_recreate_deleted_user/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 02_useradd_recreate_deleted_user/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test2 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/02_useradd_recreate_deleted_user/group b/tests/usertools/01/02_useradd_recreate_deleted_user/group new file mode 100644 index 00000000..3b8e510f --- /dev/null +++ b/tests/usertools/01/02_useradd_recreate_deleted_user/group @@ -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: +test2:x:1000: diff --git a/tests/usertools/01/02_useradd_recreate_deleted_user/gshadow b/tests/usertools/01/02_useradd_recreate_deleted_user/gshadow new file mode 100644 index 00000000..73d02983 --- /dev/null +++ b/tests/usertools/01/02_useradd_recreate_deleted_user/gshadow @@ -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:: +test2:!:: diff --git a/tests/usertools/01/02_useradd_recreate_deleted_user/passwd b/tests/usertools/01/02_useradd_recreate_deleted_user/passwd new file mode 100644 index 00000000..0a8cf880 --- /dev/null +++ b/tests/usertools/01/02_useradd_recreate_deleted_user/passwd @@ -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 +test2:x:1000:1000::/home/test2:/bin/sh diff --git a/tests/usertools/01/02_useradd_recreate_deleted_user/shadow b/tests/usertools/01/02_useradd_recreate_deleted_user/shadow new file mode 100644 index 00000000..1ca61d8d --- /dev/null +++ b/tests/usertools/01/02_useradd_recreate_deleted_user/shadow @@ -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::: +test2:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/03_useradd_additional_options.test b/tests/usertools/01/03_useradd_additional_options.test new file mode 100755 index 00000000..5808e458 --- /dev/null +++ b/tests/usertools/01/03_useradd_additional_options.test @@ -0,0 +1,50 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "useradd options --comment, --expiredate, --shell, --inactive, --home-dir" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test3 with options)..." +useradd --comment "comment test3" \ + --expiredate "2006-02-04" \ + --shell "/bin/bash" \ + --inactive "12" \ + --home-dir "/nonexistenthomedir" \ + test3 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 03_useradd_additional_options/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 03_useradd_additional_options/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 03_useradd_additional_options/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 03_useradd_additional_options/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir /home/test3..." +test ! -d /home/test3 +echo "OK" +echo -n "no homedir /nonexistenthomedir..." +test ! -d /nonexistenthomedir +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/03_useradd_additional_options/group b/tests/usertools/01/03_useradd_additional_options/group new file mode 100644 index 00000000..a0c13812 --- /dev/null +++ b/tests/usertools/01/03_useradd_additional_options/group @@ -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: +test3:x:1000: diff --git a/tests/usertools/01/03_useradd_additional_options/gshadow b/tests/usertools/01/03_useradd_additional_options/gshadow new file mode 100644 index 00000000..88e4ab16 --- /dev/null +++ b/tests/usertools/01/03_useradd_additional_options/gshadow @@ -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:: +test3:!:: diff --git a/tests/usertools/01/03_useradd_additional_options/passwd b/tests/usertools/01/03_useradd_additional_options/passwd new file mode 100644 index 00000000..725da572 --- /dev/null +++ b/tests/usertools/01/03_useradd_additional_options/passwd @@ -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 +test3:x:1000:1000:comment test3:/nonexistenthomedir:/bin/bash diff --git a/tests/usertools/01/03_useradd_additional_options/shadow b/tests/usertools/01/03_useradd_additional_options/shadow new file mode 100644 index 00000000..77fbfbc6 --- /dev/null +++ b/tests/usertools/01/03_useradd_additional_options/shadow @@ -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::: +test3:!:@TODAY@:0:99999:7:12:13183: diff --git a/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail.test b/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail.test new file mode 100755 index 00000000..73324510 --- /dev/null +++ b/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail.test @@ -0,0 +1,60 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user with an existing ID" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd -u 4242 test1)..." +useradd -u 4242 test1 +echo "OK" +echo -n "Create user test2 with the same ID (useradd -u 4242 test2)..." +useradd -u 4242 test2 2>tmp/useradd.err && exit 1 || { + status=$? +} +echo "OK" +echo "All right, useradd returned error $status." +echo -n "Check returned status..." +test "$status" = "4" +echo "OK" + +echo "useradd displayed:" +echo "=======================================================================" +cat tmp/useradd.err +echo "=======================================================================" +echo -n "Check that there were a failure message..." +diff -au 04_useradd_add_user_with_existing_UID_fail/useradd.err tmp/useradd.err +echo "error message OK." +rm -f tmp/useradd.err + +echo -n "Check the passwd file..." +../../common/compare_file.pl 04_useradd_add_user_with_existing_UID_fail/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 04_useradd_add_user_with_existing_UID_fail/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 04_useradd_add_user_with_existing_UID_fail/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 04_useradd_add_user_with_existing_UID_fail/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/group b/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/group new file mode 100644 index 00000000..6c7895c6 --- /dev/null +++ b/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/group @@ -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: +test1:x:4242: diff --git a/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/gshadow b/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/passwd b/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/passwd new file mode 100644 index 00000000..4b6c8085 --- /dev/null +++ b/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/passwd @@ -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 +test1:x:4242:4242::/home/test1:/bin/sh diff --git a/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/shadow b/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/useradd.err b/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/useradd.err new file mode 100644 index 00000000..23e59625 --- /dev/null +++ b/tests/usertools/01/04_useradd_add_user_with_existing_UID_fail/useradd.err @@ -0,0 +1 @@ +useradd: UID 4242 is not unique diff --git a/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o.test b/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o.test new file mode 100755 index 00000000..b630c675 --- /dev/null +++ b/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o.test @@ -0,0 +1,48 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user with a specified existing ID" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd -u 4242 test1)..." +useradd -u 4242 test1 +echo "OK" +echo -n "Create user test2 with the same ID (useradd -u 4242 -o test2)..." +useradd -u 4242 -o test2 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 04_useradd_add_user_with_existing_UID_with_-o/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 04_useradd_add_user_with_existing_UID_with_-o/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 04_useradd_add_user_with_existing_UID_with_-o/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 04_useradd_add_user_with_existing_UID_with_-o/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir /home/test1..." +test -d /home/test1 && exit 1 || true +echo "OK" +echo -n "no homedir /home/test2..." +test -d /home/test2 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o/group b/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o/group new file mode 100644 index 00000000..a951b25c --- /dev/null +++ b/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o/group @@ -0,0 +1,43 @@ +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: +test1:x:4242: +test2:x:4243: diff --git a/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o/gshadow b/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o/gshadow new file mode 100644 index 00000000..11e7389c --- /dev/null +++ b/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o/gshadow @@ -0,0 +1,43 @@ +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:: +test1:!:: +test2:!:: diff --git a/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o/passwd b/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o/passwd new file mode 100644 index 00000000..58c50dd6 --- /dev/null +++ b/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o/passwd @@ -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 +test1:x:4242:4242::/home/test1:/bin/sh +test2:x:4242:4243::/home/test2:/bin/sh diff --git a/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o/shadow b/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o/shadow new file mode 100644 index 00000000..4c40f478 --- /dev/null +++ b/tests/usertools/01/04_useradd_add_user_with_existing_UID_with_-o/shadow @@ -0,0 +1,21 @@ +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::: +test1:!:@TODAY@:0:99999:7::: +test2:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/04_useradd_specified_UID.test b/tests/usertools/01/04_useradd_specified_UID.test new file mode 100755 index 00000000..240899b6 --- /dev/null +++ b/tests/usertools/01/04_useradd_specified_UID.test @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user with a specified ID" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd -u 4242 test1)..." +useradd -u 4242 test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 04_useradd_specified_UID/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 04_useradd_specified_UID/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 04_useradd_specified_UID/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 04_useradd_specified_UID/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/04_useradd_specified_UID/group b/tests/usertools/01/04_useradd_specified_UID/group new file mode 100644 index 00000000..6c7895c6 --- /dev/null +++ b/tests/usertools/01/04_useradd_specified_UID/group @@ -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: +test1:x:4242: diff --git a/tests/usertools/01/04_useradd_specified_UID/gshadow b/tests/usertools/01/04_useradd_specified_UID/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/04_useradd_specified_UID/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/04_useradd_specified_UID/passwd b/tests/usertools/01/04_useradd_specified_UID/passwd new file mode 100644 index 00000000..4b6c8085 --- /dev/null +++ b/tests/usertools/01/04_useradd_specified_UID/passwd @@ -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 +test1:x:4242:4242::/home/test1:/bin/sh diff --git a/tests/usertools/01/04_useradd_specified_UID/shadow b/tests/usertools/01/04_useradd_specified_UID/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/04_useradd_specified_UID/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/04_useradd_specified_UID_and_GID.test b/tests/usertools/01/04_useradd_specified_UID_and_GID.test new file mode 100755 index 00000000..1e119711 --- /dev/null +++ b/tests/usertools/01/04_useradd_specified_UID_and_GID.test @@ -0,0 +1,48 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user with a specified existing UID and GID" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd -u 4242 test1)..." +useradd -u 4242 test1 +echo "OK" +echo -n "Create user test2 with the same ID (useradd -u 4242 -g 4242 -o test2)..." +useradd -u 4242 -g 4242 -o test2 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 04_useradd_specified_UID_and_GID/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 04_useradd_specified_UID_and_GID/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 04_useradd_specified_UID_and_GID/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 04_useradd_specified_UID_and_GID/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir /home/test1..." +test -d /home/test1 && exit 1 || true +echo "OK" +echo -n "no homedir /home/test2..." +test -d /home/test2 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/04_useradd_specified_UID_and_GID/group b/tests/usertools/01/04_useradd_specified_UID_and_GID/group new file mode 100644 index 00000000..6c7895c6 --- /dev/null +++ b/tests/usertools/01/04_useradd_specified_UID_and_GID/group @@ -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: +test1:x:4242: diff --git a/tests/usertools/01/04_useradd_specified_UID_and_GID/gshadow b/tests/usertools/01/04_useradd_specified_UID_and_GID/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/04_useradd_specified_UID_and_GID/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/04_useradd_specified_UID_and_GID/passwd b/tests/usertools/01/04_useradd_specified_UID_and_GID/passwd new file mode 100644 index 00000000..2603e1ec --- /dev/null +++ b/tests/usertools/01/04_useradd_specified_UID_and_GID/passwd @@ -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 +test1:x:4242:4242::/home/test1:/bin/sh +test2:x:4242:4242::/home/test2:/bin/sh diff --git a/tests/usertools/01/04_useradd_specified_UID_and_GID/shadow b/tests/usertools/01/04_useradd_specified_UID_and_GID/shadow new file mode 100644 index 00000000..4c40f478 --- /dev/null +++ b/tests/usertools/01/04_useradd_specified_UID_and_GID/shadow @@ -0,0 +1,21 @@ +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::: +test1:!:@TODAY@:0:99999:7::: +test2:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID.test b/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID.test new file mode 100755 index 00000000..de2a1891 --- /dev/null +++ b/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID.test @@ -0,0 +1,51 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Remove an user with a duplicate ID" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd -u 4242 test1)..." +useradd -u 4242 test1 +echo "OK" +echo -n "Create user test2 with the same ID (useradd -u 4242 -o test2)..." +useradd -u 4242 -o test2 +echo "OK" +echo -n "Delete user test2 (userdel test2)..." +userdel test2 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 04_userdel_delete_user_with_non_unique_UID/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 04_userdel_delete_user_with_non_unique_UID/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 04_userdel_delete_user_with_non_unique_UID/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 04_userdel_delete_user_with_non_unique_UID/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir /home/test1..." +test -d /home/test1 && exit 1 || true +echo "OK" +echo -n "no homedir /home/test2..." +test -d /home/test2 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID/group b/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID/group new file mode 100644 index 00000000..6c7895c6 --- /dev/null +++ b/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID/group @@ -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: +test1:x:4242: diff --git a/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID/gshadow b/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID/passwd b/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID/passwd new file mode 100644 index 00000000..4b6c8085 --- /dev/null +++ b/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID/passwd @@ -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 +test1:x:4242:4242::/home/test1:/bin/sh diff --git a/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID/shadow b/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/04_userdel_delete_user_with_non_unique_UID/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/05_useradd_invalid_numeric_primary_group.test b/tests/usertools/01/05_useradd_invalid_numeric_primary_group.test new file mode 100755 index 00000000..04b4bd03 --- /dev/null +++ b/tests/usertools/01/05_useradd_invalid_numeric_primary_group.test @@ -0,0 +1,58 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user with a specified unexisting GID" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd -g 4242 test1)..." +useradd -g 4242 test1 2>tmp/useradd.err && exit 1 || { + status=$? +} +echo "OK" +echo "OK" +echo "All right, useradd returned error $status." +echo -n "Check returned status..." +test "$status" = "6" +echo "OK" + +echo "useradd displayed:" +echo "=======================================================================" +cat tmp/useradd.err +echo "=======================================================================" +echo -n "Check that there were a failure message..." +diff -au 05_useradd_invalid_numeric_primary_group/useradd.err tmp/useradd.err +echo "error message OK." +rm -f tmp/useradd.err + +echo -n "Check the passwd file..." +../../common/compare_file.pl config/etc/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl config/etc/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl config/etc/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl config/etc/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/05_useradd_invalid_numeric_primary_group/useradd.err b/tests/usertools/01/05_useradd_invalid_numeric_primary_group/useradd.err new file mode 100644 index 00000000..150a30e2 --- /dev/null +++ b/tests/usertools/01/05_useradd_invalid_numeric_primary_group/useradd.err @@ -0,0 +1 @@ +useradd: unknown group 4242 diff --git a/tests/usertools/01/06_useradd_invalid_named_primary_group.test b/tests/usertools/01/06_useradd_invalid_named_primary_group.test new file mode 100755 index 00000000..ea02d5fa --- /dev/null +++ b/tests/usertools/01/06_useradd_invalid_named_primary_group.test @@ -0,0 +1,58 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user with a specified unexisting GID" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1 -g nekral)..." +useradd test1 -g nekral 2>tmp/useradd.err && exit 1 || { + status=$? +} +echo "OK" +echo "OK" +echo "All right, useradd returned error $status." +echo -n "Check returned status..." +test "$status" = "6" +echo "OK" + +echo "useradd displayed:" +echo "=======================================================================" +cat tmp/useradd.err +echo "=======================================================================" +echo -n "Check that there were a failure message..." +diff -au 06_useradd_invalid_named_primary_group/useradd.err tmp/useradd.err +echo "error message OK." +rm -f tmp/useradd.err + +echo -n "Check the passwd file..." +../../common/compare_file.pl config/etc/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl config/etc/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl config/etc/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl config/etc/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/06_useradd_invalid_named_primary_group/useradd.err b/tests/usertools/01/06_useradd_invalid_named_primary_group/useradd.err new file mode 100644 index 00000000..486c42e8 --- /dev/null +++ b/tests/usertools/01/06_useradd_invalid_named_primary_group/useradd.err @@ -0,0 +1 @@ +useradd: unknown group nekral diff --git a/tests/usertools/01/07_useradd_numerical_primary_group.test b/tests/usertools/01/07_useradd_numerical_primary_group.test new file mode 100755 index 00000000..1f1f14c2 --- /dev/null +++ b/tests/usertools/01/07_useradd_numerical_primary_group.test @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user with a numerical GID" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd -g 1 test1)..." +useradd -g 1 test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 07_useradd_numerical_primary_group/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 07_useradd_numerical_primary_group/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 07_useradd_numerical_primary_group/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 07_useradd_numerical_primary_group/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/07_useradd_numerical_primary_group/group b/tests/usertools/01/07_useradd_numerical_primary_group/group new file mode 100644 index 00000000..10123908 --- /dev/null +++ b/tests/usertools/01/07_useradd_numerical_primary_group/group @@ -0,0 +1,41 @@ +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: diff --git a/tests/usertools/01/07_useradd_numerical_primary_group/gshadow b/tests/usertools/01/07_useradd_numerical_primary_group/gshadow new file mode 100644 index 00000000..ae424865 --- /dev/null +++ b/tests/usertools/01/07_useradd_numerical_primary_group/gshadow @@ -0,0 +1,41 @@ +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:: diff --git a/tests/usertools/01/07_useradd_numerical_primary_group/passwd b/tests/usertools/01/07_useradd_numerical_primary_group/passwd new file mode 100644 index 00000000..902efbe4 --- /dev/null +++ b/tests/usertools/01/07_useradd_numerical_primary_group/passwd @@ -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 +test1:x:1000:1::/home/test1:/bin/sh diff --git a/tests/usertools/01/07_useradd_numerical_primary_group/shadow b/tests/usertools/01/07_useradd_numerical_primary_group/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/07_useradd_numerical_primary_group/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/08_useradd_named_primary_group.test b/tests/usertools/01/08_useradd_named_primary_group.test new file mode 100755 index 00000000..d18acdff --- /dev/null +++ b/tests/usertools/01/08_useradd_named_primary_group.test @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user with a named GID" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1 -g nogroup)..." +useradd test1 -g nogroup +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 08_useradd_named_primary_group/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 08_useradd_named_primary_group/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 08_useradd_named_primary_group/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 08_useradd_named_primary_group/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/08_useradd_named_primary_group/group b/tests/usertools/01/08_useradd_named_primary_group/group new file mode 100644 index 00000000..10123908 --- /dev/null +++ b/tests/usertools/01/08_useradd_named_primary_group/group @@ -0,0 +1,41 @@ +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: diff --git a/tests/usertools/01/08_useradd_named_primary_group/gshadow b/tests/usertools/01/08_useradd_named_primary_group/gshadow new file mode 100644 index 00000000..ae424865 --- /dev/null +++ b/tests/usertools/01/08_useradd_named_primary_group/gshadow @@ -0,0 +1,41 @@ +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:: diff --git a/tests/usertools/01/08_useradd_named_primary_group/passwd b/tests/usertools/01/08_useradd_named_primary_group/passwd new file mode 100644 index 00000000..42ef2e26 --- /dev/null +++ b/tests/usertools/01/08_useradd_named_primary_group/passwd @@ -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 +test1:x:1000:65534::/home/test1:/bin/sh diff --git a/tests/usertools/01/08_useradd_named_primary_group/shadow b/tests/usertools/01/08_useradd_named_primary_group/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/08_useradd_named_primary_group/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/09_usermod_change_user_info.test b/tests/usertools/01/09_usermod_change_user_info.test new file mode 100755 index 00000000..75d00b27 --- /dev/null +++ b/tests/usertools/01/09_usermod_change_user_info.test @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Change user information with usermod" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1)..." +useradd test1 +echo "OK" +echo -n "Change user test1..." +usermod -g 1 --comment "comment" -e 2000-09-01 -f 17 -s /bin/bash -d /tmp test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 09_usermod_change_user_info/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 09_usermod_change_user_info/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 09_usermod_change_user_info/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 09_usermod_change_user_info/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/09_usermod_change_user_info/group b/tests/usertools/01/09_usermod_change_user_info/group new file mode 100644 index 00000000..ff319127 --- /dev/null +++ b/tests/usertools/01/09_usermod_change_user_info/group @@ -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: +test1:x:1000: diff --git a/tests/usertools/01/09_usermod_change_user_info/gshadow b/tests/usertools/01/09_usermod_change_user_info/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/09_usermod_change_user_info/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/09_usermod_change_user_info/passwd b/tests/usertools/01/09_usermod_change_user_info/passwd new file mode 100644 index 00000000..60c8e45f --- /dev/null +++ b/tests/usertools/01/09_usermod_change_user_info/passwd @@ -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 +test1:x:1000:1:comment:/tmp:/bin/bash diff --git a/tests/usertools/01/09_usermod_change_user_info/shadow b/tests/usertools/01/09_usermod_change_user_info/shadow new file mode 100644 index 00000000..cf6bc25d --- /dev/null +++ b/tests/usertools/01/09_usermod_change_user_info/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7:17:11201: diff --git a/tests/usertools/01/10_usermod_rename_user.test b/tests/usertools/01/10_usermod_rename_user.test new file mode 100755 index 00000000..202e9b6e --- /dev/null +++ b/tests/usertools/01/10_usermod_rename_user.test @@ -0,0 +1,48 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1)..." +useradd test1 +echo "OK" +echo -n "Rename user test1 to test2 (usermod -l test2 test1)..." +usermod -l test2 test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 10_usermod_rename_user/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 10_usermod_rename_user/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 10_usermod_rename_user/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 10_usermod_rename_user/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir (/home/test1)..." +test -d /home/test1 && exit 1 || true +echo "OK" +echo -n "no homedir (/home/test2)..." +test -d /home/test2 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/10_usermod_rename_user/group b/tests/usertools/01/10_usermod_rename_user/group new file mode 100644 index 00000000..ff319127 --- /dev/null +++ b/tests/usertools/01/10_usermod_rename_user/group @@ -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: +test1:x:1000: diff --git a/tests/usertools/01/10_usermod_rename_user/gshadow b/tests/usertools/01/10_usermod_rename_user/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/10_usermod_rename_user/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/10_usermod_rename_user/passwd b/tests/usertools/01/10_usermod_rename_user/passwd new file mode 100644 index 00000000..0d1ab518 --- /dev/null +++ b/tests/usertools/01/10_usermod_rename_user/passwd @@ -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 +test2:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/10_usermod_rename_user/shadow b/tests/usertools/01/10_usermod_rename_user/shadow new file mode 100644 index 00000000..1ca61d8d --- /dev/null +++ b/tests/usertools/01/10_usermod_rename_user/shadow @@ -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::: +test2:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/10_usermod_rename_user_in_group.test b/tests/usertools/01/10_usermod_rename_user_in_group.test new file mode 100755 index 00000000..374acabc --- /dev/null +++ b/tests/usertools/01/10_usermod_rename_user_in_group.test @@ -0,0 +1,48 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 also in group daemon (useradd test1 -G daemon)..." +useradd test1 -G daemon +echo "OK" +echo -n "Rename user test1 to test2 (usermod -l test2 test1)..." +usermod -l test2 test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 10_usermod_rename_user_in_group/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 10_usermod_rename_user_in_group/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 10_usermod_rename_user_in_group/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 10_usermod_rename_user_in_group/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir (/home/test1)..." +test -d /home/test1 && exit 1 || true +echo "OK" +echo -n "no homedir (/home/test2)..." +test -d /home/test2 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/10_usermod_rename_user_in_group/group b/tests/usertools/01/10_usermod_rename_user_in_group/group new file mode 100644 index 00000000..271a2c34 --- /dev/null +++ b/tests/usertools/01/10_usermod_rename_user_in_group/group @@ -0,0 +1,42 @@ +root:x:0: +daemon:x:1:test2 +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: +test1:x:1000: diff --git a/tests/usertools/01/10_usermod_rename_user_in_group/gshadow b/tests/usertools/01/10_usermod_rename_user_in_group/gshadow new file mode 100644 index 00000000..879d206a --- /dev/null +++ b/tests/usertools/01/10_usermod_rename_user_in_group/gshadow @@ -0,0 +1,42 @@ +root:*:: +daemon:*::test2 +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:: +test1:!:: diff --git a/tests/usertools/01/10_usermod_rename_user_in_group/passwd b/tests/usertools/01/10_usermod_rename_user_in_group/passwd new file mode 100644 index 00000000..0d1ab518 --- /dev/null +++ b/tests/usertools/01/10_usermod_rename_user_in_group/passwd @@ -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 +test2:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/10_usermod_rename_user_in_group/shadow b/tests/usertools/01/10_usermod_rename_user_in_group/shadow new file mode 100644 index 00000000..1ca61d8d --- /dev/null +++ b/tests/usertools/01/10_usermod_rename_user_in_group/shadow @@ -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::: +test2:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/11_usermod_change_password.test b/tests/usertools/01/11_usermod_change_password.test new file mode 100755 index 00000000..a6e7acec --- /dev/null +++ b/tests/usertools/01/11_usermod_change_password.test @@ -0,0 +1,46 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1)..." +useradd test1 +echo "OK" +echo -n "Change user's password..." +usermod -p '$1$12345678$0jEt1CYOyE.5NxWFMZyZy1' test1 +# (test1F00barbaz) +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 11_usermod_change_password/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 11_usermod_change_password/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 11_usermod_change_password/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 11_usermod_change_password/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/11_usermod_change_password/group b/tests/usertools/01/11_usermod_change_password/group new file mode 100644 index 00000000..ff319127 --- /dev/null +++ b/tests/usertools/01/11_usermod_change_password/group @@ -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: +test1:x:1000: diff --git a/tests/usertools/01/11_usermod_change_password/gshadow b/tests/usertools/01/11_usermod_change_password/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/11_usermod_change_password/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/11_usermod_change_password/passwd b/tests/usertools/01/11_usermod_change_password/passwd new file mode 100644 index 00000000..0b4b0fa8 --- /dev/null +++ b/tests/usertools/01/11_usermod_change_password/passwd @@ -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 +test1:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/11_usermod_change_password/shadow b/tests/usertools/01/11_usermod_change_password/shadow new file mode 100644 index 00000000..72025a2a --- /dev/null +++ b/tests/usertools/01/11_usermod_change_password/shadow @@ -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::: +test1:$1$12345678$0jEt1CYOyE.5NxWFMZyZy1:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/11_usermod_lock_password.test b/tests/usertools/01/11_usermod_lock_password.test new file mode 100755 index 00000000..f5e6a9fe --- /dev/null +++ b/tests/usertools/01/11_usermod_lock_password.test @@ -0,0 +1,49 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1)..." +useradd test1 +echo "OK" +echo -n "Change user's password..." +usermod -p '$1$12345678$0jEt1CYOyE.5NxWFMZyZy1' test1 +# (test1F00barbaz) +echo "OK" +echo -n "Lock user's password..." +usermod -L test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 11_usermod_lock_password/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 11_usermod_lock_password/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 11_usermod_lock_password/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 11_usermod_lock_password/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/11_usermod_lock_password/group b/tests/usertools/01/11_usermod_lock_password/group new file mode 100644 index 00000000..ff319127 --- /dev/null +++ b/tests/usertools/01/11_usermod_lock_password/group @@ -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: +test1:x:1000: diff --git a/tests/usertools/01/11_usermod_lock_password/gshadow b/tests/usertools/01/11_usermod_lock_password/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/11_usermod_lock_password/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/11_usermod_lock_password/passwd b/tests/usertools/01/11_usermod_lock_password/passwd new file mode 100644 index 00000000..0b4b0fa8 --- /dev/null +++ b/tests/usertools/01/11_usermod_lock_password/passwd @@ -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 +test1:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/11_usermod_lock_password/shadow b/tests/usertools/01/11_usermod_lock_password/shadow new file mode 100644 index 00000000..5a236b74 --- /dev/null +++ b/tests/usertools/01/11_usermod_lock_password/shadow @@ -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::: +test1:!$1$12345678$0jEt1CYOyE.5NxWFMZyZy1:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/11_usermod_unlock_empty_password.test b/tests/usertools/01/11_usermod_unlock_empty_password.test new file mode 100755 index 00000000..d12dfd8f --- /dev/null +++ b/tests/usertools/01/11_usermod_unlock_empty_password.test @@ -0,0 +1,54 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1)..." +useradd test1 +echo "OK" +echo -n "Unlock user's password..." +usermod -U test1 2>tmp/err +echo "OK" + +echo "usermod displayed:" +echo "=======================================================================" +cat tmp/err +echo "=======================================================================" +echo -n "Check that there were a failure message..." +diff -au 11_usermod_unlock_empty_password/usermod.err tmp/err +echo "error message OK." +rm -f tmp/err + +echo -n "Check the passwd file..." +../../common/compare_file.pl 11_usermod_unlock_empty_password/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 11_usermod_unlock_empty_password/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 11_usermod_unlock_empty_password/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 11_usermod_unlock_empty_password/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/11_usermod_unlock_empty_password/group b/tests/usertools/01/11_usermod_unlock_empty_password/group new file mode 100644 index 00000000..ff319127 --- /dev/null +++ b/tests/usertools/01/11_usermod_unlock_empty_password/group @@ -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: +test1:x:1000: diff --git a/tests/usertools/01/11_usermod_unlock_empty_password/gshadow b/tests/usertools/01/11_usermod_unlock_empty_password/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/11_usermod_unlock_empty_password/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/11_usermod_unlock_empty_password/passwd b/tests/usertools/01/11_usermod_unlock_empty_password/passwd new file mode 100644 index 00000000..0b4b0fa8 --- /dev/null +++ b/tests/usertools/01/11_usermod_unlock_empty_password/passwd @@ -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 +test1:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/11_usermod_unlock_empty_password/shadow b/tests/usertools/01/11_usermod_unlock_empty_password/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/11_usermod_unlock_empty_password/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/11_usermod_unlock_empty_password/usermod.err b/tests/usertools/01/11_usermod_unlock_empty_password/usermod.err new file mode 100644 index 00000000..8782fc41 --- /dev/null +++ b/tests/usertools/01/11_usermod_unlock_empty_password/usermod.err @@ -0,0 +1,2 @@ +usermod: unlocking the user would result in a passwordless account. +You should set a password with usermod -p to unlock this user account. diff --git a/tests/usertools/01/11_usermod_unlock_password.test b/tests/usertools/01/11_usermod_unlock_password.test new file mode 100755 index 00000000..905b2c03 --- /dev/null +++ b/tests/usertools/01/11_usermod_unlock_password.test @@ -0,0 +1,52 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1)..." +useradd test1 +echo "OK" +echo -n "Change user's password..." +usermod -p '$1$12345678$0jEt1CYOyE.5NxWFMZyZy1' test1 +# (test1F00barbaz) +echo "OK" +echo -n "Lock user's password..." +usermod -L test1 +echo "OK" +echo -n "Unlock user's password..." +usermod -U test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 11_usermod_unlock_password/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 11_usermod_unlock_password/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 11_usermod_unlock_password/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 11_usermod_unlock_password/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/11_usermod_unlock_password/group b/tests/usertools/01/11_usermod_unlock_password/group new file mode 100644 index 00000000..ff319127 --- /dev/null +++ b/tests/usertools/01/11_usermod_unlock_password/group @@ -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: +test1:x:1000: diff --git a/tests/usertools/01/11_usermod_unlock_password/gshadow b/tests/usertools/01/11_usermod_unlock_password/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/11_usermod_unlock_password/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/11_usermod_unlock_password/passwd b/tests/usertools/01/11_usermod_unlock_password/passwd new file mode 100644 index 00000000..0b4b0fa8 --- /dev/null +++ b/tests/usertools/01/11_usermod_unlock_password/passwd @@ -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 +test1:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/11_usermod_unlock_password/shadow b/tests/usertools/01/11_usermod_unlock_password/shadow new file mode 100644 index 00000000..72025a2a --- /dev/null +++ b/tests/usertools/01/11_usermod_unlock_password/shadow @@ -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::: +test1:$1$12345678$0jEt1CYOyE.5NxWFMZyZy1:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/12_usermod_change_gid_name.test b/tests/usertools/01/12_usermod_change_gid_name.test new file mode 100755 index 00000000..81481494 --- /dev/null +++ b/tests/usertools/01/12_usermod_change_gid_name.test @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1)..." +useradd test1 +echo "OK" +echo -n "Change user's group..." +usermod -g daemon test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 12_usermod_change_gid_name/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 12_usermod_change_gid_name/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 12_usermod_change_gid_name/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 12_usermod_change_gid_name/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/12_usermod_change_gid_name/group b/tests/usertools/01/12_usermod_change_gid_name/group new file mode 100644 index 00000000..ff319127 --- /dev/null +++ b/tests/usertools/01/12_usermod_change_gid_name/group @@ -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: +test1:x:1000: diff --git a/tests/usertools/01/12_usermod_change_gid_name/gshadow b/tests/usertools/01/12_usermod_change_gid_name/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/12_usermod_change_gid_name/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/12_usermod_change_gid_name/passwd b/tests/usertools/01/12_usermod_change_gid_name/passwd new file mode 100644 index 00000000..902efbe4 --- /dev/null +++ b/tests/usertools/01/12_usermod_change_gid_name/passwd @@ -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 +test1:x:1000:1::/home/test1:/bin/sh diff --git a/tests/usertools/01/12_usermod_change_gid_name/shadow b/tests/usertools/01/12_usermod_change_gid_name/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/12_usermod_change_gid_name/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/12_usermod_change_gid_number.test b/tests/usertools/01/12_usermod_change_gid_number.test new file mode 100755 index 00000000..e4172a8a --- /dev/null +++ b/tests/usertools/01/12_usermod_change_gid_number.test @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1)..." +useradd test1 +echo "OK" +echo -n "Change user's group..." +usermod -g 1 test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 12_usermod_change_gid_number/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 12_usermod_change_gid_number/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 12_usermod_change_gid_number/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 12_usermod_change_gid_number/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/12_usermod_change_gid_number/group b/tests/usertools/01/12_usermod_change_gid_number/group new file mode 100644 index 00000000..ff319127 --- /dev/null +++ b/tests/usertools/01/12_usermod_change_gid_number/group @@ -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: +test1:x:1000: diff --git a/tests/usertools/01/12_usermod_change_gid_number/gshadow b/tests/usertools/01/12_usermod_change_gid_number/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/12_usermod_change_gid_number/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/12_usermod_change_gid_number/passwd b/tests/usertools/01/12_usermod_change_gid_number/passwd new file mode 100644 index 00000000..902efbe4 --- /dev/null +++ b/tests/usertools/01/12_usermod_change_gid_number/passwd @@ -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 +test1:x:1000:1::/home/test1:/bin/sh diff --git a/tests/usertools/01/12_usermod_change_gid_number/shadow b/tests/usertools/01/12_usermod_change_gid_number/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/12_usermod_change_gid_number/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/13_useradd_negative_UID.test b/tests/usertools/01/13_useradd_negative_UID.test new file mode 100755 index 00000000..9e4b012b --- /dev/null +++ b/tests/usertools/01/13_useradd_negative_UID.test @@ -0,0 +1,52 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 with a negative UID (useradd -u -1 test1)..." +msg=$(useradd -u -1 test1 2>&1) && exit 1 || { + status=$? +} +echo "OK" +echo "useradd returned status $status," +echo "and displayed \"$msg\"" +echo -n "The returned status should be 3..." +test "$status" = "3" +echo "OK" +echo -n "Test the error message (should be \"useradd: invalid numeric argument '-1'\")..." +test "$msg" = "useradd: invalid numeric argument '-1'" +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 13_useradd_negative_UID/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 13_useradd_negative_UID/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 13_useradd_negative_UID/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 13_useradd_negative_UID/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/13_useradd_negative_UID/group b/tests/usertools/01/13_useradd_negative_UID/group new file mode 100644 index 00000000..10123908 --- /dev/null +++ b/tests/usertools/01/13_useradd_negative_UID/group @@ -0,0 +1,41 @@ +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: diff --git a/tests/usertools/01/13_useradd_negative_UID/gshadow b/tests/usertools/01/13_useradd_negative_UID/gshadow new file mode 100644 index 00000000..ae424865 --- /dev/null +++ b/tests/usertools/01/13_useradd_negative_UID/gshadow @@ -0,0 +1,41 @@ +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:: diff --git a/tests/usertools/01/13_useradd_negative_UID/passwd b/tests/usertools/01/13_useradd_negative_UID/passwd new file mode 100644 index 00000000..43fc135a --- /dev/null +++ b/tests/usertools/01/13_useradd_negative_UID/passwd @@ -0,0 +1,19 @@ +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 diff --git a/tests/usertools/01/13_useradd_negative_UID/shadow b/tests/usertools/01/13_useradd_negative_UID/shadow new file mode 100644 index 00000000..5f50d187 --- /dev/null +++ b/tests/usertools/01/13_useradd_negative_UID/shadow @@ -0,0 +1,19 @@ +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::: diff --git a/tests/usertools/01/14_useradd_out_of_range_UID.test b/tests/usertools/01/14_useradd_out_of_range_UID.test new file mode 100755 index 00000000..2b75d713 --- /dev/null +++ b/tests/usertools/01/14_useradd_out_of_range_UID.test @@ -0,0 +1,52 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 with UID 2147483648 (useradd -u 2147483648 test1)..." +msg=$(useradd -u 2147483648 test1 2>&1) && exit 1 || { + status=$? +} +echo "OK" +echo "useradd returned status $status," +echo "and displayed \"$msg\"" +echo -n "The returned status should be 3..." +test "$status" = "3" +echo "OK" +echo -n "Test the error message (should be \"useradd: invalid numeric argument '2147483648'\")..." +test "$msg" = "useradd: invalid numeric argument '2147483648'" +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 14_useradd_out_of_range_UID/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 14_useradd_out_of_range_UID/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 14_useradd_out_of_range_UID/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 14_useradd_out_of_range_UID/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/14_useradd_out_of_range_UID/group b/tests/usertools/01/14_useradd_out_of_range_UID/group new file mode 100644 index 00000000..10123908 --- /dev/null +++ b/tests/usertools/01/14_useradd_out_of_range_UID/group @@ -0,0 +1,41 @@ +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: diff --git a/tests/usertools/01/14_useradd_out_of_range_UID/gshadow b/tests/usertools/01/14_useradd_out_of_range_UID/gshadow new file mode 100644 index 00000000..ae424865 --- /dev/null +++ b/tests/usertools/01/14_useradd_out_of_range_UID/gshadow @@ -0,0 +1,41 @@ +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:: diff --git a/tests/usertools/01/14_useradd_out_of_range_UID/passwd b/tests/usertools/01/14_useradd_out_of_range_UID/passwd new file mode 100644 index 00000000..43fc135a --- /dev/null +++ b/tests/usertools/01/14_useradd_out_of_range_UID/passwd @@ -0,0 +1,19 @@ +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 diff --git a/tests/usertools/01/14_useradd_out_of_range_UID/shadow b/tests/usertools/01/14_useradd_out_of_range_UID/shadow new file mode 100644 index 00000000..5f50d187 --- /dev/null +++ b/tests/usertools/01/14_useradd_out_of_range_UID/shadow @@ -0,0 +1,19 @@ +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::: diff --git a/tests/usertools/01/15_useradd_specified_large_UID.test b/tests/usertools/01/15_useradd_specified_large_UID.test new file mode 100755 index 00000000..69fd5dbc --- /dev/null +++ b/tests/usertools/01/15_useradd_specified_large_UID.test @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user with a specified ID" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd -u 2147483647 test1)..." +useradd -u 2147483647 test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 15_useradd_specified_large_UID/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 15_useradd_specified_large_UID/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 15_useradd_specified_large_UID/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 15_useradd_specified_large_UID/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/15_useradd_specified_large_UID/group b/tests/usertools/01/15_useradd_specified_large_UID/group new file mode 100644 index 00000000..8494bd0a --- /dev/null +++ b/tests/usertools/01/15_useradd_specified_large_UID/group @@ -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: +test1:x:2147483647: diff --git a/tests/usertools/01/15_useradd_specified_large_UID/gshadow b/tests/usertools/01/15_useradd_specified_large_UID/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/15_useradd_specified_large_UID/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/15_useradd_specified_large_UID/passwd b/tests/usertools/01/15_useradd_specified_large_UID/passwd new file mode 100644 index 00000000..506fe353 --- /dev/null +++ b/tests/usertools/01/15_useradd_specified_large_UID/passwd @@ -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 +test1:x:2147483647:2147483647::/home/test1:/bin/sh diff --git a/tests/usertools/01/15_useradd_specified_large_UID/shadow b/tests/usertools/01/15_useradd_specified_large_UID/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/15_useradd_specified_large_UID/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/16_useradd_add_user_to_multiple_groups.test b/tests/usertools/01/16_useradd_add_user_to_multiple_groups.test new file mode 100755 index 00000000..3e0323e3 --- /dev/null +++ b/tests/usertools/01/16_useradd_add_user_to_multiple_groups.test @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1, and add it to group src (useradd test1 -g src)..." +useradd test1 -g nogroup -G src,daemon,bin +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 16_useradd_add_user_to_multiple_groups/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 16_useradd_add_user_to_multiple_groups/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 16_useradd_add_user_to_multiple_groups/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 16_useradd_add_user_to_multiple_groups/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/16_useradd_add_user_to_multiple_groups/group b/tests/usertools/01/16_useradd_add_user_to_multiple_groups/group new file mode 100644 index 00000000..04d5635c --- /dev/null +++ b/tests/usertools/01/16_useradd_add_user_to_multiple_groups/group @@ -0,0 +1,41 @@ +root:x:0: +daemon:x:1:test1 +bin:x:2:test1 +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:test1 +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: diff --git a/tests/usertools/01/16_useradd_add_user_to_multiple_groups/gshadow b/tests/usertools/01/16_useradd_add_user_to_multiple_groups/gshadow new file mode 100644 index 00000000..1605ab67 --- /dev/null +++ b/tests/usertools/01/16_useradd_add_user_to_multiple_groups/gshadow @@ -0,0 +1,41 @@ +root:*:: +daemon:*::test1 +bin:*::test1 +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:*::test1 +gnats:*:: +shadow:*:: +utmp:*:: +video:*:: +sasl:*:: +plugdev:*:: +staff:*:: +games:*:: +users:*:: +nogroup:*:: +crontab:x:: +Debian-exim:x:: diff --git a/tests/usertools/01/16_useradd_add_user_to_multiple_groups/passwd b/tests/usertools/01/16_useradd_add_user_to_multiple_groups/passwd new file mode 100644 index 00000000..42ef2e26 --- /dev/null +++ b/tests/usertools/01/16_useradd_add_user_to_multiple_groups/passwd @@ -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 +test1:x:1000:65534::/home/test1:/bin/sh diff --git a/tests/usertools/01/16_useradd_add_user_to_multiple_groups/shadow b/tests/usertools/01/16_useradd_add_user_to_multiple_groups/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/16_useradd_add_user_to_multiple_groups/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/16_useradd_add_user_to_one_group.test b/tests/usertools/01/16_useradd_add_user_to_one_group.test new file mode 100755 index 00000000..38c0020d --- /dev/null +++ b/tests/usertools/01/16_useradd_add_user_to_one_group.test @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1, and add it to group src (useradd test1 -g src)..." +useradd test1 -G src +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 16_useradd_add_user_to_one_group/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 16_useradd_add_user_to_one_group/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 16_useradd_add_user_to_one_group/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 16_useradd_add_user_to_one_group/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/16_useradd_add_user_to_one_group/group b/tests/usertools/01/16_useradd_add_user_to_one_group/group new file mode 100644 index 00000000..1c6668ee --- /dev/null +++ b/tests/usertools/01/16_useradd_add_user_to_one_group/group @@ -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:test1 +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: +test1:x:1000: diff --git a/tests/usertools/01/16_useradd_add_user_to_one_group/gshadow b/tests/usertools/01/16_useradd_add_user_to_one_group/gshadow new file mode 100644 index 00000000..680a5dc0 --- /dev/null +++ b/tests/usertools/01/16_useradd_add_user_to_one_group/gshadow @@ -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:*::test1 +gnats:*:: +shadow:*:: +utmp:*:: +video:*:: +sasl:*:: +plugdev:*:: +staff:*:: +games:*:: +users:*:: +nogroup:*:: +crontab:x:: +Debian-exim:x:: +test1:!:: diff --git a/tests/usertools/01/16_useradd_add_user_to_one_group/passwd b/tests/usertools/01/16_useradd_add_user_to_one_group/passwd new file mode 100644 index 00000000..0b4b0fa8 --- /dev/null +++ b/tests/usertools/01/16_useradd_add_user_to_one_group/passwd @@ -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 +test1:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/16_useradd_add_user_to_one_group/shadow b/tests/usertools/01/16_useradd_add_user_to_one_group/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/16_useradd_add_user_to_one_group/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/17_useradd_create_homedir.test b/tests/usertools/01/17_useradd_create_homedir.test new file mode 100755 index 00000000..cf271409 --- /dev/null +++ b/tests/usertools/01/17_useradd_create_homedir.test @@ -0,0 +1,46 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 with homedir (useradd --create-home test1)..." +useradd --create-home test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 01_useradd_add_user/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 01_useradd_add_user/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 01_useradd_add_user/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 01_useradd_add_user/gshadow /etc/gshadow +echo "OK" +echo -n "homedir created..." +test -d /home/test1 +echo "OK" +echo -n "Check if skeleton files were added..." +diff -rauN /etc/skel /home/test1 +echo "OK" +rm -rf /home/test1 + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/17_useradd_create_homedir/group b/tests/usertools/01/17_useradd_create_homedir/group new file mode 100644 index 00000000..ff319127 --- /dev/null +++ b/tests/usertools/01/17_useradd_create_homedir/group @@ -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: +test1:x:1000: diff --git a/tests/usertools/01/17_useradd_create_homedir/gshadow b/tests/usertools/01/17_useradd_create_homedir/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/17_useradd_create_homedir/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/17_useradd_create_homedir/passwd b/tests/usertools/01/17_useradd_create_homedir/passwd new file mode 100644 index 00000000..0b4b0fa8 --- /dev/null +++ b/tests/usertools/01/17_useradd_create_homedir/passwd @@ -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 +test1:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/17_useradd_create_homedir/shadow b/tests/usertools/01/17_useradd_create_homedir/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/17_useradd_create_homedir/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/18_userdel_remove_homedir.test b/tests/usertools/01/18_userdel_remove_homedir.test new file mode 100755 index 00000000..f7eee9b6 --- /dev/null +++ b/tests/usertools/01/18_userdel_remove_homedir.test @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 with homedir (useradd --create-home test1)..." +useradd --create-home test1 +echo "OK" +echo -n "Delete user test1 with homedir (userdel --remove test1)..." +userdel --remove test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl config/etc/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl config/etc/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl config/etc/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl config/etc/gshadow /etc/gshadow +echo "OK" +echo -n "homedir removed..." +test ! -d /home/test1 +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/18_userdel_remove_homedir/group b/tests/usertools/01/18_userdel_remove_homedir/group new file mode 100644 index 00000000..ff319127 --- /dev/null +++ b/tests/usertools/01/18_userdel_remove_homedir/group @@ -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: +test1:x:1000: diff --git a/tests/usertools/01/18_userdel_remove_homedir/gshadow b/tests/usertools/01/18_userdel_remove_homedir/gshadow new file mode 100644 index 00000000..90e8eacc --- /dev/null +++ b/tests/usertools/01/18_userdel_remove_homedir/gshadow @@ -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:: +test1:!:: diff --git a/tests/usertools/01/18_userdel_remove_homedir/passwd b/tests/usertools/01/18_userdel_remove_homedir/passwd new file mode 100644 index 00000000..0b4b0fa8 --- /dev/null +++ b/tests/usertools/01/18_userdel_remove_homedir/passwd @@ -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 +test1:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/18_userdel_remove_homedir/shadow b/tests/usertools/01/18_userdel_remove_homedir/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/18_userdel_remove_homedir/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/19_userdel_delete_user_in_group.test b/tests/usertools/01/19_userdel_delete_user_in_group.test new file mode 100755 index 00000000..77878999 --- /dev/null +++ b/tests/usertools/01/19_userdel_delete_user_in_group.test @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Delete user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 and add it to groups daemon and bin (useradd test1 -G daemon,bin)..." +useradd test1 -G daemon,bin +echo "OK" +echo -n "Delete user test1 (userdel test1)..." +userdel test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl config/etc/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl config/etc/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl config/etc/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl config/etc/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/20_usermod_change_homedir.test b/tests/usertools/01/20_usermod_change_homedir.test new file mode 100755 index 00000000..6ef6e8ff --- /dev/null +++ b/tests/usertools/01/20_usermod_change_homedir.test @@ -0,0 +1,58 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Delete user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 and its homedir (useradd test1 -m)..." +useradd test1 -m +echo "OK" +echo -n "Change the user's homedir (usermod --home /home/test1.new test1)..." +usermod --home /home/test1.new test1 +echo "OK" +echo -n "Test if the new homedir was not created..." +test ! -d /home/test1.new +echo "OK" +echo -n "test if the old homedir was kept..." +test -d /home/test1 +echo "OK" +echo -n "Delete user test1 (userdel test1)..." +userdel test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl config/etc/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl config/etc/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl config/etc/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl config/etc/gshadow /etc/gshadow +echo "OK" +echo -n "old homedir kept (/home/test1)..." +test -d /home/test1 +echo "OK" +echo -n "no homedir (/home/test1.new)..." +test ! -d /home/test1.new +echo "OK" +rm -rf /home/test1 + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/21_usermod_change_and_move_homedir.test b/tests/usertools/01/21_usermod_change_and_move_homedir.test new file mode 100755 index 00000000..2db99070 --- /dev/null +++ b/tests/usertools/01/21_usermod_change_and_move_homedir.test @@ -0,0 +1,57 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Delete user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 and its homedir (useradd test1 -m)..." +useradd test1 -m +echo "OK" +echo -n "Change the user's homedir (usermod -m --home /home/test1.new test1)..." +usermod -m --home /home/test1.new test1 +echo "OK" +echo -n "Test if the new homedir exists..." +test -d /home/test1.new +echo "OK" +echo -n "test if the old homedir was removed..." +test ! -d /home/test1 +echo "OK" +echo -n "Delete user test1 (userdel test1)..." +userdel test1 --remove +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl config/etc/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl config/etc/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl config/etc/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl config/etc/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir (/home/test1)..." +test ! -d /home/test1 +echo "OK" +echo -n "no homedir (/home/test1.new)..." +test ! -d /home/test1.new +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/22_usermod_new_groups.test b/tests/usertools/01/22_usermod_new_groups.test new file mode 100755 index 00000000..2cbdfa28 --- /dev/null +++ b/tests/usertools/01/22_usermod_new_groups.test @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 (useradd test1)..." +useradd test1 +echo "OK" +echo -n "Add test1 to groups nogroup, daemon, and src..." +usermod -G nogroup,daemon,src test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 22_usermod_new_groups/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 22_usermod_new_groups/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 22_usermod_new_groups/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 22_usermod_new_groups/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/22_usermod_new_groups/group b/tests/usertools/01/22_usermod_new_groups/group new file mode 100644 index 00000000..e529520f --- /dev/null +++ b/tests/usertools/01/22_usermod_new_groups/group @@ -0,0 +1,42 @@ +root:x:0: +daemon:x:1:test1 +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:test1 +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:test1 +crontab:x:101: +Debian-exim:x:102: +test1:x:1000: diff --git a/tests/usertools/01/22_usermod_new_groups/gshadow b/tests/usertools/01/22_usermod_new_groups/gshadow new file mode 100644 index 00000000..87749e3b --- /dev/null +++ b/tests/usertools/01/22_usermod_new_groups/gshadow @@ -0,0 +1,42 @@ +root:*:: +daemon:*::test1 +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:*::test1 +gnats:*:: +shadow:*:: +utmp:*:: +video:*:: +sasl:*:: +plugdev:*:: +staff:*:: +games:*:: +users:*:: +nogroup:*::test1 +crontab:x:: +Debian-exim:x:: +test1:!:: diff --git a/tests/usertools/01/22_usermod_new_groups/passwd b/tests/usertools/01/22_usermod_new_groups/passwd new file mode 100644 index 00000000..0b4b0fa8 --- /dev/null +++ b/tests/usertools/01/22_usermod_new_groups/passwd @@ -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 +test1:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/22_usermod_new_groups/shadow b/tests/usertools/01/22_usermod_new_groups/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/22_usermod_new_groups/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/23_usermod_add_groups.test b/tests/usertools/01/23_usermod_add_groups.test new file mode 100755 index 00000000..754bdd4d --- /dev/null +++ b/tests/usertools/01/23_usermod_add_groups.test @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 and add it to group bin (useradd test1 -G bin)..." +useradd test1 -G bin +echo "OK" +echo -n "Add test1 to the additional groups nogroup, daemon, and src..." +usermod -a -G nogroup,daemon,src test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 23_usermod_add_groups/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 23_usermod_add_groups/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 23_usermod_add_groups/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 23_usermod_add_groups/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/23_usermod_add_groups/group b/tests/usertools/01/23_usermod_add_groups/group new file mode 100644 index 00000000..09243ddc --- /dev/null +++ b/tests/usertools/01/23_usermod_add_groups/group @@ -0,0 +1,42 @@ +root:x:0: +daemon:x:1:test1 +bin:x:2:test1 +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:test1 +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:test1 +crontab:x:101: +Debian-exim:x:102: +test1:x:1000: diff --git a/tests/usertools/01/23_usermod_add_groups/gshadow b/tests/usertools/01/23_usermod_add_groups/gshadow new file mode 100644 index 00000000..a572a196 --- /dev/null +++ b/tests/usertools/01/23_usermod_add_groups/gshadow @@ -0,0 +1,42 @@ +root:*:: +daemon:*::test1 +bin:*::test1 +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:*::test1 +gnats:*:: +shadow:*:: +utmp:*:: +video:*:: +sasl:*:: +plugdev:*:: +staff:*:: +games:*:: +users:*:: +nogroup:*::test1 +crontab:x:: +Debian-exim:x:: +test1:!:: diff --git a/tests/usertools/01/23_usermod_add_groups/passwd b/tests/usertools/01/23_usermod_add_groups/passwd new file mode 100644 index 00000000..0b4b0fa8 --- /dev/null +++ b/tests/usertools/01/23_usermod_add_groups/passwd @@ -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 +test1:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/23_usermod_add_groups/shadow b/tests/usertools/01/23_usermod_add_groups/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/23_usermod_add_groups/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/24_usermod_new_groups_remove_old_groups.test b/tests/usertools/01/24_usermod_new_groups_remove_old_groups.test new file mode 100755 index 00000000..6b217c68 --- /dev/null +++ b/tests/usertools/01/24_usermod_new_groups_remove_old_groups.test @@ -0,0 +1,45 @@ +#!/bin/sh + +set -e + +cd $(dirname $0) + +. ../../common/config.sh +. ../../common/log.sh + +log_start "$0" "Add a new user" + +save_config + +# restore the files on exit +trap 'log_status "$0" "FAILURE"; restore_config' 0 + +change_config + +echo -n "Create user test1 and add it to group bin (useradd test1 -G bin)..." +useradd test1 -G bin +echo "OK" +echo -n "Change the groups of test1 to nogroup, daemon, and src..." +usermod -G nogroup,daemon,src test1 +echo "OK" + +echo -n "Check the passwd file..." +../../common/compare_file.pl 24_usermod_new_groups_remove_old_groups/passwd /etc/passwd +echo "OK" +echo -n "Check the group file..." +../../common/compare_file.pl 24_usermod_new_groups_remove_old_groups/group /etc/group +echo "OK" +echo -n "Check the shadow file..." +../../common/compare_file.pl 24_usermod_new_groups_remove_old_groups/shadow /etc/shadow +echo "OK" +echo -n "Check the gshadow file..." +../../common/compare_file.pl 24_usermod_new_groups_remove_old_groups/gshadow /etc/gshadow +echo "OK" +echo -n "no homedir..." +test -d /home/test1 && exit 1 || true +echo "OK" + +log_status "$0" "SUCCESS" +restore_config +trap '' 0 + diff --git a/tests/usertools/01/24_usermod_new_groups_remove_old_groups/group b/tests/usertools/01/24_usermod_new_groups_remove_old_groups/group new file mode 100644 index 00000000..e529520f --- /dev/null +++ b/tests/usertools/01/24_usermod_new_groups_remove_old_groups/group @@ -0,0 +1,42 @@ +root:x:0: +daemon:x:1:test1 +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:test1 +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:test1 +crontab:x:101: +Debian-exim:x:102: +test1:x:1000: diff --git a/tests/usertools/01/24_usermod_new_groups_remove_old_groups/gshadow b/tests/usertools/01/24_usermod_new_groups_remove_old_groups/gshadow new file mode 100644 index 00000000..87749e3b --- /dev/null +++ b/tests/usertools/01/24_usermod_new_groups_remove_old_groups/gshadow @@ -0,0 +1,42 @@ +root:*:: +daemon:*::test1 +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:*::test1 +gnats:*:: +shadow:*:: +utmp:*:: +video:*:: +sasl:*:: +plugdev:*:: +staff:*:: +games:*:: +users:*:: +nogroup:*::test1 +crontab:x:: +Debian-exim:x:: +test1:!:: diff --git a/tests/usertools/01/24_usermod_new_groups_remove_old_groups/passwd b/tests/usertools/01/24_usermod_new_groups_remove_old_groups/passwd new file mode 100644 index 00000000..0b4b0fa8 --- /dev/null +++ b/tests/usertools/01/24_usermod_new_groups_remove_old_groups/passwd @@ -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 +test1:x:1000:1000::/home/test1:/bin/sh diff --git a/tests/usertools/01/24_usermod_new_groups_remove_old_groups/shadow b/tests/usertools/01/24_usermod_new_groups_remove_old_groups/shadow new file mode 100644 index 00000000..5920e12b --- /dev/null +++ b/tests/usertools/01/24_usermod_new_groups_remove_old_groups/shadow @@ -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::: +test1:!:@TODAY@:0:99999:7::: diff --git a/tests/usertools/01/run1 b/tests/usertools/01/run1 deleted file mode 100755 index c331ce08..00000000 --- a/tests/usertools/01/run1 +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test that useradd can add an user and userdel removes it. - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -echo -n "Create user test1..." -useradd test1 -echo "OK" - -echo "test if the user was added" -echo -n " passwd..." -getent passwd test1 | - egrep "^test1:x:([0-9]+):\\1::/home/test1:/bin/sh$" -echo " OK" -uid=$(getent passwd test1|sed -ne "s/test1:x:\([0-9]*\):.*/\\1/p") -# uid must be greater than UID_MIN (in login.defs) -echo -n " uid: $uid < 1000..." -test $uid -ge 1000 -echo " OK" -echo -n " group..." -getent group test1 | egrep "^test1:x:$uid:$" -echo " OK" -echo -n " shadow..." -getent shadow test1 | egrep "^test1:!:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " gshadow..." -egrep "^test1:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - -echo -n "delete this user..." -userdel test1 -echo "OK" - -echo "check if the user was deleted" -echo -n " no entries..." -egrep "^test1:" \ - /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true -echo " OK" -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $lines_passwd = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $lines_group = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $lines_shadow = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $lines_gshadow = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - diff --git a/tests/usertools/01/run10 b/tests/usertools/01/run10 deleted file mode 100755 index d3fd6c5b..00000000 --- a/tests/usertools/01/run10 +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Check that usermod can rename an user - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -echo -n "Create user test1..." -useradd test1 -echo "OK" - -uid=$(getent passwd test1|sed -ne "s/test1:x:\([0-9]*\):.*/\\1/p") - -echo -n "Rename user test1..." -usermod -l test2 test1 -echo "OK" - -echo "test if the user was changed" -echo -n " passwd no user test1..." -getent passwd test1 && exit 1 || true -echo " OK" -echo -n " passwd user test2..." -getent passwd test2 | - egrep "^test2:x:$uid:$uid::/home/test1:/bin/sh$" -echo " OK" -echo -n " group..." -getent group test1 | egrep "^test1:x:$uid:$" -echo " OK" -echo -n " shadow no user test1..." -getent shadow test1 && exit 1 || true -echo " OK" -echo -n " shadow user test2..." -getent shadow test2 | egrep "^test2:!:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " gshadow..." -egrep "^test1:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - diff --git a/tests/usertools/01/run11 b/tests/usertools/01/run11 deleted file mode 100755 index 71430e63..00000000 --- a/tests/usertools/01/run11 +++ /dev/null @@ -1,147 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Check that usermod can change, lock or unlock an user's password - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -echo -n "Create user test1..." -useradd test1 -echo "OK" - -uid=$(getent passwd test1|sed -ne "s/test1:x:\([0-9]*\):.*/\\1/p") - -echo -n "Change user's password..." -usermod -p '$1$12345678$0jEt1CYOyE.5NxWFMZyZy1' test1 -# (test1F00barbaz) -echo "OK" - -echo "test if the user was changed" -echo -n " passwd..." -getent passwd test1 | - egrep "^test1:x:$uid:$uid::/home/test1:/bin/sh$" -echo " OK" -echo -n " group..." -getent group test1 | egrep "^test1:x:$uid:$" -echo " OK" -echo -n " shadow..." -getent shadow test1 | egrep "^test1:\\\$1\\\$12345678\\\$0jEt1CYOyE\.5NxWFMZyZy1:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " gshadow..." -egrep "^test1:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - -echo -n "Lock user's password..." -usermod -L test1 -echo "OK" - -echo "test if the user was changed" -echo -n " passwd..." -getent passwd test1 | - egrep "^test1:x:$uid:$uid::/home/test1:/bin/sh$" -echo " OK" -echo -n " group..." -getent group test1 | egrep "^test1:x:$uid:$" -echo " OK" -echo -n " shadow..." -getent shadow test1 | egrep "^test1:\!\\\$1\\\$12345678\\\$0jEt1CYOyE\.5NxWFMZyZy1:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " gshadow..." -egrep "^test1:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - -echo -n "Unlock user's password..." -usermod --unlock test1 -echo "OK" - -echo "test if the user was changed" -echo -n " passwd..." -getent passwd test1 | - egrep "^test1:x:$uid:$uid::/home/test1:/bin/sh$" -echo " OK" -echo -n " group..." -getent group test1 | egrep "^test1:x:$uid:$" -echo " OK" -echo -n " shadow..." -getent shadow test1 | egrep "^test1:\\\$1\\\$12345678\\\$0jEt1CYOyE\.5NxWFMZyZy1:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " gshadow..." -egrep "^test1:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - diff --git a/tests/usertools/01/run12 b/tests/usertools/01/run12 deleted file mode 100755 index 81e79b6f..00000000 --- a/tests/usertools/01/run12 +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test that usermod can change the group of an user -# (-g with non-numerical GID) - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -echo -n "Create user test1..." -useradd test1 -echo "OK" - -uid=$(getent passwd test1|sed -ne "s/test1:x:\([0-9]*\):.*/\\1/p") - -echo -n "Change user test1..." -usermod -g bin test1 -echo "OK" - -echo "test if the user was changed" -echo -n " passwd..." -getent passwd test1 | - egrep "^test1:x:$uid:2::/home/test1:/bin/sh$" -echo " OK" -echo -n " group..." -getent group test1 | egrep "^test1:x:$uid:$" -echo " OK" -echo -n " shadow..." -getent shadow test1 | egrep "^test1:!:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " gshadow..." -egrep "^test1:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - diff --git a/tests/usertools/01/run13 b/tests/usertools/01/run13 deleted file mode 100755 index b0cb7809..00000000 --- a/tests/usertools/01/run13 +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test that useradd do not accept negative UID - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -echo -n "Create user test1 with a negative UID..." -msg=$(useradd -u -1 test1 2>&1) && exit 1 || test "$?" = "3" -test "$msg" = "useradd: invalid numeric argument '-1'" -echo "OK" - -echo "check that the user was not added" -echo -n " passwd..." -getent passwd test1 && exit 1 || true -echo " OK" -echo -n " group..." -getent group test1 && exit 1 || true -echo " OK" -echo -n " shadow..." -getent shadow test1 && exit 1 || true -echo " OK" -echo -n " gshadow..." -egrep "^test1:!::$" /etc/gshadow && exit 1 || true -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - diff --git a/tests/usertools/01/run14 b/tests/usertools/01/run14 deleted file mode 100755 index 22b7a457..00000000 --- a/tests/usertools/01/run14 +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test that useradd do not accept UID that will cause overflow - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -echo -n "Create user test1 with UID 2147483648..." -msg=$(useradd -u 2147483648 test1 2>&1) && exit 1 || test "$?" = "3" -test "$msg" = "useradd: invalid numeric argument '2147483648'" -echo "OK" - -echo "check that the user was not added" -echo -n " passwd..." -getent passwd test1 && exit 1 || true -echo " OK" -echo -n " group..." -getent group test1 && exit 1 || true -echo " OK" -echo -n " shadow..." -getent shadow test1 && exit 1 || true -echo " OK" -echo -n " gshadow..." -egrep "^test1:!::$" /etc/gshadow && exit 1 || true -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - diff --git a/tests/usertools/01/run15 b/tests/usertools/01/run15 deleted file mode 100755 index 9d40edc2..00000000 --- a/tests/usertools/01/run15 +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test that useradd can add an user with an high UID - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -echo -n "Create user test1..." -uid=2147483647 -useradd -u $uid test1 -echo "OK" - -echo "test if the user was added" -echo -n " passwd..." -getent passwd test1 | - egrep "^test1:x:$uid:$uid::/home/test1:/bin/sh$" -echo " OK" -echo -n " group..." -getent group test1 | egrep "^test1:x:$uid:$" -echo " OK" -echo -n " shadow..." -getent shadow test1 | egrep "^test1:!:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " gshadow..." -egrep "^test1:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - -echo -n "delete this user..." -userdel test1 -echo "OK" - -echo "check if the user was deleted" -echo -n " no entries..." -egrep "^test1:" \ - /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true -echo " OK" -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $lines_passwd = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $lines_group = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $lines_shadow = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $lines_gshadow = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - diff --git a/tests/usertools/01/run2 b/tests/usertools/01/run2 deleted file mode 100755 index 3f0d486e..00000000 --- a/tests/usertools/01/run2 +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test that if a user is created, removed and another user is created, the -# UID of the first user is reused. - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -echo -n "Create user test1..." -useradd test1 -echo "OK" - -echo "test if the user was added" -echo -n " passwd..." -getent passwd test1 | - egrep "^test1:x:([0-9]+):\\1::/home/test1:/bin/sh$" -echo " OK" -uid=$(getent passwd test1|sed -ne "s/test1:x:\([0-9]*\):.*/\\1/p") -# uid must be greater than UID_MIN (in login.defs) -echo -n " uid: $uid < 1000..." -test $uid -ge 1000 -echo " OK" -echo -n " group..." -getent group test1 | egrep "^test1:x:$uid:$" -echo " OK" -echo -n " shadow..." -getent shadow test1 | egrep "^test1:!:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " gshadow..." -egrep "^test1:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - -echo -n "delete this user..." -userdel test1 -echo "OK" - -echo "check if the user was deleted" -echo -n " no entries..." -egrep "^test1:" \ - /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true -echo " OK" -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $lines_passwd = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $lines_group = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $lines_shadow = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $lines_gshadow = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - -echo -n "Create user test2..." -useradd test2 -echo "OK" - -echo "test if the user was added with the same uid" -echo -n " passwd..." -getent passwd test2 | - egrep "^test2:x:$uid:$uid::/home/test2:/bin/sh$" -echo " OK" -echo -n " group..." -getent group test2 | egrep "^test2:x:$uid:$" -echo " OK" -echo -n " shadow..." -getent shadow test2 | egrep "^test2:!:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " gshadow..." -egrep "^test2:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test2 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - -echo -n "delete this user..." -userdel test2 -echo "OK" - -echo "check if the user was deleted" -echo -n " no entries..." -egrep "^test2:" \ - /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true -echo " OK" -echo -n " no homedir..." -test -d /home/test2 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $lines_passwd = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $lines_group = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $lines_shadow = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $lines_gshadow = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - diff --git a/tests/usertools/01/run3 b/tests/usertools/01/run3 deleted file mode 100755 index 36d6ef3e..00000000 --- a/tests/usertools/01/run3 +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test the options used to provide information on the user -# (--comment, --expiredate, --shell, --inactive, --home-dir) - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -echo -n "Create user test3, using options..." -useradd --comment "comment test3" \ - --expiredate "2006-02-04" \ - --shell "/bin/bash" \ - --inactive "12" \ - --home-dir "/nonexistenthomedir" \ - test3 -echo "OK" - -echo "test if the user was added with the same uid" -echo -n " passwd..." -getent passwd test3 | - egrep "^test3:x:([0-9]+):\\1:comment test3:/nonexistenthomedir:/bin/bash$" -echo " OK" -uid=$(getent passwd test3|sed -ne "s/test3:x:\([0-9]*\):.*/\\1/p") -# uid must be greater than UID_MIN (in login.defs) -echo -n " uid: $uid < 1000..." -test $uid -ge 1000 -echo -n " group..." -getent group test3 | egrep "^test3:x:$uid:$" -echo " OK" -echo -n " shadow..." -getent shadow test3 | egrep "^test3:!:[0-9]+:0:99999:7:12:13183:$" -echo " OK" -echo -n " gshadow..." -egrep "^test3:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test3 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - -echo -n "delete this user..." -userdel test3 -echo "OK" - -echo "check if the user was deleted" -echo -n " no entries..." -egrep "^test3:" \ - /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true -echo " OK" -echo -n " no homedir..." -test -d /home/test3 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $lines_passwd = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $lines_group = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $lines_shadow = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $lines_gshadow = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - diff --git a/tests/usertools/01/run4 b/tests/usertools/01/run4 deleted file mode 100755 index 84373feb..00000000 --- a/tests/usertools/01/run4 +++ /dev/null @@ -1,180 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test the -u option of useradd (we can specify the new user UID) -# Check that we can't create an user with the same UID without the -o -# option. - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -echo -n "Create user test4..." -useradd -u 4242 test4 -echo "OK" - -echo "test if the user was added with the right uid" -echo -n " passwd..." -getent passwd test4 | - egrep "^test4:x:4242:4242::/home/test4:/bin/sh$" -echo " OK" -echo -n " group..." -getent group test4 | egrep "^test4:x:4242:$" -echo " OK" -echo -n " shadow..." -getent shadow test4 | egrep "^test4:!:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " gshadow..." -egrep "^test4:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test4 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - -echo "do NOT delete this user" - -echo -n "Create user test5 with the same uid..." -useradd -u 4242 test5 && exit 1 || true -echo "All right, useradd return an error." - -echo "This user should not exist" -echo -n " no entries..." -egrep "^test5:" \ - /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true -echo " OK" -echo -n " no homedir..." -test -d /home/test5 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - -echo -n "Create user test6 with the same uid..." -useradd -o -u 4242 test6 -echo "OK" - -echo "test if the user was added with the right uid" -echo -n " passwd..." -getent passwd test6 | - egrep "^test6:x:4242:4243::/home/test6:/bin/sh$" -echo " OK" -echo -n " group..." -getent group test6 | egrep "^test6:x:4243:$" -echo " OK" -echo -n " shadow..." -getent shadow test6 | egrep "^test6:!:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " gshadow..." -egrep "^test6:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test6 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 2 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 2 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 2 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 2 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - -echo -n "delete user test4..." -userdel test4 -echo "OK" - -echo "check if the user was deleted" -echo -n " no entries..." -egrep "^test4:" \ - /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true -echo " OK" -echo -n " no homedir..." -test -d /home/test4 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - -echo -n "delete user test6..." -userdel test6 -echo "OK" - -echo "check if the user was deleted" -echo -n " no entries..." -egrep "^test6:" \ - /etc/passwd /etc/group /etc/shadow /etc/gshadow && exit 1 || true -echo " OK" -echo -n " no homedir..." -test -d /home/test6 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $lines_passwd = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $lines_group = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $lines_shadow = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $lines_gshadow = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - diff --git a/tests/usertools/01/run5 b/tests/usertools/01/run5 deleted file mode 100755 index 9ea5f8ae..00000000 --- a/tests/usertools/01/run5 +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test useradd -g rejects negative GID -# (In fact useradd fall back to a textual match) - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -################################################################################ -echo -n "Create user test1 in the non existent group -1..." -msg=$(useradd test1 -g -1 2>&1) && exit 1 || { - status=$? - echo status: $status - test "$status" = "6" -} -echo msg: $msg -test "$msg" = "useradd: unknown group -1" -echo "OK" - diff --git a/tests/usertools/01/run6 b/tests/usertools/01/run6 deleted file mode 100755 index 3d5441ed..00000000 --- a/tests/usertools/01/run6 +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test useradd -g checks that the given group exists - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -################################################################################ -echo -n "Create user test2 in the non existent group nekral..." -msg=$(useradd test2 -g nekral 2>&1) && exit 1 || { - status=$? - echo status: $status - test "$status" = "6" -} -echo msg: $msg -test "$msg" = "useradd: unknown group nekral" -echo "OK" diff --git a/tests/usertools/01/run7 b/tests/usertools/01/run7 deleted file mode 100755 index 38b229e1..00000000 --- a/tests/usertools/01/run7 +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test useradd -g accepts numerical groups - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -################################################################################ -echo -n "Create user test3 in group daemon (1)..." -useradd test3 -g 1 - -echo "test if the user was added" -echo -n " passwd..." -getent passwd test3 | - egrep "^test3:x:([0-9]+):1::/home/test3:/bin/sh$" -echo " OK" -uid=$(getent passwd test3|sed -ne "s/test3:x:\([0-9]*\):.*/\\1/p") -# uid must be greater than UID_MIN (in login.defs) -echo -n " uid: $uid < 1000..." -test $uid -ge 1000 -echo " OK" -echo -n " no group test3..." -getent group test3 | egrep "^test3:x:$uid:$" && false || true -echo " OK" -echo -n " shadow..." -getent shadow test3 | egrep "^test3:!:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " no group test3 in gshadow..." -egrep "^test3:!::$" /etc/gshadow && false || true -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test3 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - diff --git a/tests/usertools/01/run8 b/tests/usertools/01/run8 deleted file mode 100755 index d8fb4184..00000000 --- a/tests/usertools/01/run8 +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test useradd -g accepts textual groups - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -################################################################################ -echo -n "Create user test4 in group nogroup..." -useradd test4 -g nogroup - -echo "test if the user was added" -echo -n " passwd..." -getent passwd test4 | - egrep "^test4:x:([0-9]+):65534::/home/test4:/bin/sh$" -echo " OK" -uid=$(getent passwd test4|sed -ne "s/test4:x:\([0-9]*\):.*/\\1/p") -# uid must be greater than UID_MIN (in login.defs) -echo -n " uid: $uid < 1000..." -test $uid -ge 1000 -echo " OK" -echo -n " no group test4..." -getent group test4 | egrep "^test4:x:$uid:$" && false || true -echo " OK" -echo -n " test4 in group nogroup..." -egrep "^nogroup:x:65534:$" /etc/group -echo " OK" -echo -n " shadow..." -getent shadow test4 | egrep "^test4:!:[0-9]+:0:99999:7:::$" -echo " OK" -echo -n " no group test4 in gshadow..." -egrep "^test4:!::$" /etc/gshadow && false || true -echo " OK" -echo -n " test4 in group nogroup (in gshadow)..." -egrep "^nogroup:\*::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test4 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" - diff --git a/tests/usertools/01/run9 b/tests/usertools/01/run9 deleted file mode 100755 index abac7cb7..00000000 --- a/tests/usertools/01/run9 +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh - -set -e - -cd $(dirname $0) - -# Rational: -# Test that usermod can change the informations on an user - -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/ - -lines_passwd=$(wc -l /etc/passwd | cut -f1 -d" ") -lines_shadow=$(wc -l /etc/shadow | cut -f1 -d" ") -lines_group=$(wc -l /etc/group | cut -f1 -d" ") -lines_gshadow=$(wc -l /etc/gshadow | cut -f1 -d" ") - -echo -n "Create user test1..." -useradd test1 -echo "OK" - -uid=$(getent passwd test1|sed -ne "s/test1:x:\([0-9]*\):.*/\\1/p") - -echo -n "Change user test1..." -usermod -g 1 --comment "comment" -e 2000-01-01 -f 17 -s /bin/bash -d /tmp test1 -echo "OK" - -echo "test if the user was changed" -echo -n " passwd..." -getent passwd test1 | - egrep "^test1:x:$uid:1:comment:/tmp:/bin/bash$" -echo " OK" -echo -n " group..." -getent group test1 | egrep "^test1:x:$uid:$" -echo " OK" -echo -n " shadow..." -getent shadow test1 | egrep "^test1:!:[0-9]+:0:99999:7:17:10957:$" -echo " OK" -echo -n " gshadow..." -egrep "^test1:!::$" /etc/gshadow -echo " OK" -# the home directory should not exist -echo -n " no homedir..." -test -d /home/test1 && exit 1 || true -echo " OK" -echo -n " number of lines" -test $(( lines_passwd + 1 )) = $(wc -l /etc/passwd | cut -f1 -d" ") -echo -n "." -test $(( lines_group + 1 )) = $(wc -l /etc/group | cut -f1 -d" ") -echo -n "." -test $(( lines_shadow + 1 )) = $(wc -l /etc/shadow | cut -f1 -d" ") -echo -n "." -test $(( lines_gshadow + 1 )) = $(wc -l /etc/gshadow | cut -f1 -d" ") -echo -n "." -echo " OK" -