aboutsummaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-09-17 16:17:16 +0000
committerOmar Polo <op@omarpolo.com>2021-09-17 16:17:16 +0000
commitdb623d7551caaed88664d4e7c379b231f89c6ca4 (patch)
tree4fead2dd9158fabe6432f067cff83d04439b4328 /log.c
parentf2478b332f0f60a53113cdc6434f134c34a2155c (diff)
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!
Diffstat (limited to 'log.c')
-rw-r--r--log.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/log.c b/log.c
index 404d43f..81064e7 100644
--- a/log.c
+++ b/log.c
@@ -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;
}