Debian Codegraph @

tests/failures/pwconv/03_pwconv_rename_passwd_failure/pwconv.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" "pwconv report failures to write the passwd file"
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 the shadow file..."
20 rm -f /etc/shadow
21 echo "OK"
22
23 echo -n "Enable shadow passwords (pwconv)..."
24 LD_PRELOAD=../../../common/rename_failure.so FAILURE_PATH=/etc/passwd pwconv 2>tmp/pwconv.err && exit 1 || {
25 status=$?
26 }
27 echo "OK"
28
29 echo -n "Check returned status ($status)..."
30 test "$status" = "3"
31 echo "OK"
32
33 echo "pwconv reported:"
34 echo "======================================================================="
35 cat tmp/pwconv.err
36 echo "======================================================================="
37 echo -n "Check that there were a failure message..."
38 diff -au data/pwconv.err tmp/pwconv.err
39 echo "error message OK."
40 rm -f tmp/pwconv.err
41
42 echo -n "Check the passwd file..."
43 ../../../common/compare_file.pl config/etc/passwd /etc/passwd
44 echo "OK"
45 echo -n "Check the group file..."
46 ../../../common/compare_file.pl config/etc/group /etc/group
47 echo "OK"
48 echo -n "Check the shadow file..."
49 ../../../common/compare_file.pl data/shadow /etc/shadow
50 echo "OK"
51 echo -n "Check the gshadow file..."
52 ../../../common/compare_file.pl config/etc/gshadow /etc/gshadow
53 echo "OK"
54
55 log_status "$0" "SUCCESS"
56 restore_config
57 trap '' 0
58