#!/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.
#
#################################################################################
#
# Time
#
#################################################################################
#
    InsertSection "Time and Synchronization"

    # Test        : TIME-3104
    # Description : Check for a running syslog daemon
    Register --test-no TIME-3104 --weight L --network NO --description "Check for running syslog daemon"
    if [ ${SKIPTEST} -eq 0 ]; then
        # Linux/FreeBSD (ntpdate), OpenBSD (ntpd, rdate)
	logtext "Test: Searching for a NTP daemon or client... "
	FOUND=0
	FIND=`ps ax | grep "ntpd" | grep -v "grep"`
	if [ ! "${FIND}" = "" ]; then FOUND=1; logtext "Result: Found NTP daemon"; fi
        # Check crontab for OpenBSD/FreeBSD
	if [ -f /etc/crontab ]; then
	    FIND=`cat /etc/crontab | egrep "ntpdate|rdate" | grep -v '^#'`
	    if [ ! "${FIND}" = "" ]; then
    		FOUND=1;
		Display --indent 2 --text "- Checking NTP client in crontab file..." --result FOUND --color GREEN
	      else
	        Display --indent 2 --text "- Checking NTP client in crontab file..." --result "NOT FOUND" --color WHITE
	    fi
	fi
	if [ ${FOUND} -eq 0 ]; then    
    	    Display --indent 2 --text "- Checking for a running NTP daemon or client..." --result WARNING --color RED
	    logtext "Result: Could not find a NTP daemon or client"
	    logtext "Suggestion: Check if any NTP daemon is running or a NTP client gets "
	    logtext "executed daily, to prevent big time differences and avoid problems "
	    logtext "with services like kerberos, authentication or logging differences."
	    ReportWarning ${TEST_NO} "M" "No NTP daemon or client found"
	  else
	    Display --indent 2 --text "- Checking for a running NTP daemon or client..." --result OK --color GREEN
	    logtext "Result: Found a time syncing daemon/client."
        fi
    fi
#
#################################################################################
#

wait_for_keypress

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