diff options
author | 2019-05-19 17:08:15 +0300 | |
---|---|---|
committer | 2019-05-19 17:08:15 +0300 | |
commit | 0389fdc7507238221a9747c5fcbca26952e3229c (patch) | |
tree | c33799e4d15d025e87787a7cedcc5001b05478f9 | |
parent | a40cd32e24e18857ab937e1142fe4146334b455c (diff) | |
download | usurpation-0389fdc7507238221a9747c5fcbca26952e3229c.tar.gz usurpation-0389fdc7507238221a9747c5fcbca26952e3229c.tar.bz2 usurpation-0389fdc7507238221a9747c5fcbca26952e3229c.zip |
daemon: read the system-wide config file now.
This usually, but now always means "/etc/usurpation.conf"
Signed-off-by: Gediminas Jakutis <gediminas@varciai.lt>
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | src/daemon/settings.c | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/meson.build b/meson.build index 4a780c8..636aa4b 100644 --- a/meson.build +++ b/meson.build @@ -22,7 +22,7 @@ elif get_option('buildtype') == 'debugoptimized' verb = '3' endif -daemon = executable(progname, d_sources, version, include_directories : inc, install : true, dependencies : deps, extra_files : d_conf, c_args : '-DUSURP_VERBOSITY=' + verb) +daemon = executable(progname, d_sources, version, include_directories : inc, install : true, dependencies : deps, extra_files : d_conf, c_args : ['-DUSURP_VERBOSITY=' + verb, '-DSYSCONFDIR=' + get_option('sysconfdir')]) #install_data(extra, install_dir : resource_dir) install_data(d_conf, install_dir : get_option('sysconfdir')) diff --git a/src/daemon/settings.c b/src/daemon/settings.c index 855d4bb..e5941cc 100644 --- a/src/daemon/settings.c +++ b/src/daemon/settings.c @@ -39,7 +39,11 @@ void settings_init(void) unset_flag(flag_daemonize); settings.port = 6996; settings.verboselevel = USURP_VERBOSITY; - setting_readconf("./usurpation.conf"); +#define macro2str(a) _macro2str(a) +#define _macro2str(a) #a + setting_readconf("/" macro2str(SYSCONFDIR) "/usurpation.conf"); +#undef macro2str +#undef _macro2str } int setting_detach(void) @@ -91,7 +95,7 @@ static int setting_readconf(const char * const path) int fd; - if ((fd = open(path, O_RDONLY | O_NOATIME)) == -1) { + if ((fd = open(path, O_RDONLY)) == -1) { if (USURP_VERBOSITY >= 2) { perror("error while opening the configuration file"); return 1; |