diff --git a/ChangeLog b/ChangeLog index b1ce9327..ab0afcf3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -40,6 +40,9 @@ ver. 1.1.1-dev-1 (20??/??/??) - development nightly edition - postfix backend switched to `systemd` (gh-3527) * `action.d/firewallcmd-ipset.conf`: - rename `ipsettype` to `ipsetbackend` (gh-2620), parameter `ipsettype` will be used now to the real set type (gh-3760) +* `action.d/nftables.conf`: + - action fixed for SELinux without execmem permission, rewrite capturing with `grep -P` using `grep -E` or `sed` + (PCRE-JIT by `grep -P` may cause SELinux denial for execmem, see gh-4137) * `action.d/xarf-login-attack.conf` - ignore errors or warnings in output of `dig` provided as comment (gh-4068) * `filter.d/apache-badbots.conf`, `filter.d/apache-fakegooglebot.conf`: - regexs rewritten more strict (removed catch-alls, etc); diff --git a/config/action.d/nftables.conf b/config/action.d/nftables.conf index a55128e9..94ff9cdf 100644 --- a/config/action.d/nftables.conf +++ b/config/action.d/nftables.conf @@ -53,7 +53,7 @@ _nft_for_proto-multiport-iter = for proto in $(echo '' | sed 's/,/ /g' _nft_for_proto-multiport-done = done _nft_list = -a list chain -_nft_get_handle_id = grep -oP '@\s+.*\s+\Khandle\s+(\d+)$' +_nft_get_handle_id = sed -nE 's/.*@\s+.*\s+\#\s*(handle\s+[0-9]+)$/\1/p' _nft_add_set = add set
\{ type \; \} <_nft_for_proto--iter> @@ -67,7 +67,7 @@ _nft_del_set = { %(_nft_list)s | %(_nft_get_handle_id)s; } | while read -r hdl; # Notes.: command executed after the stop in order to delete table (it checks that no sets are available): # Values: CMD # -_nft_shutdown_table = { list table
| grep -qP '^\s+set\s+'; } || { +_nft_shutdown_table = { list table
| grep -qE '^\s+set\s+'; } || { delete table
} diff --git a/fail2ban/tests/servertestcase.py b/fail2ban/tests/servertestcase.py index 040e9c03..cf7006f2 100644 --- a/fail2ban/tests/servertestcase.py +++ b/fail2ban/tests/servertestcase.py @@ -1362,10 +1362,10 @@ class ServerConfigReaderTests(LogCaptureTestCase): "`{ nft flush set inet f2b-table addr6-set-j-w-nft-mp 2> /dev/null; } || ", ), 'stop': ( - r"`{ nft -a list chain inet f2b-table f2b-chain | grep -oP '@addr-set-j-w-nft-mp\s+.*\s+\Khandle\s+(\d+)$'; } | while read -r hdl; do`", + r"`{ nft -a list chain inet f2b-table f2b-chain | sed -nE 's/.*@addr-set-j-w-nft-mp\s+.*\s+\#\s*(handle\s+[0-9]+)$/\1/p'; } | while read -r hdl; do`", r"`nft delete rule inet f2b-table f2b-chain $hdl; done`", r"`nft delete set inet f2b-table addr-set-j-w-nft-mp`", - r"`{ nft -a list chain inet f2b-table f2b-chain | grep -oP '@addr6-set-j-w-nft-mp\s+.*\s+\Khandle\s+(\d+)$'; } | while read -r hdl; do`", + r"`{ nft -a list chain inet f2b-table f2b-chain | sed -nE 's/.*@addr6-set-j-w-nft-mp\s+.*\s+\#\s*(handle\s+[0-9]+)$/\1/p'; } | while read -r hdl; do`", r"`nft delete rule inet f2b-table f2b-chain $hdl; done`", r"`nft delete set inet f2b-table addr6-set-j-w-nft-mp`", ), @@ -1408,10 +1408,10 @@ class ServerConfigReaderTests(LogCaptureTestCase): "`{ nft flush set inet f2b-table addr6-set-j-w-nft-ap 2> /dev/null; } || ", ), 'stop': ( - r"`{ nft -a list chain inet f2b-table f2b-chain | grep -oP '@addr-set-j-w-nft-ap\s+.*\s+\Khandle\s+(\d+)$'; } | while read -r hdl; do`", + r"`{ nft -a list chain inet f2b-table f2b-chain | sed -nE 's/.*@addr-set-j-w-nft-ap\s+.*\s+\#\s*(handle\s+[0-9]+)$/\1/p'; } | while read -r hdl; do`", r"`nft delete rule inet f2b-table f2b-chain $hdl; done`", r"`nft delete set inet f2b-table addr-set-j-w-nft-ap`", - r"`{ nft -a list chain inet f2b-table f2b-chain | grep -oP '@addr6-set-j-w-nft-ap\s+.*\s+\Khandle\s+(\d+)$'; } | while read -r hdl; do`", + r"`{ nft -a list chain inet f2b-table f2b-chain | sed -nE 's/.*@addr6-set-j-w-nft-ap\s+.*\s+\#\s*(handle\s+[0-9]+)$/\1/p'; } | while read -r hdl; do`", r"`nft delete rule inet f2b-table f2b-chain $hdl; done`", r"`nft delete set inet f2b-table addr6-set-j-w-nft-ap`", ),