summaryrefslogtreecommitdiffstats
path: root/plugins/imklog/linux.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/imklog/linux.c')
-rw-r--r--plugins/imklog/linux.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/plugins/imklog/linux.c b/plugins/imklog/linux.c
index 198b7c0e..727708a5 100644
--- a/plugins/imklog/linux.c
+++ b/plugins/imklog/linux.c
@@ -37,6 +37,7 @@
#include "msg.h"
#include "module-template.h"
#include "imklog.h"
+#include "unicode-helper.h"
/* Includes. */
@@ -84,19 +85,21 @@ static enum LOGSRC {none, proc, kernel} logsrc;
extern int ksyslog(int type, char *buf, int len);
+static uchar *GetPath(void)
+{
+ return pszPath ? pszPath : UCHAR_CONSTANT(_PATH_KLOG);
+}
+
static void CloseLogSrc(void)
{
- /* Turn on logging of messages to console, but only if we had the -c
- * option -- rgerhards, 2007-08-01
- */
- if (console_log_level != -1)
+ /* Turn on logging of messages to console, but only if a log level was speficied */
+ if(console_log_level != -1)
ksyslog(7, NULL, 0);
/* Shutdown the log sources. */
- switch ( logsrc )
- {
+ switch(logsrc) {
case kernel:
- ksyslog(0, 0, 0);
+ ksyslog(0, NULL, 0);
imklogLogIntMsg(LOG_INFO, "Kernel logging (ksyslog) stopped.");
break;
case proc:
@@ -135,7 +138,7 @@ static enum LOGSRC GetKernelLogSrc(void)
* file system is available to get kernel messages from.
*/
if ( use_syscall ||
- ((stat(_PATH_KLOG, &sb) < 0) && (errno == ENOENT)) )
+ ((stat((char*)GetPath(), &sb) < 0) && (errno == ENOENT)) )
{
/* Initialize kernel logging. */
ksyslog(1, NULL, 0);
@@ -144,14 +147,14 @@ static enum LOGSRC GetKernelLogSrc(void)
return(kernel);
}
- if ( (kmsg = open(_PATH_KLOG, O_RDONLY)) < 0 )
+ if ( (kmsg = open((char*)GetPath(), O_RDONLY|O_CLOEXEC)) < 0 )
{
imklogLogIntMsg(LOG_ERR, "imklog: Cannot open proc file system, %d.\n", errno);
- ksyslog(7, NULL, 0); /* TODO: check this, implement more */
+ ksyslog(7, NULL, 0);
return(none);
}
- imklogLogIntMsg(LOG_INFO, "imklog %s, log source = %s started.", VERSION, _PATH_KLOG);
+ imklogLogIntMsg(LOG_INFO, "imklog %s, log source = %s started.", VERSION, GetPath());
return(proc);
}