#!/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.
#
#################################################################################
#
# Banners and identification
#
#################################################################################
#
    InsertSection "Banners and identification"
    Display --indent 2 --text "- Checking banners..."
#
#################################################################################
#
    # Test        : BANN-7113
    # Description : Check FreeBSD COPYRIGHT banner file
    Register --test-no BANN-7113 --os FreeBSD --weight L --network NO --description "Check COPYRIGHT banner file"
    if [ ${SKIPTEST} -eq 0 ]; then
        Display --indent 2 --text "- /COPYRIGHT or /etc/COPYRIGHT" --result
	logtext "Test: Testing existence /COPYRIGHT or /etc/COPYRIGHT"

        FOUND=0
        if [ -f /COPYRIGHT ]; then
            if [ -e /COPYRIGHT ]; then
    		FOUND=1
    		Display --indent 2 --text "- /COPYRIGHT" --result FOUND --color GREEN
		logtext "/COPYRIGHT available, but empty"
	     else
		FOUND=1
		Display --indent 2 --text "- /COPYRIGHT" --result FOUND --color GREEN
	        logtext "/COPYRIGHT available and contains text"	
	    fi
	fi
	if [ -f /etc/COPYRIGHT ]; then
            if [ -e /etc/COPYRIGHT ]; then
	        FOUND=1
	        Display --indent 2 --text "- /etc/COPYRIGHT" --result FOUND --color GREEN
	        logtext "/etc/COPYRIGHT available, but empty"
	      else
	        FOUND=1
	        Display --indent 2 --text "- /etc/COPYRIGHT" --result FOUND --color GREEN
	        logtext "/etc/COPYRIGHT available and contains text"	
	    fi
        fi
        if [ ${FOUND} -eq 0 ]; then
            Display --indent 2 --text "- /COPYRIGHT or /etc/COPYRIGHT" --result "NOT FOUND" --color WHITE
            logtext "Result: /COPYRIGHT and /etc/COPYRIGHT not found"
        fi
    fi    
#
#################################################################################
#
    # Test        : BANN-7119
    # Description : Check MOTD banner file
    Register --test-no BANN-7119 --weight L --network NO --description "Check MOTD banner file"
    if [ ${SKIPTEST} -eq 0 ]; then
        logtext "Test: Testing existence /etc/motd"
        if [ -f /etc/motd  ]; then
	    logtext "Result: file /etc/motd exists"
	    Display --indent 2 --text "- /etc/motd..." --result FOUND --color GREEN
	    if [ ! -L /etc/motd ]; then
	        IsWorldWritable /etc/motd
		if [ "${FileIsWorldWritable}" = "TRUE" ]; then
		    Display --indent 4 --text "- /etc/motd permissions..." --result WARNING --color RED
		    logtext "Result: /etc/motd is world writable. Users can change this file."
		    ReportWarning ${TEST_NO} "H" "/etc/motd is world writable"
	         else
		    Display --indent 4 --text "- /etc/motd permissions..." --result OK --color GREEN
		    logtext "Result: /etc/motd is not world writable."
		fi
	    fi
	  else
	    logtext "Result: Test skipped"
	    Display --indent 2 --text "- /etc/motd..." --result "NOT FOUND" --color WHITE
        fi
    fi
#
#################################################################################
#

wait_for_keypress

#
#################################################################################
#
# Notes:
# HPUX: /etc/copyright
#
#================================================================================
# Lynis - Copyright 2007-2008, Michael Boelen - www.rootkit.nl - The Netherlands
