2 ########################################################
6 # 10/01/04 Kris Wilson RHEL4 only allows super user
9 # 12/03/04 Marty Ridgeway Pull RHEl4 tests out from script
10 ########################################################
14 if [ $iam = "root" ]; then
15 if [ $# -lt 1 ] ; then
16 echo Either
do not run this
script as root or start it like
26 # 1. root einen cronjob unterjubeln
32 crontab
-u root
- << EOF
38 if [ $rc = "0" ]; then
39 echo root has now an interesting cron job
40 echo "crontab has a severe security breach (FAIL)"
44 echo "Editing a crontab of another user failed successfully (PASS)"
50 # 2. write some illegal crontabs
55 #crontab -l > /dev/null 2> /dev/null
56 #if [ $? = "0" ]; then
57 # echo Saving current crontab...
59 # crontab -l > /tmp/save-crontab-`whoami`
64 #for line in `cat cron_illegal_cron_lines | grep '^[^#]' | sed -e 's/[ \t][ \t]*/_/g'` ; do
65 # line=`echo $line | sed -e 's/_/ /g'`
67 # cronconf=`echo "$line" | cut -f 1 -d '|'`
68 # desc=`echo "$line" | cut -f 2 -d '|'`
71 # echo "$cronconf true" | crontab -
73 # if [ $? = "0" ]; then
74 # echo 'Test FAILED (or crontab returned wrong exit code)'
83 # Test whether cron uses setuid correctly
89 tmpscript
=cron_neg01_test
90 rm -rf $tmpscript.out
&> /dev
/null
93 cat > /tmp
/$tmpscript << EOF
94 touch /root/halloichwarhier
96 cat /root/halloichwarhier ; echo "res:$?"
97 rm /root/halloichwarhier
100 chmod 755 /tmp
/$tmpscript
103 cronline
=`date '+%M' | awk '{print ($1+2)%60 " * * * * "}'`
104 (echo "$cronline /tmp/$tmpscript >> /tmp/$tmpscript.out 2>> /tmp/$tmpscript.out" ; \
105 echo "$cronline /tmp/$tmpscript >> /$tmpscript.out 2>> /$tmpscript.out") \
108 echo "sleeping 130 secs..."
113 if [ "1" = `cat /tmp/$tmpscript.out | grep "res:0" | wc -l` ]; then
114 echo "setuid test part 1 successfully failed (PASS)"
116 echo "cron executed scripts have root privileges! (FAIL)"
121 test -e /tmp
/$tmpscript.out
&& CODE
=1
122 if [ $CODE = "1" ]; then
123 echo "setuid test part 2 successfully failed (PASS)"
125 echo "cron writes script output with root privileges! (FAIL)"
130 rm /tmp
/$tmpscript* &> /dev
/null
135 if [ "$savedcrontab" = "1" ]; then
136 echo "Restoring crontab..."
137 cat /tmp
/save-crontab-
`whoami` |
grep '^[^#]' | crontab
-
138 # rm -r /tmp/save-crontab-`whoami`