Debian Codegraph @

tests/usertools/chpasswd-PAM/10_chpasswd_usage-m-c_exclusive/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 checks that -c and -m are not provided at the same time"
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 "Password must use md5 and another method (chpasswd -m -c SHA256)..."
20 echo 'nobody:test' | chpasswd -m -c SHA256 2>tmp/usage.out && exit 1 || {
21 status=$?
22 }
23 echo "OK"
24
25 echo -n "Check returned status ($status)..."
26 test "$status" = "2"
27 echo "OK"
28
29 echo "chpasswd reported:"
30 echo "======================================================================="
31 cat tmp/usage.out
32 echo "======================================================================="
33 echo -n "Check the usage message..."
34 diff -au data/usage.out tmp/usage.out
35 echo "usage message OK."
36 rm -f tmp/usage.out
37
38 echo -n "Check the passwd file..."
39 ../../../common/compare_file.pl config/etc/passwd /etc/passwd
40 echo "OK"
41 echo -n "Check the group file..."
42 ../../../common/compare_file.pl config/etc/group /etc/group
43 echo "OK"
44 echo -n "Check the shadow file..."
45 ../../../common/compare_file.pl config/etc/shadow /etc/shadow
46 echo "OK"
47 echo -n "Check the gshadow file..."
48 ../../../common/compare_file.pl config/etc/gshadow /etc/gshadow
49 echo "OK"
50
51 log_status "$0" "SUCCESS"
52 restore_config
53 trap '' 0
54