* Use printf instead of echo for better shell compatibility.
* Use an include instead of concatenating the ruleset.
(Note that this is likely to fail is the ruleset path contains
special characters).
* Empty the table first when executing panic actions.
Fixes: https://bugs.gentoo.org/675188
Signed-off-by: Francisco Blas Izquierdo Riera (klondike) <klondike@gentoo.org>
Package-Manager: Portage-2.3.51, Repoman-2.3.11
Signed-off-by: Matthew Thode <prometheanfire@gentoo.org>
nft ${SAVE_OPTIONS} list ruleset
;;
"load")
- ( echo "flush ruleset;"; cat "${NFTABLES_SAVE}" ) | nft -f -
+ # We use an include because cat fails with long rulesets see #675188
+ printf 'flush ruleset\ninclude "%s"\n' "${NFTABLES_SAVE}" | nft -f -
;;
"panic")
panic hard | nft -f -
local tmp_save="${NFTABLES_SAVE}.tmp"
umask 600;
(
- echo "#!/sbin/nft -f"
- echo "flush ruleset;"
+ printf '#!/sbin/nft -f\nflush ruleset\n'
nft ${SAVE_OPTIONS} list ruleset
) > "$tmp_save" && mv ${tmp_save} ${NFTABLES_SAVE}
;;
local erule;
[ "$1" = soft ] && erule="ct state established,related accept;" || erule="";
cat <<EOF
+flush ruleset
table inet filter {
chain input {
type filter hook input priority 0;