Questo script manda una notifica a una mail specificata quando viene rilasciata una advisory che influenza (potenzialmente) la sicurezza del sistema.
Code: Select all
#!/bin/sh
# script to check for any Gentoo advisory and notify admins via email.
# Requires Gentoolkit
#
# to be called from cron, eg.
# * */6 * * * glsa-mail.sh
#
# Released under the GPL.
# Author Giovanni Ferri <FonderiaDigitale@gechi.it>
# Gechi web site www.gechi.it
# change this! :)
email="root"
checkGLSA () {
tmpfile="/tmp/GLSA_${RANDOM}"
mailfile="/tmp/GLSA_${RANDOM}"
IFS="
"
glsa-check --nocolor --list 2>/dev/null > $tmpfile
lines=`perl -0777pe 's/^(?:.*\n){4}//' $tmpfile`
rm -f $tmpfile
year=`date +%Y`
for each in $lines; do
GLSAn=`echo "$each"|cut -d' ' -f1`
type=`echo "$each"|cut -d' ' -f2`
case $type in
*N*)
if [ "$got" != 1 ]; then
got=1
echo "$HOSTNAME could be affected by this vulnerability:" >> $mailfile
echo >> $mailfile
fi
glsa-check --dump $GLSAn 2>/dev/null >> $mailfile
;;
esac
done
}
checkGLSA
cat $mailfile|mail $email -s 'new GLSA vulnerability found!! Check your machine.'
if [ "$got" == 1 ]; then
rm -f $tmpfile $mailfile
else
exit 0
fi




