freebsd-dev/etc/periodic/daily/470.status-named

59 lines
1.1 KiB
Plaintext
Raw Normal View History

#!/bin/sh
#
# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
. /etc/defaults/periodic.conf
source_periodic_confs
fi
catmsgs() {
find /var/log -name 'messages.*' -mtime -2 |
sort -t. -r -n +1 -2 |
xargs zcat -f
[ -f /var/log/messages ] && cat /var/log/messages
}
case "$daily_status_named_enable" in
[Yy][Ee][Ss])
echo
echo 'Checking for denied zone transfers (AXFR and IXFR):'
start=`date -v-1d '+%b %d' | sed 's/0\(.\)$/ \1/'`
rc=$(catmsgs |
perl -ne 'print "$2 from $1\n"
if (/^'"$start"'.*named\[\d+\]: denied [AI]XFR from \[(.*)\]\.\d+ for "(.*)"/);' |
sort -f | uniq -ic |
perl -e '
use Socket;
while (<STDIN>) {
if (/^.*from (.*)$/) {
$ip_addr = $1;
chomp;
if ($ARGV[0] =~ /^yes$/i) {
($host) = gethostbyaddr(inet_aton($ip_addr), AF_INET);
} else {
$host = "";
}
if ($host) {
print "$_ ($host)\n";
} else {
print "$_\n";
}
}
}
' $daily_status_named_usedns | tee /dev/stderr | wc -l)
[ $rc -gt 0 ] && rc=1
;;
*) rc=0;;
esac
exit $rc