|
|
8a3219 |
From cc2b632a51ad32e7b3966f44057add92e45e60a5 Mon Sep 17 00:00:00 2001
|
|
|
8a3219 |
From: Eric Garver <eric@garver.life>
|
|
|
8a3219 |
Date: Fri, 14 Jun 2019 09:44:41 -0400
|
|
|
8a3219 |
Subject: [PATCH 03/20] fix: tests: always list rules using macros
|
|
|
8a3219 |
|
|
|
8a3219 |
This is to make sure certain flags are used, e.g. "-w" for iptables.
|
|
|
8a3219 |
|
|
|
8a3219 |
Fixes: rhbz 1720650
|
|
|
8a3219 |
(cherry picked from commit e527818500be462a724cd34c94948a2704560eb1)
|
|
|
8a3219 |
---
|
|
|
8a3219 |
src/tests/features/rfc3964_ipv4.at | 4 +-
|
|
|
8a3219 |
.../regression/icmp_block_in_forward_chain.at | 27 +++++--
|
|
|
8a3219 |
src/tests/regression/rhbz1514043.at | 80 +++++++++++++++++--
|
|
|
8a3219 |
3 files changed, 98 insertions(+), 13 deletions(-)
|
|
|
8a3219 |
|
|
|
8a3219 |
diff --git a/src/tests/features/rfc3964_ipv4.at b/src/tests/features/rfc3964_ipv4.at
|
|
|
8a3219 |
index cce828c0b3de..baff411793b2 100644
|
|
|
8a3219 |
--- a/src/tests/features/rfc3964_ipv4.at
|
|
|
8a3219 |
+++ b/src/tests/features/rfc3964_ipv4.at
|
|
|
8a3219 |
@@ -93,8 +93,8 @@ NFT_LIST_RULES([inet], [filter_OUTPUT], 0, [dnl
|
|
|
8a3219 |
}
|
|
|
8a3219 |
])
|
|
|
8a3219 |
|
|
|
8a3219 |
-m4_if(iptables, FIREWALL_BACKEND, [
|
|
|
8a3219 |
-NS_CHECK([ip6tables -w -n -t filter -L RFC3964_IPv4], 1, [ignore], [ignore])
|
|
|
8a3219 |
+IP6TABLES_LIST_RULES([filter], [RFC3964_IPv4], 0, [ignore], [dnl
|
|
|
8a3219 |
+iptables: No chain/target/match by that name.
|
|
|
8a3219 |
])
|
|
|
8a3219 |
IP6TABLES_LIST_RULES([filter], [FORWARD], 0, [dnl
|
|
|
8a3219 |
ACCEPT all ::/0 ::/0 ctstate RELATED,ESTABLISHED,DNAT
|
|
|
8a3219 |
diff --git a/src/tests/regression/icmp_block_in_forward_chain.at b/src/tests/regression/icmp_block_in_forward_chain.at
|
|
|
8a3219 |
index 769315d9534e..7580bc179470 100644
|
|
|
8a3219 |
--- a/src/tests/regression/icmp_block_in_forward_chain.at
|
|
|
8a3219 |
+++ b/src/tests/regression/icmp_block_in_forward_chain.at
|
|
|
8a3219 |
@@ -2,12 +2,27 @@ FWD_START_TEST([ICMP block present FORWARD chain])
|
|
|
8a3219 |
AT_KEYWORDS(icmp)
|
|
|
8a3219 |
|
|
|
8a3219 |
FWD_CHECK([-q --zone=public --add-icmp-block=host-prohibited])
|
|
|
8a3219 |
-m4_if(iptables, FIREWALL_BACKEND, [
|
|
|
8a3219 |
- NS_CHECK([IPTABLES -L IN_public_deny | grep "host-prohibited"], 0, ignore)
|
|
|
8a3219 |
- NS_CHECK([IPTABLES -L FWDI_public_deny | grep "host-prohibited"], 0, ignore)
|
|
|
8a3219 |
-], [
|
|
|
8a3219 |
- NS_CHECK([nft list chain inet firewalld filter_IN_public_deny | grep "destination-unreachable" |grep "\(code 10\|host-prohibited\)"], 0, ignore)
|
|
|
8a3219 |
- NS_CHECK([nft list chain inet firewalld filter_FWDI_public_deny | grep "destination-unreachable" |grep "\(code 10\|host-prohibited\)"], 0, ignore)
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+NFT_LIST_RULES([inet], [filter_IN_public_deny | sed -e 's/icmp code 10/icmp code host-prohibited/'], 0, [dnl
|
|
|
8a3219 |
+ table inet firewalld {
|
|
|
8a3219 |
+ chain filter_IN_public_deny {
|
|
|
8a3219 |
+ icmp type destination-unreachable icmp code host-prohibited reject with icmp type admin-prohibited
|
|
|
8a3219 |
+ }
|
|
|
8a3219 |
+ }
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+NFT_LIST_RULES([inet], [filter_FWDI_public_deny | sed -e 's/icmp code 10/icmp code host-prohibited/'], 0, [dnl
|
|
|
8a3219 |
+ table inet firewalld {
|
|
|
8a3219 |
+ chain filter_FWDI_public_deny {
|
|
|
8a3219 |
+ icmp type destination-unreachable icmp code host-prohibited reject with icmp type admin-prohibited
|
|
|
8a3219 |
+ }
|
|
|
8a3219 |
+ }
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+IPTABLES_LIST_RULES([filter], [IN_public_deny], 0, [dnl
|
|
|
8a3219 |
+ REJECT icmp -- 0.0.0.0/0 0.0.0.0/0 icmptype 3 code 10 reject-with icmp-host-prohibited
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+IPTABLES_LIST_RULES([filter], [FWDI_public_deny], 0, [dnl
|
|
|
8a3219 |
+ REJECT icmp -- 0.0.0.0/0 0.0.0.0/0 icmptype 3 code 10 reject-with icmp-host-prohibited
|
|
|
8a3219 |
])
|
|
|
8a3219 |
|
|
|
8a3219 |
FWD_END_TEST
|
|
|
8a3219 |
diff --git a/src/tests/regression/rhbz1514043.at b/src/tests/regression/rhbz1514043.at
|
|
|
8a3219 |
index 88ce4934e5ea..241cf547f7f3 100644
|
|
|
8a3219 |
--- a/src/tests/regression/rhbz1514043.at
|
|
|
8a3219 |
+++ b/src/tests/regression/rhbz1514043.at
|
|
|
8a3219 |
@@ -7,11 +7,81 @@ FWD_RELOAD
|
|
|
8a3219 |
FWD_CHECK([--zone=public --list-all | TRIM | grep ^services], 0, [dnl
|
|
|
8a3219 |
services: cockpit dhcpv6-client samba ssh
|
|
|
8a3219 |
])
|
|
|
8a3219 |
+
|
|
|
8a3219 |
dnl check that log denied actually took effect
|
|
|
8a3219 |
-m4_if(iptables, FIREWALL_BACKEND, [
|
|
|
8a3219 |
- NS_CHECK([IPTABLES -t filter -L | grep "FINAL_REJECT:"], 0, ignore)
|
|
|
8a3219 |
-], [
|
|
|
8a3219 |
- NS_CHECK([nft list chain inet firewalld filter_INPUT | grep "FINAL_REJECT"], 0, ignore)
|
|
|
8a3219 |
- NS_CHECK([nft list chain inet firewalld filter_FORWARD | grep "FINAL_REJECT"], 0, ignore)
|
|
|
8a3219 |
+NFT_LIST_RULES([inet], [filter_INPUT], 0, [dnl
|
|
|
8a3219 |
+ table inet firewalld {
|
|
|
8a3219 |
+ chain filter_INPUT {
|
|
|
8a3219 |
+ ct state established,related accept
|
|
|
8a3219 |
+ ct status dnat accept
|
|
|
8a3219 |
+ iifname "lo" accept
|
|
|
8a3219 |
+ jump filter_INPUT_ZONES
|
|
|
8a3219 |
+ ct state invalid log prefix "STATE_INVALID_DROP: "
|
|
|
8a3219 |
+ ct state invalid drop
|
|
|
8a3219 |
+ log prefix "FINAL_REJECT: "
|
|
|
8a3219 |
+ reject with icmpx type admin-prohibited
|
|
|
8a3219 |
+ }
|
|
|
8a3219 |
+ }
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+NFT_LIST_RULES([inet], [filter_FORWARD], 0, [dnl
|
|
|
8a3219 |
+ table inet firewalld {
|
|
|
8a3219 |
+ chain filter_FORWARD {
|
|
|
8a3219 |
+ ct state established,related accept
|
|
|
8a3219 |
+ ct status dnat accept
|
|
|
8a3219 |
+ iifname "lo" accept
|
|
|
8a3219 |
+ ip6 daddr { ::/96, ::ffff:0.0.0.0/96, 2002::/24, 2002:a00::/24, 2002:7f00::/24, 2002:a9fe::/32, 2002:ac10::/28, 2002:c0a8::/32, 2002:e000::/19 } log prefix "RFC3964_IPv4_REJECT: " reject with icmpv6 type addr-unreachable
|
|
|
8a3219 |
+ jump filter_FORWARD_IN_ZONES
|
|
|
8a3219 |
+ jump filter_FORWARD_OUT_ZONES
|
|
|
8a3219 |
+ ct state invalid log prefix "STATE_INVALID_DROP: "
|
|
|
8a3219 |
+ ct state invalid drop
|
|
|
8a3219 |
+ log prefix "FINAL_REJECT: "
|
|
|
8a3219 |
+ reject with icmpx type admin-prohibited
|
|
|
8a3219 |
+ }
|
|
|
8a3219 |
+ }
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+
|
|
|
8a3219 |
+IPTABLES_LIST_RULES([filter], [INPUT], 0, [dnl
|
|
|
8a3219 |
+ ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED,DNAT
|
|
|
8a3219 |
+ ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
|
|
|
8a3219 |
+ INPUT_direct all -- 0.0.0.0/0 0.0.0.0/0
|
|
|
8a3219 |
+ INPUT_ZONES all -- 0.0.0.0/0 0.0.0.0/0
|
|
|
8a3219 |
+ LOG all -- 0.0.0.0/0 0.0.0.0/0 ctstate INVALID LOG flags 0 level 4 prefix "STATE_INVALID_DROP: "
|
|
|
8a3219 |
+ DROP all -- 0.0.0.0/0 0.0.0.0/0 ctstate INVALID
|
|
|
8a3219 |
+ LOG all -- 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 4 prefix "FINAL_REJECT: "
|
|
|
8a3219 |
+ REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
|
|
|
8a3219 |
])
|
|
|
8a3219 |
+IPTABLES_LIST_RULES([filter], [FORWARD], 0, [dnl
|
|
|
8a3219 |
+ ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED,DNAT
|
|
|
8a3219 |
+ ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
|
|
|
8a3219 |
+ FORWARD_direct all -- 0.0.0.0/0 0.0.0.0/0
|
|
|
8a3219 |
+ FORWARD_IN_ZONES all -- 0.0.0.0/0 0.0.0.0/0
|
|
|
8a3219 |
+ FORWARD_OUT_ZONES all -- 0.0.0.0/0 0.0.0.0/0
|
|
|
8a3219 |
+ LOG all -- 0.0.0.0/0 0.0.0.0/0 ctstate INVALID LOG flags 0 level 4 prefix "STATE_INVALID_DROP: "
|
|
|
8a3219 |
+ DROP all -- 0.0.0.0/0 0.0.0.0/0 ctstate INVALID
|
|
|
8a3219 |
+ LOG all -- 0.0.0.0/0 0.0.0.0/0 LOG flags 0 level 4 prefix "FINAL_REJECT: "
|
|
|
8a3219 |
+ REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+IP6TABLES_LIST_RULES([filter], [INPUT], 0, [dnl
|
|
|
8a3219 |
+ ACCEPT all ::/0 ::/0 ctstate RELATED,ESTABLISHED,DNAT
|
|
|
8a3219 |
+ ACCEPT all ::/0 ::/0
|
|
|
8a3219 |
+ INPUT_direct all ::/0 ::/0
|
|
|
8a3219 |
+ INPUT_ZONES all ::/0 ::/0
|
|
|
8a3219 |
+ LOG all ::/0 ::/0 ctstate INVALID LOG flags 0 level 4 prefix "STATE_INVALID_DROP: "
|
|
|
8a3219 |
+ DROP all ::/0 ::/0 ctstate INVALID
|
|
|
8a3219 |
+ LOG all ::/0 ::/0 LOG flags 0 level 4 prefix "FINAL_REJECT: "
|
|
|
8a3219 |
+ REJECT all ::/0 ::/0 reject-with icmp6-adm-prohibited
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+IP6TABLES_LIST_RULES([filter], [FORWARD], 0, [dnl
|
|
|
8a3219 |
+ ACCEPT all ::/0 ::/0 ctstate RELATED,ESTABLISHED,DNAT
|
|
|
8a3219 |
+ ACCEPT all ::/0 ::/0
|
|
|
8a3219 |
+ FORWARD_direct all ::/0 ::/0
|
|
|
8a3219 |
+ RFC3964_IPv4 all ::/0 ::/0
|
|
|
8a3219 |
+ FORWARD_IN_ZONES all ::/0 ::/0
|
|
|
8a3219 |
+ FORWARD_OUT_ZONES all ::/0 ::/0
|
|
|
8a3219 |
+ LOG all ::/0 ::/0 ctstate INVALID LOG flags 0 level 4 prefix "STATE_INVALID_DROP: "
|
|
|
8a3219 |
+ DROP all ::/0 ::/0 ctstate INVALID
|
|
|
8a3219 |
+ LOG all ::/0 ::/0 LOG flags 0 level 4 prefix "FINAL_REJECT: "
|
|
|
8a3219 |
+ REJECT all ::/0 ::/0 reject-with icmp6-adm-prohibited
|
|
|
8a3219 |
+])
|
|
|
8a3219 |
+
|
|
|
8a3219 |
FWD_END_TEST
|
|
|
8a3219 |
--
|
|
|
8a3219 |
2.20.1
|
|
|
8a3219 |
|