From 5c35619385bbe50979fa417e6f1b14df531b2a4a Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Tue, 18 Jul 2017 14:31:29 +0200 Subject: [PATCH] imklog: Fix permitnonkernelfacility not working permitnonkernelfacility doesn't work when the new configuration syntax is used, e.g. 'module(load="imklog" permitnonkernelfacility="on")'. It does work with the old syntax, e.g. '$KLogPermitNonKernelFacility on' This is because the old style config is stored in a static global struct "cs", while the new style config is passed in as a pointer. Code in imklog will put old style config entries into the new config struct, and almost all the code in imklog uses the new config struct like it should. Except for a check for bPermitNonKernel in Syslog() that continued to use the static global that only has old style configs. Fix this by passing pModConf down into Syslog() and using that in place of the static global. closes https://github.com/rsyslog/rsyslog/issues/477 --- plugins/imklog/bsd.c | 4 ++-- plugins/imklog/imklog.c | 4 ++-- plugins/imklog/imklog.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/imklog/bsd.c b/plugins/imklog/bsd.c index 928cf9bd3..ff91cb213 100644 --- a/plugins/imklog/bsd.c +++ b/plugins/imklog/bsd.c @@ -144,13 +144,13 @@ submitSyslog(modConfData_t *pModConf, syslog_pri_t pri, uchar *buf) tp = &tv; done: - Syslog(pri, buf, tp); + Syslog(pModConf, pri, buf, tp); } #else /* now comes the BSD "code" (just a shim) */ static void submitSyslog(modConfData_t *pModConf, syslog_pri_t pri, uchar *buf) { - Syslog(pri, buf, NULL); + Syslog(pModConf, pri, buf, NULL); } #endif /* #ifdef LINUX */ diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c index e6776b37d..b7abc6209 100644 --- a/plugins/imklog/imklog.c +++ b/plugins/imklog/imklog.c @@ -220,7 +220,7 @@ rsRetVal imklogLogIntMsg(syslog_pri_t priority, const char *fmt, ...) * time to use. * rgerhards, 2008-04-14 */ -rsRetVal Syslog(syslog_pri_t priority, uchar *pMsg, struct timeval *tp) +rsRetVal Syslog(modConfData_t *pModConf, syslog_pri_t priority, uchar *pMsg, struct timeval *tp) { syslog_pri_t pri; int bPRISet = 0; @@ -249,7 +249,7 @@ rsRetVal Syslog(syslog_pri_t priority, uchar *pMsg, struct timeval *tp) /* if we don't get the pri, we use whatever we were supplied */ /* ignore non-kernel messages if not permitted */ - if(cs.bPermitNonKernel == 0 && pri2fac(priority) != LOG_KERN) + if(pModConf->bPermitNonKernel == 0 && pri2fac(priority) != LOG_KERN) FINALIZE; /* silently ignore */ iRet = enqMsg((uchar*)pMsg, (uchar*) "kernel:", priority, tp); diff --git a/plugins/imklog/imklog.h b/plugins/imklog/imklog.h index 476113223..13fa83ad9 100644 --- a/plugins/imklog/imklog.h +++ b/plugins/imklog/imklog.h @@ -55,7 +55,7 @@ int klogFacilIntMsg(void); /* the functions below may be called by the drivers */ rsRetVal imklogLogIntMsg(syslog_pri_t priority, const char *fmt, ...) __attribute__((format(printf,2, 3))); -rsRetVal Syslog(syslog_pri_t priority, uchar *msg, struct timeval *tp); +rsRetVal Syslog(modConfData_t *pModConf, syslog_pri_t priority, uchar *msg, struct timeval *tp); /* prototypes */ extern int klog_getMaxLine(void); /* work-around for klog drivers to get configured max line size */