Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Tuesday, March 19, 2024

Diff for scripts/shell/firewall/fw-universal.sh between version 2.26 and 2.27

version 2.26, 2005/06/29 16:16:46 version 2.27, 2005/08/04 19:39:11
Line 9 
Line 9 
 # Licensed under terms of GNU General Public License.  # Licensed under terms of GNU General Public License.
 # All rights reserved.  # All rights reserved.
 #  #
 # $Platon: scripts/shell/firewall/fw-universal.sh,v 2.25 2005/06/29 15:24:04 rajo Exp $  # $Platon: scripts/shell/firewall/fw-universal.sh,v 2.26 2005/06/29 16:16:46 rajo Exp $
 #  #
 # Changelog:  # Changelog:
 # 2003-10-24 - created  # 2003-10-24 - created
Line 19  DESC="firewall"
Line 19  DESC="firewall"
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
   
 DEFAULT_FIREWALL_CONFIG="${DEFAULT_FIREWALL_CONFIG:=/etc/default/firewall}"  DEFAULT_FIREWALL_CONFIG="${DEFAULT_FIREWALL_CONFIG:=/etc/default/firewall}"
   DEFAULT_CACHE_DIR="${DEFAULT_CACHE_DIR:=/var/cache/firewall}"
   
 if [ -f "$DEFAULT_FIREWALL_CONFIG" ]; then  if [ -f "$DEFAULT_FIREWALL_CONFIG" ]; then
         echo "Reading config file $DEFAULT_FIREWALL_CONFIG"          echo "Reading config file $DEFAULT_FIREWALL_CONFIG"
Line 40  LOG_LIMIT="${LOG_LIMIT:=-m limit --limit
Line 41  LOG_LIMIT="${LOG_LIMIT:=-m limit --limit
 # Paths:  # Paths:
 #IPTABLES=":" # for testing only - does nothing  #IPTABLES=":" # for testing only - does nothing
 IPTABLES="${IPTABLES:=$DEBUG/sbin/iptables}"  IPTABLES="${IPTABLES:=$DEBUG/sbin/iptables}"
   IPTABLES_SAVE="${IPTABLES_SAVE:=$DEBUG/sbin/iptables-save}"
   IPTABLES_RESTORE="${IPTABLES_RESTORE:=$DEBUG/sbin/iptables-restore}"
   
 if [ "x$LOGGING" = "xoff" ]; then  if [ "x$LOGGING" = "xoff" ]; then
         IPTABLES_LOG=": log turned off"          IPTABLES_LOG=": log turned off"
 else  else
Line 88  load_modules()
Line 92  load_modules()
         fi          fi
 } # }}}  } # }}}
   
   load_cache()
   { # {{{
   
           if [ ! -d "$DEFAULT_CACHE_DIR" ]; then
                   mkdir -p "$DEFAULT_CACHE_DIR";
           fi
   
           config=`cat $DEFAULT_FIREWALL_CONFIG`;
           md5key=`echo "config = '$config' parsed_interfaces ='$parsed_interfaces' parsed_routes='$parsed_routes'" | md5sum | awk '{ print $1; }'`;
           CACHE_FILE="$DEFAULT_CACHE_DIR/$md5key"
   
           #echo "CACHE_FILE=$CACHE_FILE"
   
           if [ -f "$CACHE_FILE" ]; then
                   echo "Loading rules from cache file $CACHE_FILE"
                   $IPTABLES_RESTORE -c < $CACHE_FILE;
                   exit 0;
           fi
   } # }}}
   
 # unload necessary modules from $MODULES variable  # unload necessary modules from $MODULES variable
 unload_modules()  unload_modules()
 { # {{{  { # {{{
Line 646  accept_loopback()
Line 670  accept_loopback()
 parse_ifconfig()  parse_ifconfig()
 { # {{{  { # {{{
         # Parse output from ifconfig:          # Parse output from ifconfig:
         eval `$IFCONFIG | \          parsed_interfaces=`$IFCONFIG | \
                 $AWK 'BEGIN { interfaces=""; }                  $AWK 'BEGIN { interfaces=""; }
                         /^[a-zA-Z0-9]+[ \t]+/ { # Linux                          /^[a-zA-Z0-9]+[ \t]+/ { # Linux
                                 iface=$1;                                  iface=$1;
Line 676  parse_ifconfig()
Line 700  parse_ifconfig()
                         }                          }
                         END { printf "\ninterfaces=\"%s\";      export interfaces;\n", interfaces; }                          END { printf "\ninterfaces=\"%s\";      export interfaces;\n", interfaces; }
         '`          '`
           eval "$parsed_interfaces";
   
         eval `perl -e '          parsed_routes=`perl -e '
         $\ = "\n";          $\ = "\n";
         open(FILE, "/proc/net/route") or die "Can not open /proc/net/route: $!";          open(FILE, "/proc/net/route") or die "Can not open /proc/net/route: $!";
         my @columns = split(/\s+/, <FILE>);          my @columns = split(/\s+/, <FILE>);
Line 724  parse_ifconfig()
Line 749  parse_ifconfig()
   
         } # }}}          } # }}}
         '`          '`
           eval "$parsed_routes";
   
         # Now we have defined variables like this:          # Now we have defined variables like this:
         # IFACE_eth0 HWaddr_eth0 IP_eth0 Bcast_eth0 Mask_eth0          # IFACE_eth0 HWaddr_eth0 IP_eth0 Bcast_eth0 Mask_eth0
         # IFACE_lo   HWaddr_lo   IP_lo   Bcast_lo   Mask_lo          # IFACE_lo   HWaddr_lo   IP_lo   Bcast_lo   Mask_lo
Line 764  case "$1" in
Line 791  case "$1" in
         start)          start)
                 echo -n "Starting $DESC: "                  echo -n "Starting $DESC: "
                 # Inicialize modules                  # Inicialize modules
                 $DEPMOD -a                  #$DEPMOD -a
                 load_modules                  load_modules
                   load_cache
                 set_default_policy                  set_default_policy
                 remove_chains                  remove_chains
                 #                  #
Line 790  case "$1" in
Line 818  case "$1" in
                 log_input_drop                  log_input_drop
                 log_output_drop                  log_output_drop
                 log_forward_drop                  log_forward_drop
                   $IPTABLES_SAVE -c > $CACHE_FILE
                 ;;                  ;;
   
         stop)          stop)
Line 814  case "$1" in
Line 843  case "$1" in
                 $IPTABLES -L -nv                  $IPTABLES -L -nv
                 ;;                  ;;
   
           purge)
                   find $DEFAULT_CACHE_DIR -type f -ls -exec rm -f {} \;
                   ;;
   
         *)          *)
                 echo "Usage: $0 {start|stop|really-off|status}" >&2                  echo "Usage: $0 {start|stop|really-off|status|purge}" >&2
                 exit 1                  exit 1
                 ;;                  ;;
 esac  esac

Legend:
Removed from v.2.26  
changed lines
  Added in v.2.27

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top