diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-12-05 18:33:15 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-12-05 18:33:18 +0100 |
commit | 884b6e36e6af0c6fa5b9467ccc8c2e2e4477bc95 (patch) | |
tree | 91f0e1ed27d0f2fda955b3754528aeec8f1ed74f /src/tools/wg-quick/linux.bash | |
parent | crypto: use new assembler macros for 5.5 (diff) | |
download | wireguard-monolithic-historical-884b6e36e6af0c6fa5b9467ccc8c2e2e4477bc95.tar.xz wireguard-monolithic-historical-884b6e36e6af0c6fa5b9467ccc8c2e2e4477bc95.zip |
wg-quick: linux: some iptables don't like empty lines
Reported-by: Kenneth R. Crudup <kenny@panix.com>
Diffstat (limited to 'src/tools/wg-quick/linux.bash')
-rwxr-xr-x | src/tools/wg-quick/linux.bash | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/tools/wg-quick/linux.bash b/src/tools/wg-quick/linux.bash index fc90e55..d2c2ba9 100755 --- a/src/tools/wg-quick/linux.bash +++ b/src/tools/wg-quick/linux.bash @@ -188,9 +188,9 @@ remove_iptables() { while read -r line; do [[ $line == "*"* || $line == COMMIT || $line == "-A "*"-m comment --comment \"wg-quick(8) rule for $INTERFACE\""* ]] || continue [[ $line == "-A"* ]] && found=1 - printf -v restore '%s\n%s' "$restore" "${line/#-A/-D}" + printf -v restore '%s%s\n' "$restore" "${line/#-A/-D}" done < <($iptables-save) - [[ $found -ne 1 ]] || echo "$restore" | cmd $iptables-restore -n + [[ $found -ne 1 ]] || echo -n "$restore" | cmd $iptables-restore -n done } @@ -210,14 +210,14 @@ add_default() { cmd ip $proto rule add not fwmark $table table $table cmd ip $proto rule add table main suppress_prefixlength 0 - local marker="-m comment --comment \"wg-quick(8) rule for $INTERFACE\"" restore="*raw" + local marker="-m comment --comment \"wg-quick(8) rule for $INTERFACE\"" restore=$'*raw\n' for i in "${ADDRESSES[@]}"; do [[ ( $proto == -4 && $i != *:* ) || ( $proto == -6 && $i == *:* ) ]] || continue - printf -v restore '%s\n-I PREROUTING ! -i %s -d %s -m addrtype ! --src-type LOCAL -j DROP %s\n' "$restore" "$INTERFACE" "${i%/*}" "$marker" + printf -v restore '%s-I PREROUTING ! -i %s -d %s -m addrtype ! --src-type LOCAL -j DROP %s\n' "$restore" "$INTERFACE" "${i%/*}" "$marker" done - printf -v restore '%s\nCOMMIT\n*mangle\n-I POSTROUTING -m mark --mark %d -p udp -j CONNMARK --save-mark %s\n-I PREROUTING -p udp -j CONNMARK --restore-mark %s\nCOMMIT\n' "$restore" $table "$marker" "$marker" + printf -v restore '%sCOMMIT\n*mangle\n-I POSTROUTING -m mark --mark %d -p udp -j CONNMARK --save-mark %s\n-I PREROUTING -p udp -j CONNMARK --restore-mark %s\nCOMMIT\n' "$restore" $table "$marker" "$marker" [[ $proto == -4 ]] && cmd sysctl -q net.ipv4.conf.all.src_valid_mark=1 - echo "$restore" | cmd $iptables-restore -n + echo -n "$restore" | cmd $iptables-restore -n HAVE_SET_IPTABLES=1 return 0 } |