The branch main has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=5de5140f06959f2724c626c7fab3e1c9187beefb

commit 5de5140f06959f2724c626c7fab3e1c9187beefb
Author:     Kristof Provost <[email protected]>
AuthorDate: 2026-08-26 14:52:07 +0000
Commit:     Kristof Provost <[email protected]>
CommitDate: 2026-08-26 15:03:58 +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")
---
 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 c349487ed9d2..b650c2fcba0d 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -3662,6 +3662,7 @@ main(int argc, char *argv[])
        int      opts = 0;
        int      optimize = PF_OPTIMIZE_BASIC;
        char     anchorname[MAXPATHLEN];
+       int      anchor_wildcard = 0;
        char    *path;
        const char      *idopt = NULL;
 
@@ -3852,9 +3853,10 @@ main(int argc, char *argv[])
                            "be modified from the command line");
 
                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;
                }
@@ -3911,12 +3913,12 @@ main(int argc, char *argv[])
        case SHOWOPT_RULES:
                pfctl_load_fingerprints(dev, opts);
                pfctl_show_rules(dev, path, opts, PFCTL_SHOW_RULES, anchorname,
-                   0, 0);
+                   0, anchor_wildcard);
                break;
        case SHOWOPT_LABELS:
                pfctl_load_fingerprints(dev, opts);
                pfctl_show_rules(dev, path, opts, PFCTL_SHOW_LABELS, anchorname,
-                   0, 0);
+                   0, anchor_wildcard);
                break;
        case SHOWOPT_NAT:
                pfctl_load_fingerprints(dev, opts);
diff --git a/tests/sys/netpfil/pf/anchor.sh b/tests/sys/netpfil/pf/anchor.sh
index df4a1660d797..a1935e126ed3 100644
--- a/tests/sys/netpfil/pf/anchor.sh
+++ b/tests/sys/netpfil/pf/anchor.sh
@@ -550,6 +550,35 @@ recursive_flush_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"
@@ -565,4 +594,5 @@ atf_init_test_cases()
        atf_add_test_case "include"
        atf_add_test_case "quick"
        atf_add_test_case "recursive_flush"
+       atf_add_test_case "show_recursive"
 }

Reply via email to