aboutsummaryrefslogtreecommitdiff
path: root/logger.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2023-07-26 08:10:12 +0000
committerOmar Polo <op@omarpolo.com>2023-07-26 08:10:12 +0000
commit46bcc4ea95b03fe81ad361ee02bd021a7618e5a9 (patch)
tree16728cce2ffae1c408d6807303da4f9598894121 /logger.c
parentcba01a868748013f838c28ad8005c8377160c76f (diff)
add log syslog off; don't turn syslog off when log access is specified
Diffstat (limited to 'logger.c')
-rw-r--r--logger.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/logger.c b/logger.c
index 4de68c0..d0e25c9 100644
--- a/logger.c
+++ b/logger.c
@@ -38,6 +38,7 @@
#endif
static int logfd = -1;
+static int log_to_syslog = 1;
static void logger_init(struct privsep *, struct privsep_proc *, void *);
static void logger_shutdown(void);
@@ -74,6 +75,11 @@ static int
logger_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
{
switch (imsg->hdr.type) {
+ case IMSG_LOG_SYSLOG:
+ if (IMSG_DATA_SIZE(imsg) != sizeof(log_to_syslog))
+ fatal("corrupted IMSG_LOG_SYSLOG");
+ memcpy(&log_to_syslog, imsg->data, sizeof(log_to_syslog));
+ break;
case IMSG_LOG_ACCESS:
if (logfd != -1)
close(logfd);
@@ -104,7 +110,7 @@ logger_dispatch_server(int fd, struct privsep_proc *p, struct imsg *imsg)
msg[datalen - 1] = '\0';
if (logfd != -1)
dprintf(logfd, "%s\n", msg);
- else
+ if (log_to_syslog)
syslog(LOG_DAEMON | LOG_NOTICE, "%s", msg);
break;
default: