From 4dbd9e205c413089e9aa8a43b31635fc5725f126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 11 Feb 2015 14:14:27 +0100 Subject: [PATCH] network: fix handling newline in firewall rules Since the rules are no more directly handed to echo -e, sed needs to handle all escape sequences used in rules (newline only, but in different notations). --- network/qubes-firewall | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/network/qubes-firewall b/network/qubes-firewall index 1cf5986..1db4bec 100755 --- a/network/qubes-firewall +++ b/network/qubes-firewall @@ -36,11 +36,11 @@ while true; do RULES=$(qubesdb-read $XENSTORE_IPTABLES_HEADER) IPTABLES_SAVE=$(iptables-save | sed '/^\*filter/,/^COMMIT/d') - OUT=$(printf '%s\n%s\n' "$RULES" "$IPTABLES_SAVE" | sed 's/\\n/\n/g' | iptables-restore 2>&1 || true) + OUT=$(printf '%s\n%s\n' "$RULES" "$IPTABLES_SAVE" | sed 's/\\n\|\\x0a/\n/g' | iptables-restore 2>&1 || true) for i in $(qubesdb-list -f /qubes-iptables-domainrules) ; do RULES=$(qubesdb-read "$i") - ERRS=$(printf '%s\n' "$RULES" | sed 's/\\n/\n/g' | /sbin/iptables-restore -n 2>&1 || true) + ERRS=$(printf '%s\n' "$RULES" | sed 's/\\n\|\\x0a/\n/g' | /sbin/iptables-restore -n 2>&1 || true) if [ -n "$ERRS" ]; then echo "Failed applying rules for $i: $ERRS" >&2 OUT="$OUT$ERRS"