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

# Place holder
#    if [ ! "${EXIMBINARY}" = "" ]; then
#        counttests
#        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
#    logtextbreak

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


logtext "Check for Postfix binary"
if [ ! "${POSTFIXBINARY}" = "" ];
  then
    counttests
    Display --indent 2 --text "- Checking Postfix configuration..." --result FOUND --color GREEN
    logtext "Result: found postfix binary"
    counttests
    POSTFIX_CONFIGDIR=`${POSTCONFBINARY} | grep '^config_directory'`
    POSTFIX_CONFIGFILE="${POSTFIX_CONFIGDIR}/main.cf"
    logtext "Postfix configuration directory: ${POSTFIX_CONFIGDIR}"
    logtext "Postfix configuration file: ${POSTFIX_CONFIGFILE}"    
    logtext "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
logtextbreak

wait_for_keypress

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