Commit 03c5d5fc authored by Vladimír Čunát's avatar Vladimír Čunát

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.
parent 5b1678f1
Pipeline #6630 canceled with stages
in 34 seconds
Knot Resolver 1.3.2 (2017-07-xx)
================================
Bugfixes
--------
- daemon: check existence of config file even if rundir isn't specified
Knot Resolver 1.3.1 (2017-06-23)
================================
......
......@@ -765,10 +765,10 @@ static int engine_loadconf(struct engine *engine, const char *config_path)
return kr_error(ENOEXEC);
}
/* Load config file */
if (strcmp(config_path, "-") == 0) {
return ret; /* No config, no defaults. */
}
if(access(config_path, F_OK ) != -1 ) {
if (config_path) {
if (strcmp(config_path, "-") == 0) {
return ret; /* No config and no defaults. */
}
ret = l_dosandboxfile(engine->L, config_path);
}
if (ret == 0) {
......
......@@ -78,12 +78,19 @@ int engine_cmd(struct lua_State *L, const char *str, bool raw);
int engine_pcall(struct lua_State *L, int argc);
int engine_ipc(struct engine *engine, const char *expr);
/** Start the lua engine and execute the config.
*
* @note Special path "-" means that even default config won't be done
* (like listening on localhost).
*/
int engine_start(struct engine *engine, const char *config_path);
void engine_stop(struct engine *engine);
int engine_register(struct engine *engine, const char *module, const char *precedence, const char* ref);
int engine_unregister(struct engine *engine, const char *module);
void engine_lualib(struct engine *engine, const char *name, int (*lib_cb) (struct lua_State *));
/** Return engine light userdata. */
struct engine *engine_luaget(struct lua_State *L);
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment