Debian Codegraph @

tests/failures/chage/06_chage_rename_passwd_failure/chage.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" "chage 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; chmod g+s /usr/bin/chage' 0
16
17 change_config
18
19 echo -n "Remove setgid flag on chage..."
20 chmod g-s /usr/bin/chage
21 echo "OK"
22
23 echo -n "Change bin's inactivity period (chage -I 12 bin)..."
24 LD_PRELOAD=../../../common/rename_failure.so FAILURE_PATH=/etc/passwd chage -I 12 bin 2>tmp/chage.err && exit 1 || {
25 status=$?
26 }
27 echo "OK"
28
29 echo -n "Restore setgid flag on chage..."
30 chmod g+s /usr/bin/chage
31 echo "OK"
32
33 echo -n "Check returned status ($status)..."
34 test "$status" = "1"
35 echo "OK"
36
37 echo "chage reported:"
38 echo "======================================================================="
39 cat tmp/chage.err
40 echo "======================================================================="
41 echo -n "Check that there were a failure message..."
42 diff -au data/chage.err tmp/chage.err
43 echo "error message OK."
44 rm -f tmp/chage.err
45
46 echo -n "Check the passwd file..."
47 ../../../common/compare_file.pl config/etc/passwd /etc/passwd
48 echo "OK"
49 echo -n "Check the group file..."
50 ../../../common/compare_file.pl config/etc/group /etc/group
51 echo "OK"
52 echo -n "Check the shadow file..."
53 ../../../common/compare_file.pl data/shadow /etc/shadow
54 echo "OK"
55 echo -n "Check the gshadow file..."
56 ../../../common/compare_file.pl config/etc/gshadow /etc/gshadow
57 echo "OK"
58
59 log_status "$0" "SUCCESS"
60 restore_config
61 trap '' 0
62