aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJan Palus <jpalus@fastmail.com>2023-10-26 21:15:36 +0000
committerDaniel Eklöf <daniel@ekloef.se>2023-10-27 14:21:46 +0000
commit8e1b51be102dbbfc2f4965e60431eeb60712f069 (patch)
tree25e230f1ffce4f233093fcae9b700bf6fc33f4af /config.c
parentmain: correct short option case in help output for disabling syslog (diff)
config: reset conf file descriptor after closing file stream
conf file descriptor is closed once again during cleanup at the end of config_load() if descriptor >= 0. avoid double closing by assigning negative value to fd after first close. by the time second close happens some other descriptor might be opened reusing previous number ie it might happen during foot server startup when syslog message is logged between one close and the other. in this particular situation, as of this writing, it considers fd=3 for which following events apply: 1. conf file is opened and fclosed() 2. warning is logged with syslog which leads to opening socket to /dev/log which is kept open by glibc (gets fd=3) 3. second close during config_load() closes /dev/log socket descriptor 4. epoll_create() in fdm.c reuses fd=3 again 5. another message is being logged with syslog. glibc notices sendto() failure on saved /dev/log descriptor hence it closes it and opens new one Due to epoll descriptor closure foot starts a chain of errors that lead to startup failure. Fixes #1531
Diffstat (limited to 'config.c')
-rw-r--r--config.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/config.c b/config.c
index 98d2918b..e5cd6723 100644
--- a/config.c
+++ b/config.c
@@ -3195,6 +3195,7 @@ config_load(struct config *conf, const char *conf_path,
ret = !errors_are_fatal;
fclose(f);
+ conf_file.fd = -1;
}
}