The branch main has been updated by kp:

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

commit c87390026a4e11355351d7a22ce456d1ea3cfe06
Author:     Kristof Provost <k...@freebsd.org>
AuthorDate: 2025-07-07 07:09:32 +0000
Commit:     Kristof Provost <k...@freebsd.org>
CommitDate: 2025-07-12 09:57:50 +0000

    pfctl: Fail on missing anchor
    
    There is no reason to continue on anchor specific paths if the given
    anchor does not exist.
    
    OK sashan
    
    Obtained from:  OpenBSD, kn <k...@openbsd.org>, ad846651a1
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 sbin/pfctl/pfctl.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c
index 10f3ee1f44e9..dca9bba06a3e 100644
--- a/sbin/pfctl/pfctl.c
+++ b/sbin/pfctl/pfctl.c
@@ -1340,13 +1340,8 @@ pfctl_show_rules(int dev, char *path, int opts, enum 
pfctl_show format,
                u_int32_t                mnr, nr;
 
                memset(&prs, 0, sizeof(prs));
-               if ((ret = pfctl_get_rulesets(pfh, npath, &mnr)) != 0) {
-                       if (ret == EINVAL)
-                               fprintf(stderr, "Anchor '%s' "
-                                   "not found.\n", anchorname);
-                       else
-                               errc(1, ret, "DIOCGETRULESETS");
-               }
+               if ((ret = pfctl_get_rulesets(pfh, npath, &mnr)) != 0)
+                       errx(1, "%s", pf_strerror(ret));
 
                for (nr = 0; nr < mnr; ++nr) {
                        if ((ret = pfctl_get_ruleset(pfh, npath, nr, &prs)) != 
0)
@@ -2962,13 +2957,8 @@ pfctl_walk_anchors(int dev, int opts, const char *anchor,
        int                      ret;
 
        memset(&pr, 0, sizeof(pr));
-       if ((ret = pfctl_get_rulesets(pfh, anchor, &mnr)) != 0) {
-               if (ret == EINVAL)
-                       fprintf(stderr, "Anchor '%s' not found.\n", anchor);
-               else
-                       errc(1, ret, "DIOCGETRULESETS");
-               return (-1);
-       }
+       if ((ret = pfctl_get_rulesets(pfh, anchor, &mnr)) != 0)
+               errx(1, "%s", pf_strerror(ret));
        for (nr = 0; nr < mnr; ++nr) {
                char sub[MAXPATHLEN];
 

Reply via email to