Debian Codegraph @

tests/cktools/pwck/23_pwck_locked_passwd/pwck.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" "pwck checks if the passwd file is locked"
11
12 save_config
13
14 # restore the files on exit
15 trap 'log_status "$0" "FAILURE"; restore_config; rm -f /etc/passwd.lock' 0
16
17 change_config
18
19 echo -n "Create lock file for /etc/passwd..."
20 touch /etc/passwd.lock
21 echo "done"
22
23 echo -n "Check user database (pwck)..."
24 pwck 2>tmp/pwck.err && exit 1 || {
25 status=$?
26 }
27 echo "OK"
28
29 rm -f /etc/passwd.lock
30
31 echo -n "Check returned status ($status)..."
32 test "$status" = "4"
33 echo "OK"
34
35 echo "pwck reported:"
36 echo "======================================================================="
37 cat tmp/pwck.err
38 echo "======================================================================="
39 echo -n "Check that there were a failure message..."
40 diff -au data/pwck.err tmp/pwck.err
41 echo "error message OK."
42 rm -f tmp/pwck.err
43
44 echo -n "Check the passwd file..."
45 ../../../common/compare_file.pl config/etc/passwd /etc/passwd
46 echo "OK"
47 echo -n "Check the group file..."
48 ../../../common/compare_file.pl config/etc/group /etc/group
49 echo "OK"
50 echo -n "Check the shadow file..."
51 ../../../common/compare_file.pl config/etc/shadow /etc/shadow
52 echo "OK"
53 echo -n "Check the gshadow file..."
54 ../../../common/compare_file.pl config/etc/gshadow /etc/gshadow
55 echo "OK"
56
57 log_status "$0" "SUCCESS"
58 restore_config
59 trap '' 0
60