Debian Codegraph @

tests/usertools/chpasswd-PAM/26_chpasswd_no_shadow_file_invalid_passwd/chpasswd.test

raw
1 #!/bin/sh
2
3 set -e
4
5 cd $(dirname $0)
6
7 . ../../../common/config.sh
8 . ../../../common/log.sh
9
10 log_start "$0" "chpasswd changes the passwd file if shadow does not exist"
11
12 save_config
13
14 # restore the files on exit
15 trap 'log_status "$0" "FAILURE"; restore_config' 0
16
17 change_config
18
19 echo -n "Remove /etc/shadow..."
20 rm -f /etc/shadow
21 echo "OK"
22
23 echo -n "Change nobody's and lp's password..."
24 echo 'nobody:test
25 lp:test2' | chpasswd 2>tmp/chpasswd.err && exit 1 || {
26 status=$?
27 }
28 echo "OK"
29
30 echo -n "Check returned status ($status)..."
31 test "$status" = "1"
32 echo "OK"
33
34 echo "chpasswd reported:"
35 echo "======================================================================="
36 cat tmp/chpasswd.err
37 echo "======================================================================="
38 echo -n "Check that there were a failure message..."
39 diff -au data/chpasswd.err tmp/chpasswd.err
40 echo "error message OK."
41 rm -f tmp/chpasswd.err
42
43 echo -n "Check the passwd file..."
44 ../../../common/compare_file.pl config/etc/passwd /etc/passwd
45 echo "OK"
46 echo -n "Check the group file..."
47 ../../../common/compare_file.pl config/etc/group /etc/group
48 echo "OK"
49 echo -n "Check that shadow does not exist..."
50 test ! -f /etc/shadow
51 echo "OK"
52 echo -n "Check the gshadow file..."
53 ../../../common/compare_file.pl config/etc/gshadow /etc/gshadow
54 echo "OK"
55
56 log_status "$0" "SUCCESS"
57 restore_config
58 trap '' 0
59