diff --git a/src/network.sh b/src/network.sh index 038e7c1..26303ad 100644 --- a/src/network.sh +++ b/src/network.sh @@ -576,7 +576,7 @@ clearTables() { local table="" local line="" local rules="" - local args=() + local failed="N" local rule_tag="remove" local re="--comment[[:space:]]+\"?$rule_tag\"?([[:space:]]|\$)" @@ -598,12 +598,18 @@ clearTables() { esac if [[ "$line" == -A* ]] && [[ "$line" =~ $re ]]; then - read -ra args <<< "${line/-A /-D }" - iptables -t "$table" "${args[@]}" > /dev/null 2>&1 || : + line="${line/-A /-D }" + + # Parse the quoting produced by iptables-save before deleting the rule. + if ! printf '%s\n' "$line" | + xargs -r iptables -t "$table" > /dev/null 2>&1; then + failed="Y" + fi fi done <<< "$rules" + enabled "$failed" && return 1 return 0 }