550.ipfwlimit revision 149320
187514Scjc#!/bin/sh - 287514Scjc# 387514Scjc# Copyright (c) 2001 The FreeBSD Project 487514Scjc# All rights reserved. 587514Scjc# 687514Scjc# Redistribution and use in source and binary forms, with or without 787514Scjc# modification, are permitted provided that the following conditions 887514Scjc# are met: 987514Scjc# 1. Redistributions of source code must retain the above copyright 1087514Scjc# notice, this list of conditions and the following disclaimer. 1187514Scjc# 2. Redistributions in binary form must reproduce the above copyright 1287514Scjc# notice, this list of conditions and the following disclaimer in the 1387514Scjc# documentation and/or other materials provided with the distribution. 1487514Scjc# 1587514Scjc# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1687514Scjc# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1787514Scjc# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1887514Scjc# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1987514Scjc# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2087514Scjc# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2187514Scjc# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2287514Scjc# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2387514Scjc# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2487514Scjc# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2587514Scjc# SUCH DAMAGE. 2687514Scjc# 2787514Scjc# $FreeBSD: head/etc/periodic/security/550.ipfwlimit 149320 2005-08-20 09:41:49Z glebius $ 2887514Scjc# 2987514Scjc 3087514Scjc# Show ipfw rules which have reached the log limit 3187514Scjc# 3287514Scjc 3387514Scjc# If there is a global system configuration file, suck it in. 3487514Scjc# 3587514Scjcif [ -r /etc/defaults/periodic.conf ] 3687514Scjcthen 3787514Scjc . /etc/defaults/periodic.conf 3887514Scjc source_periodic_confs 3987514Scjcfi 4087514Scjc 4187514Scjcrc=0 4287514Scjc 4387514Scjccase "$daily_status_security_ipfwlimit_enable" in 4487514Scjc [Yy][Ee][Ss]) 45117088Smtm TMP=`mktemp -t security` 4687514Scjc IPFW_LOG_LIMIT=`sysctl -n net.inet.ip.fw.verbose_limit 2> /dev/null` 47149320Sglebius if [ $? -eq 0 ]; then 48149320Sglebius IPFW_LOG_LIMIT=0 49149320Sglebius fi 50149320Sglebius ipfw -a list | grep " log " | \ 51149320Sglebius grep '^[[:digit:]]\+[[:space:]]\+[[:digit:]]\+' | \ 52149320Sglebius awk -v limit="$IPFW_LOG_LIMIT" \ 53149320Sglebius '{if ($6 == "logamount") { 54149320Sglebius if ($2 > $7) 55149320Sglebius {print $0} 56149320Sglebius } else { 57149320Sglebius if ($2 > limit) 58149320Sglebius {print $0}} 59149320Sglebius }' > ${TMP} 60149320Sglebius 61149320Sglebius if [ -s "${TMP}" ]; then 6287514Scjc rc=1 6387514Scjc echo "" 6487514Scjc echo 'ipfw log limit reached:' 6587514Scjc cat ${TMP} 6687514Scjc fi 6787514Scjc rm -f ${TMP};; 6887514Scjc *) rc=0;; 6987514Scjcesac 7087514Scjc 7187514Scjcexit $rc 72