The branch stable/14 has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=70b70acec7797961e6c6a8810b8fac4ca3dddd30

commit 70b70acec7797961e6c6a8810b8fac4ca3dddd30
Author:     Kristof Provost <[email protected]>
AuthorDate: 2026-08-26 14:52:07 +0000
Commit:     Kristof Provost <[email protected]>
CommitDate: 2026-09-03 14:03:15 +0000

    pfctl: fix printing of wildcard anchors
    
    PR:             297839
    MFC after:      1 week
    Obtained from:  OpenBSD, henning <[email protected]>, 5b6657d4d8
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    
    (cherry picked from commit 5de5140f06959f2724c626c7fab3e1c9187beefb)
---
 sbin/pfctl/pfctl.c             | 10 ++++++----
 tests/sys/netpfil/pf/anchor.sh | 30 ++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index 50ed978d1a74..083640524523 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -2876,6 +2876,7 @@ main(int argc, char *argv[])
        int      opts = 0;
        int      optimize = PF_OPTIMIZE_BASIC;
        char     anchorname[MAXPATHLEN];
+       int      anchor_wildcard = 0;
        char    *path;
 
        if (argc < 2)
@@ -3043,9 +3044,10 @@ main(int argc, char *argv[])
                int len = strlen(anchoropt);
 
                if (len >= 1 && anchoropt[len - 1] == '*') {
-                       if (len >= 2 && anchoropt[len - 2] == '/')
+                       if (len >= 2 && anchoropt[len - 2] == '/') {
                                anchoropt[len - 2] = '\0';
-                       else
+                               anchor_wildcard = 1;
+                       } else
                                anchoropt[len - 1] = '\0';
                        opts |= PF_OPT_RECURSE;
                }
@@ -3090,12 +3092,12 @@ main(int argc, char *argv[])
                case 'r':
                        pfctl_load_fingerprints(dev, opts);
                        pfctl_show_rules(dev, path, opts, PFCTL_SHOW_RULES,
-                           anchorname, 0, 0);
+                           anchorname, 0, anchor_wildcard);
                        break;
                case 'l':
                        pfctl_load_fingerprints(dev, opts);
                        pfctl_show_rules(dev, path, opts, PFCTL_SHOW_LABELS,
-                           anchorname, 0, 0);
+                           anchorname, 0, anchor_wildcard);
                        break;
                case 'n':
                        pfctl_load_fingerprints(dev, opts);
diff --git a/tests/sys/netpfil/pf/anchor.sh b/tests/sys/netpfil/pf/anchor.sh
index da4ef3970d18..511faacc3525 100644
--- a/tests/sys/netpfil/pf/anchor.sh
+++ b/tests/sys/netpfil/pf/anchor.sh
@@ -206,6 +206,35 @@ nat_cleanup()
        pft_cleanup
 }
 
+atf_test_case "show_recursive" "cleanup"
+show_recursive_head()
+{
+       atf_set descr 'Test showing anchors recursively. PR 297839'
+       atf_set require.user root
+}
+
+show_recursive_body()
+{
+       pft_init
+
+       vnet_mkjail alcatraz
+
+       pft_set_rules alcatraz \
+           "pass in no state" \
+           "pass out no state" \
+           "anchor \"test/*\""
+
+       echo 'pass in' | jexec alcatraz pfctl -a test/testing -f -
+
+       atf_check -o match:"pass in" \
+           jexec alcatraz pfctl -a 'test/*' -sr
+}
+
+show_recursive_cleanup()
+{
+       pft_cleanup
+}
+
 atf_init_test_cases()
 {
        atf_add_test_case "pr183198"
@@ -213,4 +242,5 @@ atf_init_test_cases()
        atf_add_test_case "nested_anchor"
        atf_add_test_case "wildcard"
        atf_add_test_case "nat"
+       atf_add_test_case "show_recursive"
 }

Reply via email to