summaryrefslogtreecommitdiff
path: root/sbin/unwind
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2019-01-29 20:03:50 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2019-01-29 20:03:50 +0000
commit72321dba32090e2724bb7b9722a03d8e81e04fb3 (patch)
tree711b61f10a8aff7bc345baac7301ad2a295737b3 /sbin/unwind
parenta67f556241b2b3a54165e7f9d09276031a35bc1b (diff)
Get rid of ugly access(2) and still be able to run without a config
file. Prodded by deraadt
Diffstat (limited to 'sbin/unwind')
-rw-r--r--sbin/unwind/unwind.c12
-rw-r--r--sbin/unwind/uw_parse.y6
2 files changed, 7 insertions, 11 deletions
diff --git a/sbin/unwind/unwind.c b/sbin/unwind/unwind.c
index 7e829e48919..e582d60b969 100644
--- a/sbin/unwind/unwind.c
+++ b/sbin/unwind/unwind.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: unwind.c,v 1.7 2019/01/29 19:13:01 florian Exp $ */
+/* $OpenBSD: unwind.c,v 1.8 2019/01/29 20:03:49 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -171,14 +171,8 @@ main(int argc, char *argv[])
else if (frontend_flag)
frontend(debug, cmd_opts & (OPT_VERBOSE | OPT_VERBOSE2));
- if (access(conffile, R_OK) == -1 && errno == ENOENT) {
- main_conf = config_new_empty();
- } else {
- /* parse config file */
- if ((main_conf = parse_config(conffile)) == NULL) {
- exit(1);
- }
- }
+ if ((main_conf = parse_config(conffile)) == NULL)
+ exit(1);
if (cmd_opts & OPT_NOACTION) {
if (cmd_opts & OPT_VERBOSE)
diff --git a/sbin/unwind/uw_parse.y b/sbin/unwind/uw_parse.y
index 4c2966da1ac..bdda384e7e3 100644
--- a/sbin/unwind/uw_parse.y
+++ b/sbin/unwind/uw_parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: uw_parse.y,v 1.4 2019/01/29 18:55:34 otto Exp $ */
+/* $OpenBSD: uw_parse.y,v 1.5 2019/01/29 20:03:49 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -622,7 +622,6 @@ pushfile(const char *name, int secret)
return (NULL);
}
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
- log_warn("%s", nfile->name);
free(nfile->name);
free(nfile);
return (NULL);
@@ -673,6 +672,9 @@ parse_config(char *filename)
file = pushfile(filename, 0);
if (file == NULL) {
+ if (errno == ENOENT) /* no config file is fine */
+ return (conf);
+ log_warn("%s", filename);
free(conf);
return (NULL);
}