Bug 6937 - [PATCH] rc.firewall can't be run from network - fix
Summary: [PATCH] rc.firewall can't be run from network - fix
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 2.2.6-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1998-06-13 19:00 UTC by Adrian Steinmann
Modified: 1999-06-04 15:40 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Steinmann 1998-06-13 19:00:01 UTC
The file /etc/rc.firewall reloads the ipfw rules but may not complete
if it is started on a network connection.

Fix: 

I have been using this additional code in /etc/rc.firewall with
good results: if, by chance, you run sh /etc/rc.firewall on a pty
via the network, you will albeit lose your session but the script
will finish completely and (unless you made changes which are faulty)
you will be able to log back in agains (because it ignores the HUP
signal).  It also takes down and brings up all interfaces, making
any ongoing connections cut cleaner (and usually continue) than
when the rules are loaded while the interfaces are up. The real
paranoid might also argue this way there is no window where the
interfaces are up and the FW rules are incomplete...

Could we put this into the distributed /etc/rc.firewall?


...
PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH
...

# routine to set interfaces down and up
interfaces ()
{
    case "x$1" in
	xup|xdown)
	    ifconfig -a | sed -n -e '/BROADCAST,/ s/:.*//p' | \
		while read i; do ifconfig $i $1; done
	    ;;
	*)
	    echo "USAGE: interfaces [up|down]" >&2
	    ;;
    esac
}

############
# START
trap '' 1
interfaces down

... all the ipfw rules ...

############
# DONE
interfaces up

Adrian
_________________________________________________________________________
Dr. Adrian Steinmann  Steinmann Consulting  Apollostrasse 21  8032 Zurich
   Tel +41 1 380 30 83     Fax +41 1 380 30 85    Mailto:ast@marabu.ch
How-To-Repeat: 
Run sh /etc/rc.firewall on a network connection, if /etc/rc.firewall
is sufficientlyu complex, you will lose your connection and may not
be able to contact the machine again until /etc/rc.firewall is run
completely.
Comment 1 Jordan K. Hubbard 1998-06-13 20:04:46 UTC
> Could we put this into the distributed /etc/rc.firewall?

I find your intentions here somewhat hard to follow, however.  Could
you please resubmit your changes as context or unidiffs to the distributed
rc.firewall?  Thanks!
Comment 2 ru freebsd_committer freebsd_triage 1999-06-04 15:37:43 UTC
State Changed
From-To: open->closed

It could be done from network, for example: 
# sh /etc/rc.firewall >/dev/null 2>&1 
Refer to the ``BUGS'' section of ipfw(8) manpage.