2007-03-08 05:38:37 +01:00
|
|
|
#! /usr/bin/perl -w
|
2007-03-15 22:55:22 +01:00
|
|
|
#
|
2007-03-28 18:19:35 +02:00
|
|
|
# The Shoreline Firewall4 (Shorewall-perl) Packet Filtering Firewall Compiler - V3.9
|
2007-03-15 22:55:22 +01:00
|
|
|
#
|
|
|
|
# This program is under GPL [http://www.gnu.org/copyleft/gpl.htm]
|
|
|
|
#
|
|
|
|
# (c) 2007 - Tom Eastep (teastep@shorewall.net)
|
|
|
|
#
|
|
|
|
# Complete documentation is available at http://shorewall.net
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of Version 2 of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
|
|
|
|
#
|
|
|
|
# Commands are:
|
|
|
|
#
|
|
|
|
# compiler.pl Verify the configuration files.
|
|
|
|
# compile <path name> Compile into <path name>
|
|
|
|
#
|
|
|
|
# Environmental Variables are set up by the Compiler wrapper ('compiler' program).
|
|
|
|
#
|
|
|
|
# EXPORT=Yes -e option specified to /sbin/shorewall
|
|
|
|
# SHOREWALL_DIR A directory name was passed to /sbin/shorewall
|
|
|
|
# VERBOSE Standard Shorewall verbosity control.
|
|
|
|
# VERSION Shorewall Version
|
|
|
|
# TMP_DIR Temporary Directory containing stripped copies
|
|
|
|
# of all configuration files. Shell variable substitution
|
|
|
|
# has been performed on these files.
|
|
|
|
# TIMESTAMP=Yes -t option specified to /sbin/shorewall
|
2007-03-29 19:36:04 +02:00
|
|
|
# FW Firewall zone (for shell-variable expansion).
|
2007-03-15 22:55:22 +01:00
|
|
|
#
|
|
|
|
# This program performs rudimentary shell variable expansion on action and macro files.
|
2007-03-08 05:38:37 +01:00
|
|
|
|
|
|
|
use strict;
|
2007-03-28 18:19:35 +02:00
|
|
|
use lib '/usr/share/shorewall-perl';
|
2007-03-14 03:44:41 +01:00
|
|
|
use Shorewall::Common;
|
|
|
|
use Shorewall::Config;
|
2007-03-14 04:12:22 +01:00
|
|
|
use Shorewall::Chains;
|
2007-03-14 04:19:25 +01:00
|
|
|
use Shorewall::Zones;
|
2007-03-14 04:24:28 +01:00
|
|
|
use Shorewall::Interfaces;
|
2007-03-14 16:23:07 +01:00
|
|
|
use Shorewall::Hosts;
|
2007-03-25 23:04:24 +02:00
|
|
|
use Shorewall::Policy;
|
2007-03-15 02:04:43 +01:00
|
|
|
use Shorewall::Nat;
|
2007-03-21 00:13:17 +01:00
|
|
|
use Shorewall::Providers;
|
2007-03-15 02:10:56 +01:00
|
|
|
use Shorewall::Tc;
|
2007-03-15 02:15:05 +01:00
|
|
|
use Shorewall::Tunnels;
|
2007-03-15 03:46:00 +01:00
|
|
|
use Shorewall::Macros;
|
2007-03-15 03:18:29 +01:00
|
|
|
use Shorewall::Actions;
|
2007-03-15 03:50:09 +01:00
|
|
|
use Shorewall::Accounting;
|
2007-03-15 04:17:56 +01:00
|
|
|
use Shorewall::Rules;
|
2007-03-16 17:26:34 +01:00
|
|
|
use Shorewall::Proc;
|
2007-03-17 00:07:50 +01:00
|
|
|
use Shorewall::Proxyarp;
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
#
|
|
|
|
# First stage of script generation.
|
|
|
|
#
|
|
|
|
# Copy the prog.header to the generated script.
|
|
|
|
# Generate the various user-exit jacket functions.
|
|
|
|
# Generate the 'initialize()' function.
|
|
|
|
#
|
|
|
|
|
2007-03-13 23:03:59 +01:00
|
|
|
sub generate_script_1 {
|
2007-03-25 18:38:00 +02:00
|
|
|
copy $env{SHAREDIRPL} . 'prog.header';
|
2007-03-12 02:04:21 +01:00
|
|
|
|
|
|
|
my $date = localtime;
|
|
|
|
|
2007-03-28 18:19:35 +02:00
|
|
|
emit "#\n# Compiled firewall script generated by Shorewall-perl $env{VERSION} - $date\n#";
|
2007-03-12 02:04:21 +01:00
|
|
|
|
|
|
|
if ( $ENV{EXPORT} ) {
|
2007-03-26 04:53:51 +02:00
|
|
|
emitj ( 'SHAREDIR=/usr/share/shorewall-lite',
|
|
|
|
'CONFDIR=/etc/shorewall-lite',
|
|
|
|
'VARDIR=/var/lib/shorewall-lite',
|
2007-03-27 05:39:12 +02:00
|
|
|
'PRODUCT="Shorewall Lite"'
|
|
|
|
);
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-12 02:04:21 +01:00
|
|
|
copy "$env{SHAREDIR}/lib.base";
|
2007-03-27 02:59:01 +02:00
|
|
|
|
2007-03-26 04:53:51 +02:00
|
|
|
emitj ( '################################################################################',
|
2007-03-27 02:59:01 +02:00
|
|
|
'# End of /usr/share/shorewall/lib.base',
|
2007-03-27 05:39:12 +02:00
|
|
|
'################################################################################'
|
|
|
|
);
|
2007-03-12 02:04:21 +01:00
|
|
|
} else {
|
2007-03-26 04:53:51 +02:00
|
|
|
emitj ( 'SHAREDIR=/usr/share/shorewall',
|
|
|
|
'CONFDIR=/etc/shorewall',
|
|
|
|
'VARDIR=/var/lib/shorewall',
|
|
|
|
'PRODUCT=\'Shorewall\'',
|
2007-03-27 05:39:12 +02:00
|
|
|
'. /usr/share/shorewall/lib.base'
|
|
|
|
);
|
2007-03-12 02:04:21 +01:00
|
|
|
}
|
2007-03-22 19:24:33 +01:00
|
|
|
|
2007-03-27 04:52:46 +02:00
|
|
|
emit "TEMPFILE=\n";
|
2007-03-27 02:59:01 +02:00
|
|
|
|
2007-03-27 04:25:08 +02:00
|
|
|
for my $exit qw/init start tcclear started stop stopped/ {
|
|
|
|
emit "run_${exit}_exit() {";
|
|
|
|
push_indent;
|
|
|
|
append_file $exit;
|
|
|
|
emit 'true';
|
|
|
|
pop_indent;
|
|
|
|
emit "}\n";
|
|
|
|
}
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-27 04:52:46 +02:00
|
|
|
emitj ( 'initialize()',
|
|
|
|
'{'
|
|
|
|
);
|
2007-03-12 02:04:21 +01:00
|
|
|
|
2007-03-13 23:03:59 +01:00
|
|
|
push_indent;
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-12 02:04:21 +01:00
|
|
|
if ( $ENV{EXPORT} ) {
|
2007-03-26 04:53:51 +02:00
|
|
|
emitj ( '#',
|
|
|
|
'# These variables are required by the library functions called in this script',
|
|
|
|
'#',
|
|
|
|
'CONFIG_PATH="/etc/shorewall-lite:/usr/share/shorewall-lite"' );
|
2007-03-12 02:04:21 +01:00
|
|
|
} else {
|
2007-03-26 04:53:51 +02:00
|
|
|
emitj ( 'if [ ! -f ${SHAREDIR}/version ]; then',
|
|
|
|
' fatal_error "This script requires Shorewall which do not appear to be installed on this system (did you forget \"-e\" when you compiled?)"',
|
|
|
|
'fi',
|
|
|
|
'',
|
|
|
|
'local version=$(cat ${SHAREDIR}/version)',
|
|
|
|
'',
|
|
|
|
'if [ ${SHOREWALL_LIBVERSION:-0} -lt 30401 ]; then',
|
|
|
|
' fatal_error "This script requires Shorewall version 3.4.2 or later; current version is $version"',
|
|
|
|
'fi',
|
|
|
|
'#',
|
|
|
|
'# These variables are required by the library functions called in this script',
|
|
|
|
'#',
|
2007-03-28 18:07:40 +02:00
|
|
|
qq(CONFIG_PATH="$config{CONFIG_PATH}") );
|
2007-03-12 02:04:21 +01:00
|
|
|
}
|
2007-03-14 03:44:41 +01:00
|
|
|
|
|
|
|
propagateconfig;
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-26 04:53:51 +02:00
|
|
|
emitj ( '[ -n "${COMMAND:=restart}" ]',
|
|
|
|
'[ -n "${VERBOSE:=0}" ]',
|
2007-03-28 18:07:40 +02:00
|
|
|
qq([ -n "\${RESTOREFILE:=$config{RESTOREFILE}}" ]),
|
2007-03-26 04:53:51 +02:00
|
|
|
'[ -n "$LOGFORMAT" ] || LOGFORMAT="Shorewall:%s:%s:"',
|
|
|
|
qq(VERSION="$env{VERSION}") ,
|
|
|
|
qq(PATH="$config{PATH}") ,
|
2007-03-27 05:39:12 +02:00
|
|
|
'TERMINATOR=fatal_error'
|
|
|
|
);
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-12 02:04:21 +01:00
|
|
|
if ( $config{IPTABLES} ) {
|
2007-03-28 18:07:40 +02:00
|
|
|
emitj( qq(IPTABLES="$config{IPTABLES}"),
|
2007-03-27 04:25:08 +02:00
|
|
|
'',
|
2007-03-28 18:07:40 +02:00
|
|
|
'[ -x "$IPTABLES" ] || startup_error "IPTABLES=$IPTABLES does not exist or is not executable"',
|
2007-03-27 05:39:12 +02:00
|
|
|
);
|
2007-03-12 02:04:21 +01:00
|
|
|
} else {
|
2007-03-27 04:25:08 +02:00
|
|
|
emitj( '[ -z "$IPTABLES" ] && IPTABLES=$(mywhich iptables 2> /dev/null)',
|
2007-03-27 04:52:46 +02:00
|
|
|
'',
|
2007-03-27 05:39:12 +02:00
|
|
|
'[ -n "$IPTABLES" -a -x "$IPTABLES" ] || startup_error "Can\'t find iptables executable"'
|
|
|
|
);
|
2007-03-12 02:04:21 +01:00
|
|
|
}
|
|
|
|
|
2007-03-21 21:08:05 +01:00
|
|
|
append_file 'params' if $config{EXPORTPARAMS};
|
|
|
|
|
2007-03-26 04:53:51 +02:00
|
|
|
emitj ( '',
|
|
|
|
"STOPPING=",
|
2007-03-28 18:07:40 +02:00
|
|
|
'COMMENT=', # Maintain compability with lib.base
|
|
|
|
'',
|
2007-03-26 04:53:51 +02:00
|
|
|
'#',
|
|
|
|
'# The library requires that ${VARDIR} exist',
|
|
|
|
'#',
|
2007-03-27 05:39:12 +02:00
|
|
|
'[ -d ${VARDIR} ] || mkdir -p ${VARDIR}'
|
|
|
|
);
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-13 23:03:59 +01:00
|
|
|
pop_indent;
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
emit "}\n"; # End of initialize()
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-16 00:18:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sub compile_stop_firewall() {
|
2007-03-26 03:49:31 +02:00
|
|
|
|
2007-03-28 22:16:19 +02:00
|
|
|
emit <<'EOF';
|
|
|
|
#
|
2007-03-29 01:21:37 +02:00
|
|
|
# Stop/restore the firewall after an error or because of a 'stop' or 'clear' command
|
2007-03-16 00:18:58 +01:00
|
|
|
#
|
|
|
|
stop_firewall() {
|
|
|
|
|
|
|
|
deletechain() {
|
2007-03-28 18:07:40 +02:00
|
|
|
qt $IPTABLES -L $1 -n && qt $IPTABLES -F $1 && qt $IPTABLES -X $1
|
2007-03-16 00:18:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
deleteallchains() {
|
2007-03-28 18:07:40 +02:00
|
|
|
$IPTABLES -F
|
|
|
|
$IPTABLES -X
|
2007-03-16 00:18:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setcontinue() {
|
2007-03-28 18:07:40 +02:00
|
|
|
$IPTABLES -A $1 -m state --state ESTABLISHED,RELATED -j ACCEPT
|
2007-03-16 00:18:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
delete_nat() {
|
2007-03-28 18:07:40 +02:00
|
|
|
$IPTABLES -t nat -F
|
|
|
|
$IPTABLES -t nat -X
|
2007-03-16 00:18:58 +01:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
if [ -f ${VARDIR}/nat ]; then
|
2007-03-16 00:18:58 +01:00
|
|
|
while read external interface; do
|
2007-03-28 18:07:40 +02:00
|
|
|
del_ip_addr $external $interface
|
|
|
|
done < ${VARDIR}/nat
|
2007-03-16 00:18:58 +01:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
rm -f ${VARDIR}/nat
|
2007-03-16 00:18:58 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
case $COMMAND in
|
2007-03-29 22:47:14 +02:00
|
|
|
stop|clear|restore)
|
2007-03-16 00:18:58 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
set +x
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
case $COMMAND in
|
2007-03-16 00:18:58 +01:00
|
|
|
start)
|
2007-03-28 18:07:40 +02:00
|
|
|
logger -p kern.err "ERROR:$PRODUCT start failed"
|
2007-03-16 00:18:58 +01:00
|
|
|
;;
|
|
|
|
restart)
|
2007-03-28 18:07:40 +02:00
|
|
|
logger -p kern.err "ERROR:$PRODUCT restart failed"
|
2007-03-16 00:18:58 +01:00
|
|
|
;;
|
|
|
|
restore)
|
2007-03-28 18:07:40 +02:00
|
|
|
logger -p kern.err "ERROR:$PRODUCT restore failed"
|
2007-03-16 00:18:58 +01:00
|
|
|
;;
|
|
|
|
esac
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
if [ "$RESTOREFILE" = NONE ]; then
|
2007-03-16 00:18:58 +01:00
|
|
|
COMMAND=clear
|
|
|
|
clear_firewall
|
2007-03-28 18:07:40 +02:00
|
|
|
echo "$PRODUCT Cleared"
|
2007-03-16 00:18:58 +01:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
kill $$
|
2007-03-16 00:18:58 +01:00
|
|
|
exit 2
|
|
|
|
else
|
2007-03-28 18:07:40 +02:00
|
|
|
RESTOREPATH=${VARDIR}/$RESTOREFILE
|
2007-03-16 00:18:58 +01:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
if [ -x $RESTOREPATH ]; then
|
2007-03-16 00:18:58 +01:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
if [ -x ${RESTOREPATH}-ipsets ]; then
|
2007-03-16 00:18:58 +01:00
|
|
|
progress_message2 Restoring Ipsets...
|
|
|
|
#
|
|
|
|
# We must purge iptables to be sure that there are no
|
|
|
|
# references to ipsets
|
|
|
|
#
|
|
|
|
for table in mangle nat filter; do
|
2007-03-28 18:07:40 +02:00
|
|
|
$IPTABLES -t $table -F
|
|
|
|
$IPTABLES -t $table -X
|
2007-03-16 00:18:58 +01:00
|
|
|
done
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
${RESTOREPATH}-ipsets
|
2007-03-16 00:18:58 +01:00
|
|
|
fi
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
echo Restoring ${PRODUCT:=Shorewall}...
|
2007-03-16 00:18:58 +01:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
if $RESTOREPATH restore; then
|
|
|
|
echo "$PRODUCT restored from $RESTOREPATH"
|
|
|
|
set_state "Started"
|
2007-03-16 00:18:58 +01:00
|
|
|
else
|
2007-03-28 18:07:40 +02:00
|
|
|
set_state "Unknown"
|
2007-03-16 00:18:58 +01:00
|
|
|
fi
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
kill $$
|
2007-03-16 00:18:58 +01:00
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
set_state "Stopping"
|
2007-03-16 00:18:58 +01:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
STOPPING="Yes"
|
2007-03-16 00:18:58 +01:00
|
|
|
|
|
|
|
TERMINATOR=
|
|
|
|
|
|
|
|
deletechain shorewall
|
|
|
|
|
|
|
|
determine_capabilities
|
|
|
|
|
|
|
|
run_stop_exit;
|
2007-03-16 01:58:25 +01:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
if [ -n "$MANGLE_ENABLED" ]; then
|
2007-03-16 00:18:58 +01:00
|
|
|
run_iptables -t mangle -F
|
|
|
|
run_iptables -t mangle -X
|
|
|
|
for chain in PREROUTING INPUT FORWARD POSTROUTING; do
|
2007-03-28 18:07:40 +02:00
|
|
|
qt $IPTABLES -t mangle -P $chain ACCEPT
|
2007-03-16 00:18:58 +01:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
if [ -n "$RAW_TABLE" ]; then
|
2007-03-16 00:18:58 +01:00
|
|
|
run_iptables -t raw -F
|
|
|
|
run_iptables -t raw -X
|
|
|
|
for chain in PREROUTING OUTPUT; do
|
2007-03-28 18:07:40 +02:00
|
|
|
qt $IPTABLES -t raw -P $chain ACCEPT
|
2007-03-16 00:18:58 +01:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
if [ -n "$NAT_ENABLED" ]; then
|
2007-03-16 00:18:58 +01:00
|
|
|
delete_nat
|
|
|
|
for chain in PREROUTING POSTROUTING OUTPUT; do
|
2007-03-28 18:07:40 +02:00
|
|
|
qt $IPTABLES -t nat -P $chain ACCEPT
|
2007-03-16 00:18:58 +01:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
if [ -f ${VARDIR}/proxyarp ]; then
|
2007-03-16 00:18:58 +01:00
|
|
|
while read address interface external haveroute; do
|
2007-03-28 18:07:40 +02:00
|
|
|
qt arp -i $external -d $address pub
|
|
|
|
[ -z "${haveroute}${NOROUTES}" ] && qt ip route del $address dev $interface
|
|
|
|
done < ${VARDIR}/proxyarp
|
2007-03-16 00:18:58 +01:00
|
|
|
|
|
|
|
for f in /proc/sys/net/ipv4/conf/*; do
|
2007-03-28 18:07:40 +02:00
|
|
|
[ -f $f/proxy_arp ] && echo 0 > $f/proxy_arp
|
2007-03-16 00:18:58 +01:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
rm -f ${VARDIR}/proxyarp
|
2007-03-28 22:16:19 +02:00
|
|
|
EOF
|
2007-03-16 01:58:25 +01:00
|
|
|
|
2007-03-27 07:07:57 +02:00
|
|
|
push_indent;
|
|
|
|
|
|
|
|
emit 'delete_tc1' if $config{CLEAR_TC};
|
2007-03-27 05:39:12 +02:00
|
|
|
|
2007-03-27 07:07:57 +02:00
|
|
|
emitj( 'undo_routing',
|
|
|
|
'restore_default_route'
|
2007-03-27 05:39:12 +02:00
|
|
|
);
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-16 01:58:25 +01:00
|
|
|
my $criticalhosts = process_criticalhosts;
|
2007-03-16 00:18:58 +01:00
|
|
|
|
2007-03-16 03:35:51 +01:00
|
|
|
if ( @$criticalhosts ) {
|
2007-03-16 00:18:58 +01:00
|
|
|
if ( $config{ADMINISABSENTMINDED} ) {
|
2007-03-27 07:07:57 +02:00
|
|
|
emitj ( 'for chain in INPUT OUTPUT; do',
|
|
|
|
' setpolicy $chain ACCEPT',
|
|
|
|
'done',
|
2007-03-27 01:17:46 +02:00
|
|
|
'',
|
2007-03-27 07:07:57 +02:00
|
|
|
'setpolicy FORWARD DROP',
|
2007-03-27 01:17:46 +02:00
|
|
|
'',
|
2007-03-27 07:07:57 +02:00
|
|
|
'deleteallchains',
|
2007-03-27 05:39:12 +02:00
|
|
|
''
|
|
|
|
);
|
2007-03-16 00:18:58 +01:00
|
|
|
|
2007-03-16 01:58:25 +01:00
|
|
|
for my $hosts ( @$criticalhosts ) {
|
2007-03-19 19:29:58 +01:00
|
|
|
my ( $interface, $host ) = ( split /:/, $hosts );
|
2007-03-16 01:58:25 +01:00
|
|
|
my $source = match_source_net $host;
|
|
|
|
my $dest = match_dest_net $host;
|
|
|
|
|
2007-03-27 07:07:57 +02:00
|
|
|
emitj( "\$IPTABLES -A INPUT -i $interface $source -j ACCEPT",
|
|
|
|
"\$IPTABLES -A OUTPUT -o $interface $dest -j ACCEPT"
|
2007-03-27 05:39:12 +02:00
|
|
|
);
|
2007-03-16 01:58:25 +01:00
|
|
|
}
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-27 07:07:57 +02:00
|
|
|
emitj( '',
|
|
|
|
'for chain in INPUT OUTPUT; do',
|
|
|
|
' setpolicy $chain DROP',
|
|
|
|
"done\n"
|
|
|
|
);
|
2007-03-27 02:59:01 +02:00
|
|
|
} else {
|
2007-03-27 07:07:57 +02:00
|
|
|
emitj( '',
|
|
|
|
'for chain in INPUT OUTPUT; do',
|
|
|
|
' setpolicy \$chain ACCEPT',
|
|
|
|
'done',
|
|
|
|
'',
|
|
|
|
'setpolicy FORWARD DROP',
|
|
|
|
'',
|
|
|
|
"deleteallchains\n"
|
|
|
|
);
|
2007-03-16 01:58:25 +01:00
|
|
|
|
|
|
|
for my $hosts ( @$criticalhosts ) {
|
2007-03-27 02:59:01 +02:00
|
|
|
my ( $interface, $host ) = ( split /:/, $hosts );
|
2007-03-16 01:58:25 +01:00
|
|
|
my $source = match_source_net $host;
|
|
|
|
my $dest = match_dest_net $host;
|
|
|
|
|
2007-03-27 07:07:57 +02:00
|
|
|
emitj( "\$IPTABLES -A INPUT -i $interface $source -j ACCEPT",
|
|
|
|
"\$IPTABLES -A OUTPUT -o $interface $dest -j ACCEPT"
|
2007-03-27 05:39:12 +02:00
|
|
|
);
|
2007-03-16 01:58:25 +01:00
|
|
|
}
|
|
|
|
|
2007-03-27 07:07:57 +02:00
|
|
|
emitj ( "\nsetpolicy INPUT DROP",
|
|
|
|
'',
|
|
|
|
'for chain in INPUT FORWARD; do',
|
|
|
|
' setcontinue $chain',
|
|
|
|
"done\n"
|
|
|
|
);
|
2007-03-16 01:58:25 +01:00
|
|
|
}
|
2007-03-28 16:20:46 +02:00
|
|
|
} elsif ( $config{ADMINISABSENTMINDED} ) {
|
|
|
|
emitj( 'for chain in INPUT FORWARD; do',
|
|
|
|
' setpolicy $chain DROP',
|
|
|
|
'done',
|
|
|
|
'',
|
|
|
|
'setpolicy OUTPUT ACCEPT',
|
|
|
|
'',
|
|
|
|
'deleteallchains',
|
|
|
|
'',
|
|
|
|
'for chain in INPUT FORWARD; do',
|
|
|
|
' setcontinue $chain',
|
|
|
|
"done\n",
|
|
|
|
);
|
|
|
|
} else {
|
2007-03-27 07:07:57 +02:00
|
|
|
emitj( 'for chain in INPUT OUTPUT FORWARD; do',
|
|
|
|
' setpolicy $chain DROP',
|
|
|
|
'done',
|
|
|
|
'',
|
|
|
|
"deleteallchains\n"
|
|
|
|
);
|
2007-03-28 16:20:46 +02:00
|
|
|
}
|
2007-03-16 01:58:25 +01:00
|
|
|
|
|
|
|
process_routestopped;
|
|
|
|
|
2007-03-27 05:39:12 +02:00
|
|
|
emitj( '$IPTABLES -A INPUT -i lo -j ACCEPT',
|
|
|
|
'$IPTABLES -A OUTPUT -o lo -j ACCEPT'
|
|
|
|
);
|
2007-03-27 07:07:57 +02:00
|
|
|
|
2007-03-16 01:58:25 +01:00
|
|
|
emit '$IPTABLES -A OUTPUT -o lo -j ACCEPT' unless $config{ADMINISABSENTMINDED};
|
|
|
|
|
|
|
|
my $interfaces = find_interfaces_by_option 'dhcp';
|
|
|
|
|
|
|
|
for my $interface ( @$interfaces ) {
|
|
|
|
emit "\$IPTABLES -A INPUT -p udp -i $interface --dport 67:68 -j ACCEPT";
|
|
|
|
emit "\$IPTABLES -A OUTPUT -p udp -o $interface --dport 67:68 -j ACCEPT" unless $config{ADMINISABSENTMINDED};
|
|
|
|
#
|
|
|
|
# This might be a bridge
|
|
|
|
#
|
|
|
|
emit "\$IPTABLES -A FORWARD -p udp -i $interface -o $interface --dport 67:68 -j ACCEPT";
|
|
|
|
}
|
|
|
|
|
|
|
|
emit '';
|
|
|
|
|
|
|
|
if ( $config{IP_FORWARDING} =~ /on/i ) {
|
2007-03-27 05:39:12 +02:00
|
|
|
emitj( 'echo 1 > /proc/sys/net/ipv4/ip_forward',
|
|
|
|
'progress_message2 IP Forwarding Enabled' );
|
2007-03-16 01:58:25 +01:00
|
|
|
} elsif ( $config{IP_FORWARDING} =~ /off/i ) {
|
2007-03-27 05:39:12 +02:00
|
|
|
emitj( 'echo 0 > /proc/sys/net/ipv4/ip_forward',
|
|
|
|
'progress_message2 IP Forwarding Disabled!'
|
|
|
|
);
|
2007-03-16 01:58:25 +01:00
|
|
|
}
|
2007-03-27 01:17:46 +02:00
|
|
|
|
2007-03-21 17:21:37 +01:00
|
|
|
emit 'run_stopped_exit';
|
2007-03-16 01:58:25 +01:00
|
|
|
|
|
|
|
pop_indent;
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
emit '
|
|
|
|
set_state "Stopped"
|
2007-03-16 01:58:25 +01:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
logger -p kern.info "$PRODUCT Stopped"
|
2007-03-16 01:58:25 +01:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
case $COMMAND in
|
2007-03-16 01:58:25 +01:00
|
|
|
stop|clear)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
#
|
|
|
|
# The firewall is being stopped when we were trying to do something
|
2007-03-28 18:07:40 +02:00
|
|
|
# else. Kill the shell in case we\'re running in a subshell
|
2007-03-16 01:58:25 +01:00
|
|
|
#
|
2007-03-28 18:07:40 +02:00
|
|
|
kill $$
|
2007-03-16 01:58:25 +01:00
|
|
|
;;
|
|
|
|
esac
|
2007-03-27 01:17:46 +02:00
|
|
|
}
|
2007-03-28 18:07:40 +02:00
|
|
|
';
|
2007-03-16 17:26:34 +01:00
|
|
|
|
2007-03-13 23:03:59 +01:00
|
|
|
}
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
#
|
|
|
|
# Second Phase of Script Generation
|
|
|
|
#
|
|
|
|
# copies the 'prog.functions' file into the script
|
|
|
|
# generates the first part of 'setup_routing_and_traffic_shaping()'
|
|
|
|
#
|
|
|
|
# The bulk of that function is produced by the various config file
|
|
|
|
# parsing routines that are called directly out of 'compiler()'.
|
|
|
|
#
|
2007-03-13 23:03:59 +01:00
|
|
|
sub generate_script_2 () {
|
2007-03-16 00:18:58 +01:00
|
|
|
|
2007-03-25 18:38:00 +02:00
|
|
|
copy $env{SHAREDIRPL} . 'prog.functions';
|
2007-03-16 00:18:58 +01:00
|
|
|
|
2007-03-27 05:39:12 +02:00
|
|
|
emitj( '#',
|
|
|
|
'# Setup Routing and Traffic Shaping',
|
|
|
|
'#',
|
|
|
|
'setup_routing_and_traffic_shaping() {'
|
|
|
|
);
|
2007-03-14 03:44:41 +01:00
|
|
|
|
|
|
|
push_indent;
|
2007-03-12 02:04:21 +01:00
|
|
|
|
|
|
|
emit 'local restore_file=$1';
|
|
|
|
|
|
|
|
save_progress_message 'Initializing...';
|
|
|
|
|
|
|
|
if ( $ENV{EXPORT} ) {
|
|
|
|
my $mf = find_file 'modules';
|
|
|
|
|
|
|
|
if ( $mf ne "$env{SHAREDIR}/module" && -f $mf ) {
|
|
|
|
|
2007-03-27 05:39:12 +02:00
|
|
|
emitj( 'echo MODULESDIR="$MODULESDIR" > ${VARDIR}/.modulesdir',
|
|
|
|
'cat > ${VARDIR}/.modules << EOF'
|
|
|
|
);
|
2007-03-12 02:04:21 +01:00
|
|
|
|
|
|
|
open MF, $mf or fatal_error "Unable to open $mf: $!";
|
|
|
|
|
2007-03-15 04:56:40 +01:00
|
|
|
while ( $line = <MF> ) { emit_as_is $line if $line =~ /^\s*loadmodule\b/; }
|
2007-03-12 02:04:21 +01:00
|
|
|
|
|
|
|
close MF;
|
|
|
|
|
|
|
|
emit_unindented "EOF\n";
|
|
|
|
|
|
|
|
emit 'reload_kernel_modules < ${VARDIR}/.modules';
|
|
|
|
} else {
|
|
|
|
emit 'load_kernel_modules Yes';
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
emit 'load_kernel_modules Yes';
|
|
|
|
}
|
|
|
|
|
|
|
|
emit '';
|
|
|
|
|
|
|
|
for my $interface ( @{find_interfaces_by_option 'norfc1918'} ) {
|
2007-03-26 04:53:51 +02:00
|
|
|
emitj ( "addr=\$(ip -f inet addr show $interface 2> /dev/null | grep 'inet\ ' | head -n1)",
|
|
|
|
'if [ -n "$addr" ]; then',
|
|
|
|
' addr=$(echo $addr | sed \'s/inet //;s/\/.*//;s/ peer.*//\')',
|
|
|
|
' for network in 10.0.0.0/8 176.16.0.0/12 192.168.0.0/16; do',
|
|
|
|
' if in_network $addr $network; then',
|
2007-03-28 18:07:40 +02:00
|
|
|
" error_message \"WARNING: The 'norfc1918' option has been specified on an interface with an RFC 1918 address. Interface:$interface\"",
|
2007-03-26 04:53:51 +02:00
|
|
|
' fi',
|
|
|
|
' done',
|
|
|
|
"fi\n" );
|
2007-03-12 02:04:21 +01:00
|
|
|
}
|
|
|
|
|
2007-03-27 05:39:12 +02:00
|
|
|
emitj ( 'run_init_exit',
|
|
|
|
'',
|
|
|
|
'qt $IPTABLES -L shorewall -n && qt $IPTABLES -F shorewall && qt $IPTABLES -X shorewall',
|
|
|
|
'',
|
|
|
|
'delete_proxyarp',
|
|
|
|
''
|
|
|
|
);
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
emit "delete_tc1\n" if $config{CLEAR_TC};
|
|
|
|
emit "disable_ipv6\n" if $config{DISABLE_IPV6};
|
2007-03-17 00:57:43 +01:00
|
|
|
setup_mss( $config{CLAMPMSS} ) if $config{CLAMPMSS};
|
|
|
|
|
2007-03-14 00:11:15 +01:00
|
|
|
}
|
2007-03-12 03:59:12 +01:00
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
#
|
|
|
|
# Third (final stage of script generation).
|
|
|
|
#
|
|
|
|
# Generate the end of 'setup_routing_and_traffic_shaping()':
|
|
|
|
# Generate code for loading the various files in /var/lib/shorewall[-lite]
|
|
|
|
# Generate code to add IP addresses under ADD_IP_ALIASES and ADD_SNAT_ALIASES
|
2007-03-29 01:21:37 +02:00
|
|
|
#
|
2007-03-28 18:07:40 +02:00
|
|
|
# Generate the 'setup_netfilter()' function that runs iptables-restore.
|
|
|
|
# Generate the 'define_firewall()' function.
|
|
|
|
#
|
2007-03-14 00:11:15 +01:00
|
|
|
sub generate_script_3() {
|
2007-03-12 23:18:50 +01:00
|
|
|
|
2007-03-17 17:44:47 +01:00
|
|
|
emit 'cat > ${VARDIR}/proxyarp << __EOF__';
|
2007-03-21 21:35:40 +01:00
|
|
|
dump_proxy_arp;
|
2007-03-17 17:44:47 +01:00
|
|
|
emit_unindented '__EOF__';
|
|
|
|
|
2007-03-21 21:08:05 +01:00
|
|
|
emit 'cat > ${VARDIR}/chains << __EOF__';
|
2007-03-21 21:35:40 +01:00
|
|
|
dump_rule_chains;
|
|
|
|
emit_unindented '__EOF__';
|
|
|
|
|
|
|
|
emit 'cat > ${VARDIR}/zones << __EOF__';
|
|
|
|
dump_zone_contents;
|
2007-03-21 21:08:05 +01:00
|
|
|
emit_unindented '__EOF__';
|
|
|
|
|
2007-03-22 03:13:30 +01:00
|
|
|
emit '> ${VARDIR}/nat';
|
|
|
|
|
|
|
|
add_addresses;
|
|
|
|
|
2007-03-17 17:54:39 +01:00
|
|
|
pop_indent;
|
2007-03-17 17:44:47 +01:00
|
|
|
|
2007-03-19 05:50:37 +01:00
|
|
|
emit "}\n";
|
2007-03-17 17:44:47 +01:00
|
|
|
|
2007-03-17 17:54:39 +01:00
|
|
|
progress_message2 "Creating iptables-restore input...";
|
|
|
|
create_netfilter_load;
|
2007-03-17 17:44:47 +01:00
|
|
|
|
2007-03-17 17:54:39 +01:00
|
|
|
emit "#\n# Start/Restart the Firewall\n#";
|
|
|
|
emit 'define_firewall() {';
|
2007-03-22 19:24:33 +01:00
|
|
|
push_indent;
|
2007-03-29 01:21:37 +02:00
|
|
|
|
|
|
|
emit<<'EOF';
|
|
|
|
setup_routing_and_traffic_shaping;
|
2007-03-22 19:24:33 +01:00
|
|
|
|
|
|
|
if [ $COMMAND = restore ]; then
|
|
|
|
iptables_save_file=${VARDIR}/$(basename $0)-iptables
|
|
|
|
if [ -f $iptables_save_file ]; then
|
|
|
|
iptables-restore < $iptables_save_file
|
|
|
|
else
|
|
|
|
fatal_error "$iptables_save_file does not exist"
|
|
|
|
fi
|
|
|
|
set_state "Started"
|
|
|
|
else
|
|
|
|
setup_netfilter
|
|
|
|
restore_dynamic_rules
|
|
|
|
run_start_exit
|
|
|
|
$IPTABLES -N shorewall
|
|
|
|
set_state "Started"
|
|
|
|
run_started_exit
|
|
|
|
|
|
|
|
cp -f $(my_pathname) ${VARDIR}/.restore
|
|
|
|
fi
|
|
|
|
|
|
|
|
date > ${VARDIR}/restarted
|
|
|
|
|
|
|
|
case $COMMAND in
|
|
|
|
start)
|
|
|
|
logger -p kern.info "$PRODUCT started"
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
logger -p kern.info "$PRODUCT restarted"
|
|
|
|
;;
|
|
|
|
refresh)
|
|
|
|
logger -p kern.info "$PRODUCT refreshed"
|
|
|
|
;;
|
|
|
|
restore)
|
|
|
|
logger -p kern.info "$PRODUCT restored"
|
|
|
|
;;
|
2007-03-29 01:21:37 +02:00
|
|
|
esac
|
|
|
|
EOF
|
2007-03-17 17:44:47 +01:00
|
|
|
|
2007-03-22 19:24:33 +01:00
|
|
|
pop_indent;
|
2007-03-17 17:44:47 +01:00
|
|
|
|
2007-03-14 00:11:15 +01:00
|
|
|
emit "}\n";
|
|
|
|
|
2007-03-25 18:38:00 +02:00
|
|
|
copy $env{SHAREDIRPL} . 'prog.footer';
|
2007-03-12 02:04:21 +01:00
|
|
|
}
|
|
|
|
|
2007-03-28 18:07:40 +02:00
|
|
|
#
|
|
|
|
# The Compiler.
|
|
|
|
#
|
|
|
|
# If the argument is non-null, it names the script file to generate.
|
|
|
|
# Otherwise, this is a 'check' command and no script is produced.
|
|
|
|
#
|
|
|
|
sub compiler( $ ) {
|
2007-03-10 19:17:28 +01:00
|
|
|
|
|
|
|
my $objectfile = $_[0];
|
|
|
|
|
2007-03-14 03:44:41 +01:00
|
|
|
report_capabilities if $ENV{VERBOSE} > 1;
|
2007-03-11 02:40:59 +01:00
|
|
|
|
2007-03-29 01:21:37 +02:00
|
|
|
require_capability( 'MULTIPORT' , "Shorewall-perl $env{VERSION}" );
|
|
|
|
require_capability( 'ADDRTYPE' , "Shorewall-perl $env{VERSION}" );
|
|
|
|
require_capability( 'RECENT_MATCH' , 'MACLIST_TTL' ) if $config{MACLIST_TTL};
|
|
|
|
require_capability( 'XCONNMARK' , 'HIGH_ROUTE_MARKS=Yes' ) if $config{HIGH_ROUTE_MARKS};
|
|
|
|
require_capability( 'MANGLE_ENABLED' , 'Traffic Shaping' ) if $config{TC_ENABLED};
|
2007-03-29 03:14:13 +02:00
|
|
|
require_capability( 'CONNTRACK_MATCH' , 'RFC1918_STRICT=Yes' ) if $config{RFC1918_STRICT};
|
2007-03-28 18:07:40 +02:00
|
|
|
|
|
|
|
( $command, $doing, $done ) = qw/ check Checking Checked / unless $objectfile;
|
|
|
|
|
|
|
|
initialize_chain_table;
|
|
|
|
|
|
|
|
if ( $command eq 'compile' ) {
|
|
|
|
create_temp_object( $objectfile );
|
|
|
|
generate_script_1;
|
|
|
|
}
|
|
|
|
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
|
|
|
# Process the zones file.
|
|
|
|
#
|
2007-03-14 00:11:15 +01:00
|
|
|
progress_message2 "Determining Zones...";
|
|
|
|
determine_zones;
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
|
|
|
# Process the interfaces file.
|
|
|
|
#
|
2007-03-14 00:11:15 +01:00
|
|
|
progress_message2 "Validating interfaces file...";
|
|
|
|
validate_interfaces_file;
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
|
|
|
# Process the hosts file.
|
|
|
|
#
|
2007-03-14 00:11:15 +01:00
|
|
|
validate_hosts_file;
|
2007-03-21 18:23:18 +01:00
|
|
|
#
|
|
|
|
# Report zone contents
|
|
|
|
#
|
2007-03-29 20:57:53 +02:00
|
|
|
progress_message2 "Determining Hosts in Zones...";
|
2007-03-21 18:23:18 +01:00
|
|
|
zone_report;
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
|
|
|
# Do action pre-processing.
|
|
|
|
#
|
2007-03-14 00:11:15 +01:00
|
|
|
progress_message2 "Preprocessing Action Files...";
|
|
|
|
process_actions1;
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
|
|
|
# Process the Policy File.
|
|
|
|
#
|
2007-03-14 00:11:15 +01:00
|
|
|
progress_message2 "Validating Policy file...";
|
|
|
|
validate_policy;
|
|
|
|
#
|
2007-03-16 01:58:25 +01:00
|
|
|
# Compile the 'stop_firewall()' function
|
|
|
|
#
|
|
|
|
compile_stop_firewall;
|
|
|
|
#
|
2007-03-14 00:11:15 +01:00
|
|
|
# Start Second Part of script
|
|
|
|
#
|
|
|
|
generate_script_2;
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
|
|
|
# Do all of the zone-independent stuff
|
|
|
|
#
|
2007-03-26 01:18:20 +02:00
|
|
|
progress_message2 "$doing Common Rules...";
|
2007-03-14 00:11:15 +01:00
|
|
|
add_common_rules;
|
|
|
|
#
|
2007-03-16 17:26:34 +01:00
|
|
|
# /proc stuff
|
|
|
|
#
|
|
|
|
setup_arp_filtering;
|
|
|
|
setup_route_filtering;
|
|
|
|
setup_martian_logging;
|
|
|
|
setup_source_routing;
|
|
|
|
setup_forwarding;
|
|
|
|
#
|
2007-03-17 00:07:50 +01:00
|
|
|
# Proxy Arp
|
|
|
|
#
|
|
|
|
setup_proxy_arp;
|
|
|
|
#
|
2007-03-14 00:11:15 +01:00
|
|
|
# [Re-]establish Routing
|
|
|
|
#
|
2007-03-29 19:02:13 +02:00
|
|
|
setup_providers;
|
2007-03-14 00:11:15 +01:00
|
|
|
#
|
2007-03-21 00:13:17 +01:00
|
|
|
# TCRules and Traffic Shaping
|
2007-03-14 00:11:15 +01:00
|
|
|
#
|
2007-03-21 00:13:17 +01:00
|
|
|
setup_tc;
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
2007-03-28 19:43:09 +02:00
|
|
|
# TOS
|
|
|
|
#
|
|
|
|
process_tos;
|
|
|
|
#
|
2007-03-28 20:48:43 +02:00
|
|
|
# ECN
|
|
|
|
#
|
|
|
|
setup_ecn;
|
|
|
|
#
|
2007-03-09 01:03:04 +01:00
|
|
|
# Setup Masquerading/SNAT
|
|
|
|
#
|
2007-03-29 19:02:13 +02:00
|
|
|
setup_masq;
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
|
|
|
# MACLIST Filtration
|
|
|
|
#
|
2007-03-26 01:18:20 +02:00
|
|
|
progress_message2 "$doing MAC Filtration -- Phase 1...";
|
2007-03-14 00:11:15 +01:00
|
|
|
setup_mac_lists 1;
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
|
|
|
# Process the rules file.
|
|
|
|
#
|
2007-03-14 00:11:15 +01:00
|
|
|
progress_message2 "$doing Rules...";
|
|
|
|
process_rules;
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
|
|
|
# Add Tunnel rules.
|
|
|
|
#
|
2007-03-14 00:11:15 +01:00
|
|
|
setup_tunnels;
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
|
|
|
# Post-rules action processing.
|
|
|
|
#
|
|
|
|
process_actions2;
|
|
|
|
process_actions3;
|
|
|
|
#
|
|
|
|
# MACLIST Filtration again
|
|
|
|
#
|
2007-03-26 01:18:20 +02:00
|
|
|
progress_message2 "$doing MAC Filtration -- Phase 2...";
|
2007-03-14 00:11:15 +01:00
|
|
|
setup_mac_lists 2;
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
|
|
|
# Apply Policies
|
|
|
|
#
|
2007-03-14 00:11:15 +01:00
|
|
|
progress_message2 'Applying Policies...';
|
|
|
|
apply_policy_rules;
|
2007-03-09 01:03:04 +01:00
|
|
|
#
|
|
|
|
# Setup Nat
|
|
|
|
#
|
2007-03-29 19:02:13 +02:00
|
|
|
setup_nat;
|
2007-03-25 23:04:24 +02:00
|
|
|
#
|
|
|
|
# Setup NETMAP
|
|
|
|
#
|
2007-03-29 19:02:13 +02:00
|
|
|
setup_netmap;
|
2007-03-25 23:04:24 +02:00
|
|
|
#
|
2007-03-09 01:03:04 +01:00
|
|
|
# Accounting.
|
|
|
|
#
|
2007-03-26 01:18:20 +02:00
|
|
|
progress_message2 "$doing Accounting...";
|
2007-03-14 00:11:15 +01:00
|
|
|
setup_accounting;
|
2007-03-15 22:55:22 +01:00
|
|
|
|
2007-03-28 03:52:45 +02:00
|
|
|
progress_message2 'Generating Rule Matrix...';
|
|
|
|
generate_matrix;
|
|
|
|
generate_script_3;
|
2007-03-28 18:07:40 +02:00
|
|
|
|
2007-03-17 17:44:47 +01:00
|
|
|
if ( $command eq 'check' ) {
|
|
|
|
progress_message3 "Shorewall configuration verified";
|
|
|
|
} else {
|
2007-03-13 23:03:59 +01:00
|
|
|
#
|
|
|
|
# Finish the script.
|
|
|
|
#
|
2007-03-15 01:34:17 +01:00
|
|
|
finalize_object;
|
2007-03-21 17:21:37 +01:00
|
|
|
#
|
|
|
|
# And generate the auxilary config file
|
|
|
|
#
|
2007-03-25 18:38:00 +02:00
|
|
|
generate_aux_config if $ENV{EXPORT};
|
2007-03-10 19:17:28 +01:00
|
|
|
}
|
2007-03-09 01:03:04 +01:00
|
|
|
}
|
|
|
|
|
2007-03-08 05:38:37 +01:00
|
|
|
#
|
2007-03-14 00:11:15 +01:00
|
|
|
# E x e c u t i o n S t a r t s H e r e
|
2007-03-08 05:38:37 +01:00
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Get shorewall.conf and capabilities.
|
|
|
|
#
|
2007-03-15 03:53:07 +01:00
|
|
|
get_configuration;
|
|
|
|
#
|
|
|
|
# Compile/Check the configuration.
|
|
|
|
#
|
2007-03-28 18:07:40 +02:00
|
|
|
compiler $ARGV[0];
|