diff options
author | kn <kn@cvs.openbsd.org> | 2020-01-16 01:02:21 +0000 |
---|---|---|
committer | kn <kn@cvs.openbsd.org> | 2020-01-16 01:02:21 +0000 |
commit | 142be4974317e476546305deba2edba40f7fa04a (patch) | |
tree | 4636ac06ab488fe41c00b84db5abde6fcf6ff5bc /sbin/pfctl/pfctl.c | |
parent | ed8904b42c416bc52f0c4d57d5f4f1d9e26fb0bc (diff) |
Fail on missing anchor
There is no reason to continue on anchor specific paths if the given
anchor does not exist.
OK sashan
Diffstat (limited to 'sbin/pfctl/pfctl.c')
-rw-r--r-- | sbin/pfctl/pfctl.c | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 5e00c7c4dae..e01087586c7 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfctl.c,v 1.381 2020/01/15 22:38:31 kn Exp $ */ +/* $OpenBSD: pfctl.c,v 1.382 2020/01/16 01:02:20 kn Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -967,13 +967,8 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, 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, const char *anchor, 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]; |