#!/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..."

# FreeBSD: /etc/COPYRIGHT or /COPYRIGHT
# HPUX: /etc/copyright

if [ "${OS}" = "FreeBSD" ]; then
    counttests
    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
    logtextbreak
fi    

#
#################################################################################
#

# Check /etc/motd file

    counttests
    logtext "Test: Testing existence /etc/motd"

    if [ -f /etc/motd -a ! -L /etc/motd ]; then
	counttests
	logtext "Result: file /etc/motd exists"
	Display --indent 2 --text "- /etc/motd..." --result FOUND --color WHITE
	IsWorldWritable /etc/motd

	if [ "${FileIsWorldWritable}" = "TRUE" ]; then
	    Display --indent 4 --text "- /etc/motd permissions..." --result WARNING --color RED
	    logtext "Warning: /etc/motd is world writable. Users can change this file."
	 else
	    Display --indent 4 --text "- /etc/motd permissions..." --result OK --color GREEN
	    logtext "Result: Ok, /etc/motd is not world writable."
	fi
      else
        logtext "Result: Test skipped"
	Display --indent 2 --text "- /etc/motd..." --result "NOT FOUND" --color WHITE
    fi
    
    logtextbreak


wait_for_keypress

###########################################################################
##%HASH-SHA1%----------------------------%
##%TESTS-COUNT%50%
###########################################################################

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