• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2#*********************************************************************
3#   Copyright (c) International Business Machines  Corp., 2000
4#
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.
9#
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.
14#
15#   You should have received a copy of the GNU General Public License
16#   along with this program;  if not, write to the Free Software
17#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18#
19#  FILE   : cron
20#
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)
29
30#
31#  HISTORY:
32#     	SUSE
33#
34
35
36TEST_USER="c02_user"
37TEST_USER_GROUP="users"
38TEST_USER_HOMEDIR="/home/$TEST_USER"
39
40#-----------------------------------------------------------------------
41# FUNCTION:  do_setup
42#-----------------------------------------------------------------------
43
44do_setup(){
45
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
50
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
56        }
57        fi
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
64	fi
65}
66
67#-----------------------------------------------------------------------
68# FUNCTION:  do_cleanup
69#-----------------------------------------------------------------------
70
71do_cleanup(){
72        rm -rf /home/$TEST_USER
73        userdel $TEST_USER
74}
75
76#-----------------------------------------------------------------------
77# FUNCTION:  MAIN
78#-----------------------------------------------------------------------
79do_setup
80cron_neg_tests.sh $TEST_USER
81EXIT_CODE=$?
82do_cleanup
83exit $EXIT_CODE
84