mirror of
https://github.com/clearlinux/linux-steam-integration.git
synced 2026-10-04 16:08:24 +00:00
common: Return realpath'd config dir where possible
This ensures we only use a sane realpath and collapse the slashes where we can to allow trivial string matching. Signed-off-by: Ikey Doherty <ikey@solus-project.com>
This commit is contained in:
@@ -55,9 +55,14 @@ char *lsi_get_user_config_dir()
|
||||
const char *home = NULL;
|
||||
char *c = NULL;
|
||||
char *xdg_config = getenv("XDG_CONFIG_HOME");
|
||||
char *p = NULL;
|
||||
|
||||
/* Respect the XDG_CONFIG_HOME variable if it is set */
|
||||
if (xdg_config) {
|
||||
p = realpath(xdg_config, NULL);
|
||||
if (p) {
|
||||
return p;
|
||||
}
|
||||
return strdup(xdg_config);
|
||||
}
|
||||
|
||||
@@ -65,6 +70,11 @@ char *lsi_get_user_config_dir()
|
||||
if (asprintf(&c, "%s/.config", home) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
p = realpath(c, NULL);
|
||||
if (p) {
|
||||
free(c);
|
||||
return p;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user