
Avoid bailing out early if multiple instances of iptables-restore are
called simultaneously.
Fixes QubesOS/qubes-issues#3665
(cherry picked from commit 8f6bd245bd
)
66 lines
1.2 KiB
Bash
Executable File
66 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# qubes-iptables Start Qubes base iptables firewall
|
|
#
|
|
# chkconfig: 2345 08 92
|
|
# description: Loads iptables firewall
|
|
#
|
|
# config: /etc/qubes/iptables.rules
|
|
# config: /etc/qubes/ip6tables.rules
|
|
#
|
|
### BEGIN INIT INFO
|
|
# Provides: iptables
|
|
# Required-Start:
|
|
# Required-Stop:
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: Loads Qubes base iptables firewall
|
|
# Description: Loads Qubes base iptables firewall
|
|
### END INIT INFO
|
|
|
|
IPTABLES=iptables
|
|
IPTABLES_DATA_DIR=/etc/qubes
|
|
|
|
if [ ! -x /sbin/$IPTABLES ]; then
|
|
echo $"${IPTABLES}: /sbin/$IPTABLES does not exist."
|
|
exit 5
|
|
fi
|
|
|
|
start() {
|
|
ipt=$1
|
|
IPTABLES_DATA=$IPTABLES_DATA_DIR/${ipt}.rules
|
|
CMD=$ipt
|
|
# Do not start if there is no config file.
|
|
[ ! -f "$IPTABLES_DATA" ] && return 6
|
|
|
|
CMD_ARGS=
|
|
if "$CMD-restore" --help 2>&1 | grep -q wait=; then
|
|
CMD_ARGS=--wait
|
|
fi
|
|
|
|
echo -n $"${CMD}: Applying firewall rules: "
|
|
|
|
"$CMD-restore" $CMD_ARGS "$IPTABLES_DATA"
|
|
ret="$?"
|
|
if [ "$ret" -eq 0 ]; then
|
|
echo OK
|
|
else
|
|
echo FAIL; return 1
|
|
fi
|
|
|
|
return $ret
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start iptables && start ip6tables
|
|
RETVAL=$?
|
|
;;
|
|
*)
|
|
echo $"Usage: ${IPTABLES} start"
|
|
RETVAL=2
|
|
;;
|
|
esac
|
|
|
|
exit $RETVAL
|