From: Quora Dodrill Date: Wed, 14 Aug 2013 22:26:29 +0000 (-0700) Subject: src/s_conf: More detailed error messages conforming to POSIX errno X-Git-Url: https://jfr.im/git/solanum.git/commitdiff_plain/a576a0fe64158002cd868e8a0dd72ff9ccbcfecd src/s_conf: More detailed error messages conforming to POSIX errno When the configuration file is unreadable or not existing, charybdis will now report the POSIX error message from the failed call. This is a compromise between the behavior in f951460ae991e2e8defb9638f8ee508283705cbb and f6f049070e240d0ce637e9e3ac4fba4148b9725d. --- diff --git a/src/s_conf.c b/src/s_conf.c index 15e7006a..d3059e46 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -1350,6 +1350,8 @@ read_conf_files(int cold) dont know anything else - Gozem 2002-07-21 + + */ rb_strlcpy(conffilebuf, filename, sizeof(conffilebuf)); @@ -1357,8 +1359,23 @@ read_conf_files(int cold) { if(cold) { - ilog(L_MAIN, "Failed in reading configuration file %s", filename); inotice("Failed in reading configuration file %s, aborting", filename); + ilog(L_MAIN, "Failed in reading configuration file %s", filename); + + int e; + e = errno; + + if (access(filename, F_OK) == -1) + { + inotice("FATAL: %s %s", strerror(e), filename); + ilog(L_MAIN, "FATAL: %s %s", strerror(e), filename); + } + else if (access(filename, R_OK) == -1) + { + inotice("FATAL: %s %s", strerror(e), filename); + ilog(L_MAIN, "FATAL: %s %s", strerror(e), filename); + } + exit(-1); } else