Blame SOURCES/arptables-legacy-helper

0890d3
#!/bin/sh
0890d3
# config: /etc/sysconfig/arptables
0890d3
0890d3
# Source 'em up
0890d3
. /etc/init.d/functions
0890d3
0890d3
ARPTABLES_CONFIG=/etc/sysconfig/arptables
0890d3
0890d3
arp_table() {
0890d3
	if fgrep -qsx $1 /proc/net/arp_tables_names; then
0890d3
		arptables -t "$@"
0890d3
	fi
0890d3
}
0890d3
0890d3
flush_delete_chains() {
0890d3
	chains=$(cat /proc/net/arp_tables_names 2>/dev/null)
0890d3
	echo -n $"Flushing all chains:"
0890d3
	let ret=0
0890d3
	for i in $chains; do arptables -t $i -F; let ret+=$?; done
0890d3
	arptables -F; let ret+=$?
0890d3
	if [ $ret -eq 0 ]; then
0890d3
		success
0890d3
	else
0890d3
		failure
0890d3
	fi
0890d3
	echo
0890d3
0890d3
	echo -n $"Removing user defined chains:"
0890d3
	let ret=0
0890d3
	for i in $chains; do arptables -t $i -X; let ret+=$?; done
0890d3
	arptables -X; let ret+=$?
0890d3
	if [ $ret -eq 0 ]; then
0890d3
		success
0890d3
	else
0890d3
		failure
0890d3
	fi
0890d3
	echo
0890d3
}
0890d3
0890d3
start() {
0890d3
	if [ ! -x /usr/sbin/arptables ]; then
0890d3
		exit 4
0890d3
	fi
0890d3
0890d3
	# don't do squat if we don't have the config file
0890d3
	if [ -f $ARPTABLES_CONFIG ]; then
0890d3
		# If we don't clear these first, we might be adding to
0890d3
		# pre-existing rules.
0890d3
                flush_delete_chains
0890d3
0890d3
		for i in $(cat /proc/net/arp_tables_names 2>/dev/null); do
0890d3
			arptables -t $i -Z;
0890d3
		done
0890d3
0890d3
		echo -n $"Applying arptables firewall rules: "
0890d3
		/usr/sbin/arptables-restore < $ARPTABLES_CONFIG && \
0890d3
			success || \
0890d3
			failure
0890d3
		echo
0890d3
		touch /var/lock/subsys/arptables
0890d3
	else
0890d3
		failure
0890d3
		echo
0890d3
		echo $"Configuration file /etc/sysconfig/arptables missing"
0890d3
		exit 6
0890d3
	fi
0890d3
}
0890d3
0890d3
stop() {
0890d3
        flush_delete_chains
0890d3
	echo -n $"Resetting built-in chains to the default ACCEPT policy:"
0890d3
	arp_table filter -P INPUT ACCEPT && \
0890d3
		arp_table filter -P OUTPUT ACCEPT && \
0890d3
		success || \
0890d3
		failure
0890d3
	echo
0890d3
	rm -f /var/lock/subsys/arptables
0890d3
}
0890d3
0890d3
case "$1" in
0890d3
start)
0890d3
	start
0890d3
	;;
0890d3
0890d3
stop)
0890d3
	stop
0890d3
	;;
0890d3
0890d3
restart|reload)
0890d3
	# "restart" is really just "start" as this isn't a daemon,
0890d3
	# and "start" clears any pre-defined rules anyway.
0890d3
	# This is really only here to make those who expect it happy
0890d3
	start
0890d3
	;;
0890d3
0890d3
condrestart|try-restart|force-reload)
0890d3
	[ -e /var/lock/subsys/arptables ] && start
0890d3
	;;
0890d3
0890d3
*)
0890d3
	exit 2
0890d3
esac
0890d3
0890d3
exit 0