home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ee.lbl.gov
/
2014.05.ftp.ee.lbl.gov.tar
/
ftp.ee.lbl.gov
/
acld-1.11.tar.gz
/
acld-1.11.tar
/
acld-1.11
/
aclfw.sh.in
< prev
next >
Wrap
Text File
|
2011-05-18
|
2KB
|
101 lines
#!/bin/sh
# @(#) $Id: aclfw.sh.in 736 2011-05-18 23:00:13Z leres $ (LBL)
#
# PROVIDE: aclfw
# REQUIRE: acld
#
test=0
case "$1" in
start|faststart)
;;
'stop')
exit
;;
'test')
test=1
;;
*)
echo "Usage: $0 { start | stop | test }"
exit 1
;;
esac
. /etc/rc.conf
# Allow test even if aclfw isn't enbled in rc.conf
if [ ${test} -ne 0 ]; then
aclfw_enable="YES"
fi
if [ -n "${aclfw_enable}" -a "x${aclfw_enable}" != "xNO" ] ; then
export PATH="@PREFIX@/libexec:${PATH}"
if [ ${test} -eq 0 ]; then
echo -n " aclfw"
else
echo "# TEST MODE"
fi
prog="`basename $0`"
watcher="${aclfw_watcher:-root}"
t1="/tmp/${prog}.1.$$"
t2="/tmp/${prog}.2.$$"
files="/var/log/nets"
if [ ! -r ${files} ]; then
files=""
for f in /var/log/syslog /var/log/messages; do
files="${files} ${f}"
f2=${f}.0
if [ -r ${f2} ]; then
files="${files} ${f2}"
fi
done
fi
if [ ${test} -ne 0 ]; then
echo "# files: ${files}"
fi
awk '$6 == "NETS" && $7 == "status=success" {
ip = "?"
if (substr($11, 1, 3) == "ip=")
ip = substr($11, 4)
if ($10 == "cmd=drop")
block[ip] = 1
else if ($10 == "cmd=restore")
block[ip] = 0
}
END {
for (ip in block)
if (block[ip])
print ip
}' ${files} > ${t1} 2>&1
if [ -s ${t1} ]; then
if [ ${test} -ne 0 ]; then
cat ${t1}
rm ${t1}
exit
fi
acl.exp drop -f ${t1} > ${t2} 2>&1
((echo "Subject: `hostname` acld ipfw startup"
echo "To: ${watcher}"
echo ""
echo "Re-blocking:"
sed -e 's/^/ /' ${t1}
echo ""
cat ${t2}) |
sendmail -bm -froot@ee.lbl.gov -t ; \
rm ${t1} ${t2} & ) > /dev/null 2>&1
else
rm ${t1}
fi
fi