Skip to content

Commit

Permalink
Fix fallback to global config
Browse files Browse the repository at this point in the history
allinurl#694 results in ~/.goaccessrc always being used, the fallback to the global config file is broken. It appears that the code is assuming that realpath() will return NULL if the file does not exist, which is not the case. Unbreak by actually attempting to open ~/.goaccessrc and falling back to global config if this fails.
  • Loading branch information
sthen authored Jan 11, 2019
1 parent 8377a9a commit a224c92
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ char *
get_config_file_path (void)
{
char *upath = NULL, *rpath = NULL;
FILE *file;

/* determine which config file to open, default or custom */
if (conf.iconfigfile != NULL) {
Expand All @@ -138,12 +139,14 @@ get_config_file_path (void)
}

/* otherwise, fallback to global config file */
if (rpath == NULL && conf.load_global_config) {
if ((file = fopen (rpath, "r")) == NULL && conf.load_global_config) {
upath = get_global_config ();
rpath = realpath (upath, NULL);
if (upath) {
free (upath);
}
} else {
fclose (file);
}

return rpath;
Expand Down

0 comments on commit a224c92

Please sign in to comment.