Skip to content

Commit ecc886a

Browse files
Rolf FokkensSirius Bakke
Rolf Fokkens
authored and
Sirius Bakke
committed
Fixed (potential) deadlock situation as sugested by https://github.com/antaflos
Signed-off-by: Sirius Bakke <[email protected]>
1 parent be15f6e commit ecc886a

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/res/configlets/linux24/reset_iptables

+16-10
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,38 @@
1212
## {{if var}} is conditional operator.
1313
##
1414
reset_iptables_v4() {
15+
local list
16+
1517
$IPTABLES {{$opt_wait}} -P OUTPUT DROP
1618
$IPTABLES {{$opt_wait}} -P INPUT DROP
1719
$IPTABLES {{$opt_wait}} -P FORWARD DROP
1820

19-
cat /proc/net/ip_tables_names | while read table; do
20-
$IPTABLES {{$opt_wait}} -t $table -L -n | while read c chain rest; do
21+
while read table; do
22+
list=$($IPTABLES {{$opt_wait}} -t $table -L -n)
23+
printf "%s" "$list" | while read c chain rest; do
2124
if test "X$c" = "XChain" ; then
2225
$IPTABLES {{$opt_wait}} -t $table -F $chain
2326
fi
24-
done
25-
$IPTABLES {{$opt_wait}} -t $table -X
26-
done
27+
done
28+
$IPTABLES {{$opt_wait}} -t $table -X
29+
done < /proc/net/ip_tables_names
2730
}
2831

2932
reset_iptables_v6() {
33+
local list
34+
3035
$IP6TABLES {{$opt_wait}} -P OUTPUT DROP
3136
$IP6TABLES {{$opt_wait}} -P INPUT DROP
3237
$IP6TABLES {{$opt_wait}} -P FORWARD DROP
3338

34-
cat /proc/net/ip6_tables_names | while read table; do
35-
$IP6TABLES {{$opt_wait}} -t $table -L -n | while read c chain rest; do
39+
while read table; do
40+
list=$($IP6TABLES {{$opt_wait}} -t $table -L -n)
41+
printf "%s" "$list" | while read c chain rest; do
3642
if test "X$c" = "XChain" ; then
3743
$IP6TABLES {{$opt_wait}} -t $table -F $chain
3844
fi
39-
done
40-
$IP6TABLES {{$opt_wait}} -t $table -X
41-
done
45+
done
46+
$IP6TABLES {{$opt_wait}} -t $table -X
47+
done < /proc/net/ip6_tables_names
4248
}
4349

0 commit comments

Comments
 (0)