From 0fbd7c956111aef50c1d8f8e2782e361a4ad3370 Mon Sep 17 00:00:00 2001 From: Costin Lupu Date: Mon, 2 Sep 2019 18:06:45 +0300 Subject: [PATCH] syslog.c: Bring back setlogmask() from musl The OSv implementation, where we took this from, dropped the setlogmask() function. We bring it back from the musl implementation because it is needed by Python 3. Signed-off-by: Costin Lupu Reviewed-by: Vlad-Andrei Badoiu --- musl-imported/src/syslog.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/musl-imported/src/syslog.c b/musl-imported/src/syslog.c index 1792241..ee109f5 100644 --- a/musl-imported/src/syslog.c +++ b/musl-imported/src/syslog.c @@ -70,6 +70,7 @@ static struct uk_mutex lock = UK_MUTEX_INITIALIZER(lock); static char log_ident[32]; static int log_opt; +static int log_mask = 0xff; static int log_facility = LOG_USER; void openlog(const char *ident, int opt, int facility) @@ -95,6 +96,18 @@ void closelog(void) { } +int setlogmask(int maskpri) +{ + int ret; + + LOCK(lock); + ret = log_mask; + if (maskpri) + log_mask = maskpri; + UNLOCK(lock); + return ret; +} + void syslog(int priority, const char *message, ...) { va_list ap; @@ -105,6 +118,9 @@ void syslog(int priority, const char *message, ...) int pid; int l, l2; + if (!(log_mask & LOG_MASK(priority & 7)) || (priority & ~0x3ff)) + return; + LOCK(lock); va_start(ap, message); -- 2.39.5