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 f951460ae9 and f6f049070e.
This commit is contained in:
Quora Dodrill 2013-08-14 15:26:29 -07:00
parent 7ddd614cd3
commit a576a0fe64

View file

@ -1350,6 +1350,8 @@ read_conf_files(int cold)
dont know anything else dont know anything else
- Gozem 2002-07-21 - Gozem 2002-07-21
*/ */
rb_strlcpy(conffilebuf, filename, sizeof(conffilebuf)); rb_strlcpy(conffilebuf, filename, sizeof(conffilebuf));
@ -1357,8 +1359,23 @@ read_conf_files(int cold)
{ {
if(cold) if(cold)
{ {
ilog(L_MAIN, "Failed in reading configuration file %s", filename);
inotice("Failed in reading configuration file %s, aborting", 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); exit(-1);
} }
else else