diff options
author | Vladimír Čunát <vladimir.cunat@nic.cz> | 2017-06-26 10:26:33 +0200 |
---|---|---|
committer | Vladimír Čunát <vladimir.cunat@nic.cz> | 2017-06-26 10:27:25 +0200 |
commit | 03c5d5fc6f920d51b571d2aa3ab004fd0da8f5c3 (patch) | |
tree | a446cc673391f9f49a7b6ac8b7d8dd6cfe09289d /daemon/main.c | |
parent | Merge !315: doc/build.rst updates (diff) | |
download | knot-resolver-03c5d5fc6f920d51b571d2aa3ab004fd0da8f5c3.tar.xz knot-resolver-03c5d5fc6f920d51b571d2aa3ab004fd0da8f5c3.zip |
daemon: check existence of config file
... even if rundir isn't specified. No other changes in semantics.
Before this a typo in config path would pass silently.
Diffstat (limited to 'daemon/main.c')
-rw-r--r-- | daemon/main.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/daemon/main.c b/daemon/main.c index 6de5e5cd..ad665499 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -548,12 +548,16 @@ int main(int argc, char **argv) kr_log_error("[system] rundir '%s': %s\n", rundir, strerror(errno)); return EXIT_FAILURE; } - if(config && strcmp(config, "-") != 0 && access(config, R_OK) != 0) { - kr_log_error("[system] rundir '%s'\n", rundir); - kr_log_error("[system] config '%s': %s\n", config, strerror(errno)); - return EXIT_FAILURE; - } } + + if (config && strcmp(config, "-") != 0 && access(config, R_OK) != 0) { + kr_log_error("[system] config '%s': %s\n", config, strerror(errno)); + return EXIT_FAILURE; + } + if (!config && access("config", R_OK) == 0) { + config = "config"; + } + #ifndef CAN_FORK_EARLY /* Forking is currently broken with libuv. We need libuv to bind to * sockets etc. before forking, but at the same time can't touch it before @@ -655,7 +659,7 @@ int main(int argc, char **argv) worker->loop = loop; loop->data = worker; - ret = engine_start(&engine, config ? config : "config"); + ret = engine_start(&engine, config); if (ret != 0) { ret = EXIT_FAILURE; goto cleanup; |