#!/bin/sh

#################################################################################
#
#   Lynis
# ------------------
#
# Copyright 2007-2008, Michael Boelen (michael@rootkit.nl), The Netherlands
# Web site: http://www.rootkit.nl
#
# Lynis comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
# See LICENSE file for usage of this software.
#
#################################################################################
#
# Scheduled tasks
#
#################################################################################
#
    InsertSection "Scheduled tasks"

    # Test        : SCHD-7704
    # Description : Check crontab / cronjobs
    Register --test-no SCHD-7704 --weight L --network NO --description "Check crontab/cronjobs"
    if [ ${SKIPTEST} -eq 0 ]; then
	Display --indent 2 --text "- Checking crontab/cronjob"
        FindCronJob()
	  {
	    sCRONJOBS=`egrep '^([0-9])' $1 | tr '\t' ' ' | tr -s ' ' | tr ' ' ','`
	  }
	if [ -f /etc/crontab ]; then
	    FindCronJob /etc/crontab
	    for I in ${sCRONJOBS}; do
	        logtext "Found cronjob (/etc/crontab): ${I}"
	    done
	fi
	if [ -d /etc/cron.d ]; then
	    FIND=`find /etc/cron.d -type f -print`
	    for I in ${FIND}; do
	        FindCronJob  ${I}
		for J in ${sCRONJOBS}; do
		    logtext "Found cronjob (/etc/cron.d): ${I}"
		done
	    done 
	fi
	# /var/spool/cron/* and /var/spool/cron/crontabs/*
	if [ -d /var/spool/cron ]; then
	    FIND=`find /var/spool/cron -type f -print`
	    for I in ${FIND}; do
	        FindCronJob  ${I}
		for J in ${sCRONJOBS}; do
		    logtext "Found cronjob (/var/spool/cron): ${I}"
		done
	    done 
	fi	
    fi
#
#################################################################################
#

wait_for_keypress

#
#================================================================================
# Lynis - Copyright 2007-2008, Michael Boelen - www.rootkit.nl - The Netherlands
