#! /bin/sh #------------------------------------------------------------------------------ # pf.cgi - show the firewall config # # Creation: 05.08.2005 jw5 # Last Update: $Id$ # #------------------------------------------------------------------------------ # Functions dump_rules () { rules="$1" f="iptables --line-numbers -nvL" n="iptables --line-numbers -t nat -nvL" case $rules in INPUT | FORWARD) $f $1 ;; PORTFW) setup-portfw.sh status | grep -v '^#' ;; DMZ) $f INPUT | grep -e ^Chain -e ^num -e dmz-inp $f dmz-inp $f FORWARD | grep -e ^Chain -e ^num -e dmz-fwd $f dmz-fwd $n PREROUTING $n POSTROUTING ;; all) $f $n ;; *[,:]*) for p in `echo $rules | sed -e 's/,/ /g'` do set `echo $p | sed -e 's/:/ /g'` case $# in 1) $f $1 ;; 2) iptables --line-numbers -t $1 -nvL $2 ;; esac done ;; *) $f INPUT $f FORWARD $n POSTROUTING ;; esac } format_output () { while read line do case "$line" in '') ;; Chain*) case $head in yes) echo '' show_tab_footer ;; esac show_tab_header "$line" no echo '
/;s/[[:space:]]\+/<\/th> | /g' echo " | additional restrictions | " #config source | comment | " ;; *) set -f set -- $line def=`echo "$1 $2 $3 $4 $5 $6 $7 $8 $9 ${10}" | sed -e 's/^//;s/[[:space:]]\+/<\/td> | /g;s/$/<\/td>/;s# | \(all\|[*]\|--\|0\.\0\.\0\.0/0\) | #\ | #g'` target=$4 shift 10 restr=`echo "$* | " | sed -e 's,/[*].*[*]/,,;s## | \ | #g'` if echo "$*" | grep -q '/\*.*\*/'; then comment="`echo "$*" | sed -e 's#.*/\*\(.*\)\*/[^*/]*#\1#'`" else comment="" fi echo "
---|---|---|---|
$comment |
" dump_rules $FORM_action echo "" ;; *) dump_rules $FORM_action | format_output ;; esac show_tab_footer show_html_footer