[client] config: do not attempt to load non-files as config

Currently, we load /etc/looking-glass-client.ini and/or
~/.config/looking-glass-client.ini as long as they exist, even if they are
not files. We should only load them if they are files.
This commit is contained in:
Quantum 2021-07-30 07:27:09 -04:00 committed by Geoffrey McRae
parent 7d78cba38c
commit 68d8d95266

View file

@ -473,7 +473,7 @@ bool config_load(int argc, char * argv[])
{ {
// load any global options first // load any global options first
struct stat st; struct stat st;
if (stat("/etc/looking-glass-client.ini", &st) >= 0) if (stat("/etc/looking-glass-client.ini", &st) >= 0 && S_ISREG(st.st_mode))
{ {
DEBUG_INFO("Loading config from: /etc/looking-glass-client.ini"); DEBUG_INFO("Loading config from: /etc/looking-glass-client.ini");
if (!option_load("/etc/looking-glass-client.ini")) if (!option_load("/etc/looking-glass-client.ini"))
@ -484,7 +484,7 @@ bool config_load(int argc, char * argv[])
struct passwd * pw = getpwuid(getuid()); struct passwd * pw = getpwuid(getuid());
char * localFile; char * localFile;
alloc_sprintf(&localFile, "%s/.looking-glass-client.ini", pw->pw_dir); alloc_sprintf(&localFile, "%s/.looking-glass-client.ini", pw->pw_dir);
if (stat(localFile, &st) >= 0) if (stat(localFile, &st) >= 0 && S_ISREG(st.st_mode))
{ {
DEBUG_INFO("Loading config from: %s", localFile); DEBUG_INFO("Loading config from: %s", localFile);
if (!option_load(localFile)) if (!option_load(localFile))