cron.daily/security

Wed, 15 Jan 2014 12:43:54 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 15 Jan 2014 12:43:54 +0100
changeset 18
2b7620bf17e6
parent 17
65656789da08
child 19
2c0dacb26b14
permissions
-rw-r--r--

Mail default is now just root. Don't send empty mail reports anymore.

#!/bin/bash
#
#############################################################################
# Copyright (C) 2005-2014
#   
# Michiel Broek               <mbse at mbse.eu>
#
# This file is part of SlackSecCheckSripts.
#
# This package is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2, or (at your option) any
# later version.
#
# SlackSecCheckSripts is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with MBSE BBS; see the file COPYING.  If not, write to the Free
# Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
#############################################################################

VERSION=0.19
export PATH=/bin:/usr/bin:/sbin:/usr/sbin
umask 077
LANG=C; export LANG

fqdn=`hostname -f`
date=`date`

if [ "${MAILTO}" = "" ]; then
    MAILTO=root
fi

DAILYDIR=`mktemp -d /tmp/_daily.XXXXXX` || exit 1
SECOUT="$DAILYDIR/secout"
TMP1="$DAILYDIR/tmp1"

trap "/bin/rm -rf $DAILYDIR ; exit 0" EXIT INT QUIT

if ! cd "$DAILYDIR"; then
    echo "Can not cd to $DAILYDIR".
    exit 1
fi


# Check chk_* scripts in /etc/security.d which are executable
# and run them. Any script output is appended to the report
#
for f in `/bin/ls /etc/security.d/chk_*`
do
    if [ -x $f ]; then
	rm -f $TMP1
	$f > $TMP1
	if [ -s $TMP1 ]; then
	    if [ ! -f $SECOUT ]; then
		echo "" >> $SECOUT
		echo "	SlackSecCheckSripts v${VERSION}" >> $SECOUT
		echo "" >> $SECOUT
	    fi
	    cat $TMP1 >> $SECOUT
	    echo "" >> $SECOUT
	    echo "------------------------------------------------------------------------------" >> $SECOUT
	fi
    fi
done

env MAILRC=/dev/null mail -s "$fqdn daily insecurity output for $date" $MAILTO < $SECOUT

mercurial