Debian Codegraph @

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