config_libconfig: resolve symlinks when setting include dir

If the config file is loaded from a symlink'd locaiton, it could be
confusing that include dir is set based on the location of the symlink
instead of the real file.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2022-07-14 18:28:56 +01:00
parent e2ed9125ed
commit a8b15f3a1b

View File

@@ -334,15 +334,14 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
config_set_options(&cfg, CONFIG_OPTION_ALLOW_OVERRIDES);
#endif
{
// dirname() could modify the original string, thus we must pass a
// copy
char *path2 = strdup(path);
char *parent = dirname(path2);
char *abspath = realpath(path, NULL);
char *parent = dirname(abspath); // path2 may be modified
if (parent)
if (parent) {
config_set_include_dir(&cfg, parent);
}
free(path2);
free(abspath);
}
{