diff options
| author | Denys Fedoryshchenko <denys.f@collabora.com> | 2026-06-04 17:43:25 +0300 |
|---|---|---|
| committer | Denys Fedoryshchenko <denys.f@collabora.com> | 2026-06-04 17:45:50 +0300 |
| commit | 5fc07183e90b5ce7c9d3ede955266ba575388965 (patch) | |
| tree | b514bfd84fe63b05bbdd57f0bba97a4c6280d0e0 | |
| parent | 8494d63943e69e2f7217ca401f6b9ba46b44cca8 (diff) | |
| download | accel-ppp-5fc07183e90b5ce7c9d3ede955266ba575388965.tar.gz accel-ppp-5fc07183e90b5ce7c9d3ede955266ba575388965.zip | |
log_file: don't register general target when log-file is unset
The general log target was registered unconditionally in init(), even
when no log-file= option was configured. The backing log_file pointer is
only allocated when the option is present, so the first general-routed
log message dereferenced NULL in queue_log() (spin_lock(&NULL->lock)),
crashing the daemon. This made commenting out log-file= a foot-gun.
Guard the registration on log_file being allocated, mirroring how the
fail/per-user/per-session targets are already conditional. Also bail out
of general_reopen() early when log-file is unset, so a SIGHUP after a
config reload that dropped log-file can't call open(NULL, ...).
| -rw-r--r-- | accel-pppd/logs/log_file.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/accel-pppd/logs/log_file.c b/accel-pppd/logs/log_file.c index a6bb1fe4..26dd4422 100644 --- a/accel-pppd/logs/log_file.c +++ b/accel-pppd/logs/log_file.c @@ -385,7 +385,12 @@ static void general_reopen(void) { const char *fname = conf_get_opt("log", "log-file"); int old_fd = -1; - int fd = open(fname, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, S_IRUSR | S_IWUSR); + int fd; + + if (!fname) + return; + + fd = open(fname, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, S_IRUSR | S_IWUSR); if (fd < 0) { log_emerg("log_file: open '%s': %s\n", fname, strerror(errno)); return; @@ -710,7 +715,8 @@ static void init(void) if (opt && atoi(opt) > 0) conf_copy = 1; - log_register_target(&general_target); + if (log_file) + log_register_target(&general_target); if (conf_per_user_dir) { log_register_target(&per_user_target); |
