#!/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.
#
#################################################################################
#
# E-mail and messaging
#
#################################################################################
#
    InsertSection "Software: e-mail"
#
#################################################################################
#
    #YYY Add support for mail, procmail
    #YYY Add support for MUAs: Thunderbird, Kmail, Evolution

    # MTA::Exim
    # Test        : MAIL-8806
    # Description : Check Exim configuration
    #Register --test-no MAIL-8806 --weight L --network NO --description "Check Exim configuration"
    #if [ ${SKIPTEST} -eq 0  ]; then

    # Place holder
    #    if [ ! "${EXIMBINARY}" = "" ]; then
    #        logtext "Test: Searching Exim configuration file..."
    #	FIND=`${EXIMBINARY} -d | grep "configuration file is" | sed 's/configuration file is//'`
    #	if [ ! "${FIND}" = "" ]; then	
    #	    Display --indent 2 --text "- Checking Exim configuration..." --result FOUND --color GREEN
    #	    Display --indent 4 --text "Result: configuration file is ${FIND}"
    #	    logtext "Result: found Exim"
    #	    logtext "Result: configuration file is ${FIND}"
    #	  else
    #	    Display --indent 2 --text "- Checking Exim configuration..." --result WARNING --color RED
    #	    logtext "Couldn't find the Exim configuration file, however Exim seems to be installed."
    #	fi
    #      else
    #	logtext "Exim not found, no tests performed"
    #    fi
#
#################################################################################
#
    # Test        : MAIL-8816
    # Description : Check Postfix configuration
    if [ ! "${POSTFIXBINARY}" = "" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
    Register --test-no MAIL-8816 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check Postfix configuration"
    if [ ${SKIPTEST} -eq 0  ]; then
        Display --indent 2 --text "- Checking Postfix configuration..." --result FOUND --color GREEN
        POSTFIX_CONFIGDIR=`${POSTCONFBINARY} | grep '^config_directory'`
        POSTFIX_CONFIGFILE="${POSTFIX_CONFIGDIR}/main.cf"
        logtext "Postfix configuration directory: ${POSTFIX_CONFIGDIR}"
        logtext "Postfix configuration file: ${POSTFIX_CONFIGFILE}"    
    fi
#
#################################################################################
#
    # Test        : MAIL-8818
    # Description : Check Postfix configuration
    if [ ! "${POSTFIXBINARY}" = "" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
    Register --test-no MAIL-8818 --preqs-met ${PREQS_MET} --weight L --network NO --description "Check Postfix configuration: banner"
    if [ ${SKIPTEST} -eq 0  ]; then
        logtext "Test: Checking Postfix banner"
        FIND1=`${POSTCONFBINARY} | grep '^smtpd_banner' | grep 'postfix'`
        FIND2=`${POSTCONFBINARY} | grep '^smtpd_banner' | grep '$mail_name'`
        FIND3=`${POSTCONFBINARY} | grep '^mail_name' | grep -i 'postfix'`
        SHOWWARNING=0
        if [ ! "${FIND1}" = "" ]; then
            SHOWWARNING=1
          else
            if [ ! "${FIND2}" = "" -a ! "${FIND3}" = "" ]; then
    	        SHOWWARNING=1
	      else	  
	        Display --indent 4 --text "- Checking Postfix banner..." --result OK --color GREEN
	    fi
        fi
        if [ ${SHOWWARNING} -eq 1 ]; then
	    Display --indent 4 --text "- Checking Postfix banner..." --result WARNING --color RED
	    logtext "Warning: found mail_name in SMTP banner, and/or mail_name contains 'Postfix'."
	    logtext "Suggestion: You are adviced to hide the mail_name (option: smtpd_banner) from your postfix configuration."
	    logtext "Use postconf -e or change your main.cf file (${POSTFIX_CONFIGFILE})"
	fi
      else
	logtext "Postfix binary not found, no tests performed"
    fi
#
#################################################################################
#

wait_for_keypress

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