From c5b0932bad5e32d658ed171cf009c0f8c4f6ba58 Mon Sep 17 00:00:00 2001 From: yrutschle Date: Fri, 19 Jun 2020 23:39:25 +0200 Subject: [PATCH] syslog_facility 'none' disables syslog --- ChangeLog | 3 +++ common.c | 16 +++++++++++++--- example.cfg | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 76cd1d4..237289d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -18,6 +18,9 @@ vNEXT: Log to syslog even if in foreground (for people who use fail2ban) + Use syslog_facility: "none" to disable syslog + output. + v1.20: 20NOV2018 Added support for socks5 protocol (Eugene Protozanov) diff --git a/common.c b/common.c index 9405bdf..517f615 100644 --- a/common.c +++ b/common.c @@ -41,6 +41,9 @@ struct sslhcfg_item cfg; struct addrinfo *addr_listen = NULL; /* what addresses do we listen to? */ + +static int do_syslog = 1; /* Should we syslog? controled by syslog_facility = "none" */ + #ifdef LIBWRAP #include int allow_severity =0, deny_severity = 0; @@ -563,9 +566,11 @@ void log_message(int type, const char* msg, ...) vfprintf(stderr, msg, ap); va_end(ap); - va_start(ap, msg); - vsyslog(type, msg, ap); - va_end(ap); + if (do_syslog) { + va_start(ap, msg); + vsyslog(type, msg, ap); + va_end(ap); + } } @@ -727,6 +732,11 @@ void setup_syslog(const char* bin_name) { char *name1, *name2; int res, fn; + if (!strcmp(cfg.syslog_facility, "none")) { + do_syslog = 0; + return; + } + name1 = strdup(bin_name); res = asprintf(&name2, "%s[%d]", basename(name1), getpid()); CHECK_RES_DIE(res, "asprintf"); diff --git a/example.cfg b/example.cfg index 75d87eb..51d085c 100644 --- a/example.cfg +++ b/example.cfg @@ -17,6 +17,7 @@ chroot: "/var/empty"; # system are usually defined in /usr/include/*/sys/syslog.h # or equivalent) # Default is "auth" +# "none" disables use of syslog syslog_facility: "auth"; # List of interfaces on which we should listen