fix syslog logging on FreeBSD

Due to capsicum(4), opening the log on-demand via syslog(3) fails.
openlog(LOG_NDELAY) forces the log to be opened immediately, before we
enter capsicum.

This doesn't affect OpenBSD (where pledge(2) doesn't stop syslog) nor
linux (where the log process is not sandboxed.)

Reported by Karl Jeacle, thank you!
This commit is contained in:
Omar Polo 2021-09-17 16:17:16 +00:00
parent f2478b332f
commit db623d7551
1 changed files with 4 additions and 0 deletions

4
log.c
View File

@ -328,6 +328,8 @@ logger_main(int fd, struct imsgbuf *ibuf)
{
log = stderr;
openlog(getprogname(), LOG_NDELAY, LOG_DAEMON);
event_init();
event_set(&imsgev, fd, EV_READ | EV_PERSIST, &handle_dispatch_imsg, ibuf);
@ -337,5 +339,7 @@ logger_main(int fd, struct imsgbuf *ibuf)
event_dispatch();
closelog();
return 0;
}