The branch stable/15 has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=678f107b5c7898570d33d9667217e8901fdc79c6

commit 678f107b5c7898570d33d9667217e8901fdc79c6
Author:     Kristof Provost <[email protected]>
AuthorDate: 2026-08-26 14:52:07 +0000
Commit:     Kristof Provost <[email protected]>
CommitDate: 2026-09-03 14:03:04 +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 1b0a342337e7..ccf84566fcac 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -3178,6 +3178,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)
@@ -3364,9 +3365,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;
                }
@@ -3417,12 +3419,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 f321c742788e..1f728a6ce0b1 100644
--- a/tests/sys/netpfil/pf/anchor.sh
+++ b/tests/sys/netpfil/pf/anchor.sh
@@ -538,6 +538,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"
@@ -553,4 +582,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