| 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 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 "Change passwords (chpasswd -e)..." |
| 24 |
echo 'nobody:test |
| 25 |
lp:test2' | chpasswd -e 2>tmp/chpasswd.err && exit 1 || { |
| 26 |
status=$? |
| 27 |
} |
| 28 |
echo "OK" |
| 29 |
|
| 30 |
rm -f /etc/passwd.lock |
| 31 |
|
| 32 |
echo -n "Check returned status ($status)..." |
| 33 |
test "$status" = "1" |
| 34 |
echo "OK" |
| 35 |
|
| 36 |
echo "chpasswd reported:" |
| 37 |
echo "=======================================================================" |
| 38 |
cat tmp/chpasswd.err |
| 39 |
echo "=======================================================================" |
| 40 |
echo -n "Check that there were a failure message..." |
| 41 |
diff -au data/chpasswd.err tmp/chpasswd.err |
| 42 |
echo "error message OK." |
| 43 |
rm -f tmp/chpasswd.err |
| 44 |
|
| 45 |
echo -n "Check the passwd file..." |
| 46 |
../../../common/compare_file.pl config/etc/passwd /etc/passwd |
| 47 |
echo "OK" |
| 48 |
echo -n "Check the group file..." |
| 49 |
../../../common/compare_file.pl config/etc/group /etc/group |
| 50 |
echo "OK" |
| 51 |
echo -n "Check the shadow file..." |
| 52 |
../../../common/compare_file.pl config/etc/shadow /etc/shadow |
| 53 |
echo "OK" |
| 54 |
echo -n "Check the gshadow file..." |
| 55 |
../../../common/compare_file.pl config/etc/gshadow /etc/gshadow |
| 56 |
echo "OK" |
| 57 |
|
| 58 |
log_status "$0" "SUCCESS" |
| 59 |
restore_config |
| 60 |
trap '' 0 |
| 61 |
|