Fix the creation of the dumpdir directory in stress_floppy Makefile
[ltp-debian.git] / testcases / commands / cron / cron03
blob2cb157a22335a776b43a41a34e74f93b80aecbb6
1 #!/bin/sh
2 #*********************************************************************
3 # Copyright (c) International Business Machines Corp., 2000
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 # the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this pronram; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # FILE : cron
21 # PURPOSE: Test a bad (negative) cron job
22 # - try to edit the crontab of root
23 # - try to set illegal or nondefined execution times
24 # Here the script uses file illegal_cron_lines which contains two
25 # fields per line: the cron line to be tested (without script name),
26 # and the description of this test. The description is written to
27 # stdout during execution of the test.
28 # - try to do things you aren't allowed as non-root (cron runs as root)
31 # HISTORY:
32 # SUSE
36 TEST_USER="c02_user"
37 TEST_USER_GROUP="users"
38 TEST_USER_HOMEDIR="/home/$TEST_USER"
40 #-----------------------------------------------------------------------
41 # FUNCTION: do_setup
42 #-----------------------------------------------------------------------
44 do_setup(){
46 #erase user if he may exist , so we can have a clean env
47 rm -rf /home/$TEST_USER
48 userdel $TEST_USER
49 sleep 1
51 useradd -m -g $TEST_USER_GROUP $TEST_USER
52 if [ $? != 0 ]
53 then {
54 echo "Could not add test user $TEST_USER to system $RHOST."
55 exit 1
58 # restart cron daemon
59 # Red Hat uses crond, SuSE/Other uses cron.
60 if [ -f /etc/init.d/crond ]; then
61 /etc/init.d/crond restart
62 else
63 /etc/init.d/cron restart
67 #-----------------------------------------------------------------------
68 # FUNCTION: do_cleanup
69 #-----------------------------------------------------------------------
71 do_cleanup(){
72 rm -rf /home/$TEST_USER
73 userdel $TEST_USER
76 #-----------------------------------------------------------------------
77 # FUNCTION: MAIN
78 #-----------------------------------------------------------------------
79 do_setup
80 cron_neg_tests.sh $TEST_USER
81 EXIT_CODE=$?
82 do_cleanup
83 exit $EXIT_CODE