Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/npf/npfctl PR/56307: Konrad Schroder: npfctl's erro...
details: https://anonhg.NetBSD.org/src/rev/d588188a1dc9
branches: trunk
changeset: 984630:d588188a1dc9
user: christos <christos%NetBSD.org@localhost>
date: Wed Jul 14 09:15:01 2021 +0000
description:
PR/56307: Konrad Schroder: npfctl's error messages don't report the failing
filename.
Add the filename (but in quotes for consistency with other places in the file).
Also fix an err -> errx
diffstat:
usr.sbin/npf/npfctl/npfctl.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diffs (77 lines):
diff -r f2980e994169 -r d588188a1dc9 usr.sbin/npf/npfctl/npfctl.c
--- a/usr.sbin/npf/npfctl/npfctl.c Wed Jul 14 08:51:51 2021 +0000
+++ b/usr.sbin/npf/npfctl/npfctl.c Wed Jul 14 09:15:01 2021 +0000
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: npfctl.c,v 1.64 2020/05/30 14:16:56 rmind Exp $");
+__RCSID("$NetBSD: npfctl.c,v 1.65 2021/07/14 09:15:01 christos Exp $");
#include <sys/types.h>
#include <sys/stat.h>
@@ -301,17 +301,18 @@
* just leaving this responsibility for the caller.
*/
if ((fd = open(path, O_RDONLY)) == -1) {
- err(EXIT_FAILURE, "could not open `%s'", path);
+ err(EXIT_FAILURE, "open: '%s'", path);
}
if (fstat(fd, &sb) == -1) {
- err(EXIT_FAILURE, "stat");
+ err(EXIT_FAILURE, "stat: '%s'", path);
}
if ((blen = sb.st_size) == 0) {
- err(EXIT_FAILURE, "the binary configuration file is empty");
+ errx(EXIT_FAILURE,
+ "the binary configuration file '%s' is empty", path);
}
blob = mmap(NULL, blen, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0);
if (blob == MAP_FAILED) {
- err(EXIT_FAILURE, "mmap");
+ err(EXIT_FAILURE, "mmap: '%s'", path);
}
ncf = npf_config_import(blob, blen);
munmap(blob, blen);
@@ -329,7 +330,7 @@
*/
ncf = npfctl_import(NPF_DB_PATH);
if (ncf == NULL) {
- err(EXIT_FAILURE, "npf_config_import");
+ err(EXIT_FAILURE, "npf_config_import: '%s'", NPF_DB_PATH);
}
if ((errno = npf_config_submit(ncf, fd, &errinfo)) != 0) {
npfctl_print_error(&errinfo);
@@ -345,7 +346,7 @@
int fd;
if (lstat(path, &st) == -1) {
- err(EXIT_FAILURE, "fstat");
+ err(EXIT_FAILURE, "fstat: '%s'", path);
}
if ((st.st_mode & S_IFMT) == S_IFSOCK) {
struct sockaddr_un addr;
@@ -358,11 +359,11 @@
strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1);
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
- err(EXIT_FAILURE, "connect");
+ err(EXIT_FAILURE, "connect: '%s'", path);
}
} else {
if ((fd = open(path, O_RDONLY)) == -1) {
- err(EXIT_FAILURE, "cannot open '%s'", path);
+ err(EXIT_FAILURE, "open: '%s'", path);
}
}
return fd;
@@ -416,7 +417,8 @@
puts("Loading the active configuration");
fd = npfctl_open_dev(NPF_DEV_PATH);
if ((ncf = npf_config_retrieve(fd)) == NULL) {
- err(EXIT_FAILURE, "npf_config_retrieve");
+ err(EXIT_FAILURE, "npf_config_retrieve: '%s'",
+ NPF_DEV_PATH);
}
}
Home |
Main Index |
Thread Index |
Old Index