From fe827dc82e396522e05326242dae2f67c153254d Mon Sep 17 00:00:00 2001 From: teastep Date: Tue, 18 Jul 2006 14:53:34 +0000 Subject: [PATCH] Fix the output of the 'hits' command under BusyBox 1.2.0 git-svn-id: https://shorewall.svn.sourceforge.net/svnroot/shorewall/trunk@4234 fbd18981-670d-0410-9b5c-8dc0c1a9a2bb --- Shorewall/changelog.txt | 3 +++ Shorewall/releasenotes.txt | 3 ++- Shorewall/shorewall | 18 +++++++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Shorewall/changelog.txt b/Shorewall/changelog.txt index dbefedafe..0e70507c8 100644 --- a/Shorewall/changelog.txt +++ b/Shorewall/changelog.txt @@ -1,3 +1,6 @@ Changes in 3.3.0 1) Remove dynamic zone capability. + +2) Fixed output of 'hits' command under busybox 1.2.0. + diff --git a/Shorewall/releasenotes.txt b/Shorewall/releasenotes.txt index cddc43c2d..d4af54205 100644 --- a/Shorewall/releasenotes.txt +++ b/Shorewall/releasenotes.txt @@ -33,7 +33,8 @@ Note to users upgrading from Shorewall 2.x or 3.0 Problems Corrected in 3.3.0 -None. +1) The output formating of the 'hits' command under BusyBox 1.2.0 has + been corrected. Other changes in 3.3.0 diff --git a/Shorewall/shorewall b/Shorewall/shorewall index 32440f759..aef15ec86 100755 --- a/Shorewall/shorewall +++ b/Shorewall/shorewall @@ -1715,19 +1715,31 @@ case "$COMMAND" in if [ $(grep -c "$LOGFORMAT" $LOGFILE ) -gt 0 ] ; then echo " HITS IP DATE" echo " ---- --------------- ------" - grep "$LOGFORMAT" $LOGFILE | sed 's/\(.\{6\}\)\(.*SRC=\)\(.*\)\( DST=.*\)/\3 \1/' | sort | uniq -c | sort -rn + grep "$LOGFORMAT" $LOGFILE | sed 's/\(.\{6\}\)\(.*SRC=\)\(.*\)\( DST=.*\)/\3 \1/' | sort | uniq -c | sort -rn | \ + while read count address month day; do + printf '%7d %-15s %3s %2d\n' $count $address $month $day + done + echo "" echo " HITS IP PORT" echo " ---- --------------- -----" grep "$LOGFORMAT" $LOGFILE | sed 's/\(.*SRC=\)\(.*\)\( DST=.*DPT=\)\([0-9]\{1,5\}\)\(.*\)/\2 \4/ t - s/\(.*SRC=\)\(.*\)\( DST=.*\)/\2/' | sort | uniq -c | sort -rn + s/\(.*SRC=\)\(.*\)\( DST=.*\)/\2/' | sort | uniq -c | sort -rn | \ + while read count address port; do + printf '%7d %-15s %d\n' $count $address $port + done + echo "" echo " HITS DATE" echo " ---- ------" - grep "$LOGFORMAT" $LOGFILE | sed 's/\(.\{6\}\)\(.*\)/\1/' | sort | uniq -c | sort -rn + grep "$LOGFORMAT" $LOGFILE | sed 's/\(.\{6\}\)\(.*\)/\1/' | sort | uniq -c | sort -rn | \ + while read count month day; do + printf '%7d %3s %2d\n' $count $month $day + done + echo "" echo " HITS PORT SERVICE(S)"