There is no reason to continue on anchor specific paths if the given
anchor does not exist, so fix the last occurences better error messages:
# pfctl -a regress\* -Fa
Anchor 'regress' not found.
pfctl: pfctl_get_anchors failed to retrieve list of anchors, can't
continue
# ./obj/pfctl -a regress\* -Fa
pfctl: Anchor does not exist
Feedback? OK?
Index: pfctl.c
===================================================================
RCS file: /cvs/src/sbin/pfctl/pfctl.c,v
retrieving revision 1.381
diff -u -p -r1.381 pfctl.c
--- pfctl.c 15 Jan 2020 22:38:31 -0000 1.381
+++ pfctl.c 15 Jan 2020 22:50:04 -0000
@@ -967,13 +967,8 @@ pfctl_show_rules(int dev, char *path, in
memset(&prs, 0, sizeof(prs));
memcpy(prs.path, npath, sizeof(prs.path));
- if (ioctl(dev, DIOCGETRULESETS, &prs) == -1) {
- if (errno == EINVAL)
- fprintf(stderr, "Anchor '%s' "
- "not found.\n", anchorname);
- else
- err(1, "DIOCGETRULESETS");
- }
+ if (ioctl(dev, DIOCGETRULESETS, &prs) == -1)
+ errx(1, "%s", pf_strerror(errno));
mnr = prs.nr;
for (nr = 0; nr < mnr; ++nr) {
@@ -2206,13 +2201,8 @@ pfctl_walk_anchors(int dev, int opts, co
memset(&pr, 0, sizeof(pr));
strlcpy(pr.path, anchor, sizeof(pr.path));
- if (ioctl(dev, DIOCGETRULESETS, &pr) == -1) {
- if (errno == EINVAL)
- fprintf(stderr, "Anchor '%s' not found.\n", anchor);
- else
- err(1, "DIOCGETRULESETS");
- return (-1);
- }
+ if (ioctl(dev, DIOCGETRULESETS, &pr) == -1)
+ errx(1, "%s", pf_strerror(errno));
mnr = pr.nr;
for (nr = 0; nr < mnr; ++nr) {
char sub[PATH_MAX];