| 1 |
#! /bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
# PATH TO VERIFY |
| 6 |
CRONTABS_DIR=/var/spool/cron/crontabs |
| 7 |
ALLOW_FILE=/etc/cron.allow |
| 8 |
DENY_FILE=/etc/cron.deny |
| 9 |
|
| 10 |
|
| 11 |
dir=$(pwd)/debian/tests |
| 12 |
. $dir/textutils.sh |
| 13 |
|
| 14 |
frame "Here we are testing the patch" \ |
| 15 |
"features/Debian-paths-and-commands.patch" \ |
| 16 |
"" \ |
| 17 |
"First of all we check path ${CRONTABS_DIR}" |
| 18 |
|
| 19 |
echo "================= adding user 'dummy' =====================" |
| 20 |
getent passwd dummy || adduser --disabled-password --gecos "" dummy |
| 21 |
|
| 22 |
echo "========= make user 'dummy' fill his crontab ==============" |
| 23 |
# stderr must be deactivated since crontab will report there |
| 24 |
# that there is no initial crontab for user "dummy" |
| 25 |
su dummy -c "EDITOR=$(pwd)/debian/tests/cronfiller.py crontab -e" 2>/dev/null |
| 26 |
|
| 27 |
echo "========== testing the crontab of user 'dummy' =============" |
| 28 |
|
| 29 |
expected_crontab_filename=${CRONTABS_DIR}/dummy |
| 30 |
[ -f ${expected_crontab_filename} ] && grep "* * * * * /bin/ls" ${expected_crontab_filename} |
| 31 |
|
| 32 |
crontab -u dummy -r |
| 33 |
|
| 34 |
frame "Now we check path ${DENY_FILE}" |
| 35 |
|
| 36 |
rm -f ${ALLOW_FILE} |
| 37 |
echo dummy > ${DENY_FILE} |
| 38 |
|
| 39 |
su dummy -c "EDITOR=$(pwd)/debian/tests/cronfiller.py crontab -e" 2>&1 |grep "not allowed" |
| 40 |
|
| 41 |
frame "Now we check path ${ALLOW_FILE}" |
| 42 |
|
| 43 |
echo goofy > ${ALLOW_FILE} |
| 44 |
rm -f ${DENY_FILE} |
| 45 |
|
| 46 |
su dummy -c "EDITOR=$(pwd)/debian/tests/cronfiller.py crontab -e" 2>&1 |grep "not allowed" |
| 47 |
|
| 48 |
echo dummy > ${ALLOW_FILE} |
| 49 |
echo dummy > ${DENY_FILE} |
| 50 |
|
| 51 |
# allow take precedence |
| 52 |
su dummy -c "EDITOR=$(pwd)/debian/tests/cronfiller.py crontab -e" 2>/dev/null |
| 53 |
|
| 54 |
echo "========== test ok =========================================" |
| 55 |
|
| 56 |
rm -f ${DENY_FILE} |
| 57 |
rm -f ${ALLOW_FILE} |