Merge lp:~s-launchpad-paulsd-com/rsyslog/trusty-proposed into lp:ubuntu/trusty-proposed/rsyslog

Proposed by Paul Donohue
Status: Needs review
Proposed branch: lp:~s-launchpad-paulsd-com/rsyslog/trusty-proposed
Merge into: lp:ubuntu/trusty-proposed/rsyslog
Diff against target: 1631 lines (+1432/-29)
13 files modified
.pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog/bsd.c (+298/-0)
.pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog/imklog.c (+488/-0)
.pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog/imklog.h (+70/-0)
.pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imkmsg/imkmsg.c (+295/-0)
.pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imkmsg/imkmsg.h (+64/-0)
debian/changelog (+7/-0)
debian/patches/11-fix-infinite-loop-openvz-vms.patch (+157/-15)
plugins/imklog/bsd.c (+25/-2)
plugins/imklog/imklog.c (+2/-1)
plugins/imklog/imklog.h (+2/-1)
plugins/imkmsg/imkmsg.c (+2/-1)
plugins/imkmsg/imkmsg.h (+2/-1)
plugins/imkmsg/kmsg.c (+20/-8)
To merge this branch: bzr merge lp:~s-launchpad-paulsd-com/rsyslog/trusty-proposed
Reviewer Review Type Date Requested Status
Brian Murray Pending
Review via email: mp+245974@code.launchpad.net

Description of the change

Updated fix for infinite loop on OpenVZ VMs (LP: #1366829)

To post a comment you must log in.

Unmerged revisions

60. By Paul Donohue

Applied updated upstream patch fixing infinite loop on OpenVZ VMs.
(LP: #1366829)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory '.pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog'
2=== added file '.pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog/bsd.c'
3--- .pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog/bsd.c 1970-01-01 00:00:00 +0000
4+++ .pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog/bsd.c 2015-01-09 16:11:08 +0000
5@@ -0,0 +1,298 @@
6+/* combined imklog driver for BSD and Linux
7+ *
8+ * This contains OS-specific functionality to read the BSD
9+ * or Linux kernel log. For a general overview, see head comment in
10+ * imklog.c. This started out as the BSD-specific drivers, but it
11+ * turned out that on modern Linux the implementation details
12+ * are very small, and so we use a single driver for both OS's with
13+ * a little help of conditional compilation.
14+ *
15+ * Copyright 2008-2012 Adiscon GmbH
16+ *
17+ * This file is part of rsyslog.
18+ *
19+ * Licensed under the Apache License, Version 2.0 (the "License");
20+ * you may not use this file except in compliance with the License.
21+ * You may obtain a copy of the License at
22+ *
23+ * http://www.apache.org/licenses/LICENSE-2.0
24+ * -or-
25+ * see COPYING.ASL20 in the source distribution
26+ *
27+ * Unless required by applicable law or agreed to in writing, software
28+ * distributed under the License is distributed on an "AS IS" BASIS,
29+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30+ * See the License for the specific language governing permissions and
31+ * limitations under the License.
32+ */
33+#ifdef HAVE_CONFIG_H
34+# include "config.h"
35+#endif
36+#include <stdlib.h>
37+#include <unistd.h>
38+#include <fcntl.h>
39+#include <errno.h>
40+#include <string.h>
41+#include <ctype.h>
42+#ifdef OS_LINUX
43+# include <sys/klog.h>
44+#endif
45+
46+#include "rsyslog.h"
47+#include "srUtils.h"
48+#include "debug.h"
49+#include "imklog.h"
50+
51+/* globals */
52+static int fklog = -1; /* kernel log fd */
53+
54+#ifndef _PATH_KLOG
55+# ifdef OS_LINUX
56+# define _PATH_KLOG "/proc/kmsg"
57+# else
58+# define _PATH_KLOG "/dev/klog"
59+# endif
60+#endif
61+
62+
63+#ifdef OS_LINUX
64+/* submit a message to imklog Syslog() API. In this function, we check if
65+ * a kernel timestamp is present and, if so, extract and strip it.
66+ * Note that this is heavily Linux specific and thus is not compiled or
67+ * used for BSD.
68+ * Special thanks to Lennart Poettering for suggesting on how to convert
69+ * the kernel timestamp to a realtime timestamp. This method depends on
70+ * the fact the the kernel timestamp is written using the monotonic clock.
71+ * Shall that change (very unlikely), this code must be changed as well. Note
72+ * that due to the way we generate the delta, we are unable to write the
73+ * absolutely correct timestamp (system call overhead of the clock calls
74+ * prevents us from doing so). However, the difference is very minor.
75+ * rgerhards, 2011-06-24
76+ */
77+static void
78+submitSyslog(modConfData_t *pModConf, int pri, uchar *buf)
79+{
80+ long secs;
81+ long usecs;
82+ long secOffs;
83+ long usecOffs;
84+ unsigned i;
85+ unsigned bufsize;
86+ struct timespec monotonic, realtime;
87+ struct timeval tv;
88+ struct timeval *tp = NULL;
89+
90+ if(!pModConf->bParseKernelStamp)
91+ goto done;
92+
93+ if(buf[3] != '[')
94+ goto done;
95+ DBGPRINTF("imklog: kernel timestamp detected, extracting it\n");
96+
97+ /* we now try to parse the timestamp. iff it parses, we assume
98+ * it is a timestamp. Otherwise we know for sure it is no ts ;)
99+ */
100+ i = 4; /* space or first digit after '[' */
101+ while(buf[i] && isspace(buf[i]))
102+ ++i; /* skip space */
103+ secs = 0;
104+ while(buf[i] && isdigit(buf[i])) {
105+ secs = secs * 10 + buf[i] - '0';
106+ ++i;
107+ }
108+ if(buf[i] != '.') {
109+ DBGPRINTF("no dot --> no kernel timestamp\n");
110+ goto done; /* no TS! */
111+ }
112+
113+ ++i; /* skip dot */
114+ usecs = 0;
115+ while(buf[i] && isdigit(buf[i])) {
116+ usecs = usecs * 10 + buf[i] - '0';
117+ ++i;
118+ }
119+ if(buf[i] != ']') {
120+ DBGPRINTF("no trailing ']' --> no kernel timestamp\n");
121+ goto done; /* no TS! */
122+ }
123+ ++i; /* skip ']' */
124+
125+ /* we have a timestamp */
126+ DBGPRINTF("kernel timestamp is %ld %ld\n", secs, usecs);
127+ if(!pModConf->bKeepKernelStamp) {
128+ bufsize= strlen((char*)buf);
129+ memmove(buf+3, buf+i, bufsize - i + 1);
130+ }
131+
132+ clock_gettime(CLOCK_MONOTONIC, &monotonic);
133+ clock_gettime(CLOCK_REALTIME, &realtime);
134+ secOffs = realtime.tv_sec - monotonic.tv_sec;
135+ usecOffs = (realtime.tv_nsec - monotonic.tv_nsec) / 1000;
136+ if(usecOffs < 0) {
137+ secOffs--;
138+ usecOffs += 1000000l;
139+ }
140+
141+ usecs += usecOffs;
142+ if(usecs > 999999l) {
143+ secs++;
144+ usecs -= 1000000l;
145+ }
146+ secs += secOffs;
147+ tv.tv_sec = secs;
148+ tv.tv_usec = usecs;
149+ tp = &tv;
150+
151+done:
152+ Syslog(pri, buf, tp);
153+}
154+#else /* now comes the BSD "code" (just a shim) */
155+static void
156+submitSyslog(modConfData_t *pModConf, int pri, uchar *buf)
157+{
158+ Syslog(pri, buf, NULL);
159+}
160+#endif /* #ifdef LINUX */
161+
162+
163+static uchar *GetPath(modConfData_t *pModConf)
164+{
165+ return pModConf->pszPath ? pModConf->pszPath : (uchar*) _PATH_KLOG;
166+}
167+
168+/* open the kernel log - will be called inside the willRun() imklog
169+ * entry point. -- rgerhards, 2008-04-09
170+ */
171+rsRetVal
172+klogWillRun(modConfData_t *pModConf)
173+{
174+ char errmsg[2048];
175+ int r;
176+ DEFiRet;
177+
178+ fklog = open((char*)GetPath(pModConf), O_RDONLY, 0);
179+ if (fklog < 0) {
180+ imklogLogIntMsg(LOG_ERR, "imklog: cannot open kernel log(%s): %s.",
181+ GetPath(pModConf), rs_strerror_r(errno, errmsg, sizeof(errmsg)));
182+ ABORT_FINALIZE(RS_RET_ERR_OPEN_KLOG);
183+ }
184+
185+# ifdef OS_LINUX
186+ /* Set level of kernel console messaging.. */
187+ if(pModConf->console_log_level != -1) {
188+ r = klogctl(8, NULL, pModConf->console_log_level);
189+ if(r != 0) {
190+ imklogLogIntMsg(LOG_WARNING, "imklog: cannot set console log level: %s",
191+ rs_strerror_r(errno, errmsg, sizeof(errmsg)));
192+ /* make sure we do not try to re-set! */
193+ pModConf->console_log_level = -1;
194+ }
195+ }
196+# endif /* #ifdef OS_LINUX */
197+
198+finalize_it:
199+ RETiRet;
200+}
201+
202+
203+/* Read kernel log while data are available, split into lines.
204+ */
205+static void
206+readklog(modConfData_t *pModConf)
207+{
208+ char *p, *q;
209+ int len, i;
210+ int iMaxLine;
211+ uchar bufRcv[128*1024+1];
212+ char errmsg[2048];
213+ uchar *pRcv = NULL; /* receive buffer */
214+
215+ iMaxLine = klog_getMaxLine();
216+
217+ /* we optimize performance: if iMaxLine is below our fixed size buffer (which
218+ * usually is sufficiently large), we use this buffer. if it is higher, heap memory
219+ * is used. We could use alloca() to achive a similar aspect, but there are so
220+ * many issues with alloca() that I do not want to take that route.
221+ * rgerhards, 2008-09-02
222+ */
223+ if((size_t) iMaxLine < sizeof(bufRcv) - 1) {
224+ pRcv = bufRcv;
225+ } else {
226+ if((pRcv = (uchar*) MALLOC(sizeof(uchar) * (iMaxLine + 1))) == NULL)
227+ iMaxLine = sizeof(bufRcv) - 1; /* better this than noting */
228+ }
229+
230+ len = 0;
231+ for (;;) {
232+ dbgprintf("imklog(BSD/Linux) waiting for kernel log line\n");
233+ i = read(fklog, pRcv + len, iMaxLine - len);
234+ if (i > 0) {
235+ pRcv[i + len] = '\0';
236+ } else {
237+ if (i < 0 && errno != EINTR && errno != EAGAIN) {
238+ imklogLogIntMsg(LOG_ERR,
239+ "imklog: error reading kernel log - shutting down: %s",
240+ rs_strerror_r(errno, errmsg, sizeof(errmsg)));
241+ fklog = -1;
242+ }
243+ break;
244+ }
245+
246+ for (p = (char*)pRcv; (q = strchr(p, '\n')) != NULL; p = q + 1) {
247+ *q = '\0';
248+ submitSyslog(pModConf, LOG_INFO, (uchar*) p);
249+ }
250+ len = strlen(p);
251+ if (len >= iMaxLine - 1) {
252+ submitSyslog(pModConf, LOG_INFO, (uchar*)p);
253+ len = 0;
254+ }
255+ if(len > 0)
256+ memmove(pRcv, p, len + 1);
257+ }
258+ if (len > 0)
259+ submitSyslog(pModConf, LOG_INFO, pRcv);
260+
261+ if(pRcv != NULL && (size_t) iMaxLine >= sizeof(bufRcv) - 1)
262+ free(pRcv);
263+}
264+
265+
266+/* to be called in the module's AfterRun entry point
267+ * rgerhards, 2008-04-09
268+ */
269+rsRetVal klogAfterRun(modConfData_t *pModConf)
270+{
271+ DEFiRet;
272+ if(fklog != -1)
273+ close(fklog);
274+# ifdef OS_LINUX
275+ /* Turn on logging of messages to console, but only if a log level was speficied */
276+ if(pModConf->console_log_level != -1)
277+ klogctl(7, NULL, 0);
278+# endif
279+ RETiRet;
280+}
281+
282+
283+
284+/* to be called in the module's WillRun entry point, this is the main
285+ * "message pull" mechanism.
286+ * rgerhards, 2008-04-09
287+ */
288+rsRetVal klogLogKMsg(modConfData_t *pModConf)
289+{
290+ DEFiRet;
291+ readklog(pModConf);
292+ RETiRet;
293+}
294+
295+
296+/* provide the (system-specific) default facility for internal messages
297+ * rgerhards, 2008-04-14
298+ */
299+int
300+klogFacilIntMsg(void)
301+{
302+ return LOG_SYSLOG;
303+}
304
305=== added file '.pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog/imklog.c'
306--- .pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog/imklog.c 1970-01-01 00:00:00 +0000
307+++ .pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog/imklog.c 2015-01-09 16:11:08 +0000
308@@ -0,0 +1,488 @@
309+/* The kernel log module.
310+ *
311+ * This is an abstracted module. As Linux and BSD kernel log is conceptually the
312+ * same, we do not do different input plugins for them but use
313+ * imklog in both cases, just with different "backend drivers" for
314+ * the different platforms. This also enables a rsyslog.conf to
315+ * be used on multiple platforms without the need to take care of
316+ * what the kernel log is coming from.
317+ *
318+ * See platform-specific files (e.g. linux.c, bsd.c) in the plugin's
319+ * working directory. For other systems with similar kernel logging
320+ * functionality, no new input plugin shall be written but rather a
321+ * driver be developed for imklog. Please note that imklog itself is
322+ * mostly concerned with handling the interface. Any real action happens
323+ * in the drivers, as things may be pretty different on different
324+ * platforms.
325+ *
326+ * Please note that this file replaces the klogd daemon that was
327+ * also present in pre-v3 versions of rsyslog.
328+ *
329+ * To test under Linux:
330+ * echo test1 > /dev/kmsg
331+ *
332+ * Copyright (C) 2008-2014 Adiscon GmbH
333+ *
334+ * This file is part of rsyslog.
335+ *
336+ * Licensed under the Apache License, Version 2.0 (the "License");
337+ * you may not use this file except in compliance with the License.
338+ * You may obtain a copy of the License at
339+ *
340+ * http://www.apache.org/licenses/LICENSE-2.0
341+ * -or-
342+ * see COPYING.ASL20 in the source distribution
343+ *
344+ * Unless required by applicable law or agreed to in writing, software
345+ * distributed under the License is distributed on an "AS IS" BASIS,
346+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
347+ * See the License for the specific language governing permissions and
348+ * limitations under the License.
349+ */
350+#include "config.h"
351+#include "rsyslog.h"
352+#include <stdio.h>
353+#include <assert.h>
354+#include <string.h>
355+#include <stdarg.h>
356+#include <ctype.h>
357+#include <stdlib.h>
358+#include <sys/socket.h>
359+
360+#include "dirty.h"
361+#include "cfsysline.h"
362+#include "obj.h"
363+#include "msg.h"
364+#include "module-template.h"
365+#include "datetime.h"
366+#include "imklog.h"
367+#include "net.h"
368+#include "glbl.h"
369+#include "prop.h"
370+#include "errmsg.h"
371+#include "unicode-helper.h"
372+
373+MODULE_TYPE_INPUT
374+MODULE_TYPE_NOKEEP
375+MODULE_CNFNAME("imklog")
376+
377+/* Module static data */
378+DEF_IMOD_STATIC_DATA
379+DEFobjCurrIf(datetime)
380+DEFobjCurrIf(glbl)
381+DEFobjCurrIf(prop)
382+DEFobjCurrIf(net)
383+DEFobjCurrIf(errmsg)
384+
385+/* config settings */
386+typedef struct configSettings_s {
387+ int bPermitNonKernel; /* permit logging of messages not having LOG_KERN facility */
388+ int bParseKernelStamp; /* if try to parse kernel timestamps for message time */
389+ int bKeepKernelStamp; /* keep the kernel timestamp in the message */
390+ int iFacilIntMsg; /* the facility to use for internal messages (set by driver) */
391+ uchar *pszPath;
392+ int console_log_level; /* still used for BSD */
393+} configSettings_t;
394+static configSettings_t cs;
395+
396+static modConfData_t *loadModConf = NULL;/* modConf ptr to use for the current load process */
397+static modConfData_t *runModConf = NULL;/* modConf ptr to use for the current load process */
398+static int bLegacyCnfModGlobalsPermitted;/* are legacy module-global config parameters permitted? */
399+
400+/* module-global parameters */
401+static struct cnfparamdescr modpdescr[] = {
402+ { "logpath", eCmdHdlrGetWord, 0 },
403+ { "permitnonkernelfacility", eCmdHdlrBinary, 0 },
404+ { "consoleloglevel", eCmdHdlrInt, 0 },
405+ { "parsekerneltimestamp", eCmdHdlrBinary, 0 },
406+ { "keepkerneltimestamp", eCmdHdlrBinary, 0 },
407+ { "internalmsgfacility", eCmdHdlrFacility, 0 }
408+};
409+static struct cnfparamblk modpblk =
410+ { CNFPARAMBLK_VERSION,
411+ sizeof(modpdescr)/sizeof(struct cnfparamdescr),
412+ modpdescr
413+ };
414+
415+static prop_t *pInputName = NULL; /* there is only one global inputName for all messages generated by this module */
416+static prop_t *pLocalHostIP = NULL;
417+
418+static inline void
419+initConfigSettings(void)
420+{
421+ cs.bPermitNonKernel = 0;
422+ cs.bParseKernelStamp = 0;
423+ cs.bKeepKernelStamp = 0;
424+ cs.console_log_level = -1;
425+ cs.pszPath = NULL;
426+ cs.iFacilIntMsg = klogFacilIntMsg();
427+}
428+
429+
430+/* enqueue the the kernel message into the message queue.
431+ * The provided msg string is not freed - thus must be done
432+ * by the caller.
433+ * rgerhards, 2008-04-12
434+ */
435+static rsRetVal
436+enqMsg(uchar *msg, uchar* pszTag, int iFacility, int iSeverity, struct timeval *tp)
437+{
438+ struct syslogTime st;
439+ msg_t *pMsg;
440+ DEFiRet;
441+
442+ assert(msg != NULL);
443+ assert(pszTag != NULL);
444+
445+ if(tp == NULL) {
446+ CHKiRet(msgConstruct(&pMsg));
447+ } else {
448+ datetime.timeval2syslogTime(tp, &st);
449+ CHKiRet(msgConstructWithTime(&pMsg, &st, tp->tv_sec));
450+ }
451+ MsgSetFlowControlType(pMsg, eFLOWCTL_LIGHT_DELAY);
452+ MsgSetInputName(pMsg, pInputName);
453+ MsgSetRawMsgWOSize(pMsg, (char*)msg);
454+ MsgSetMSGoffs(pMsg, 0); /* we do not have a header... */
455+ MsgSetRcvFrom(pMsg, glbl.GetLocalHostNameProp());
456+ MsgSetRcvFromIP(pMsg, pLocalHostIP);
457+ MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName()));
458+ MsgSetTAG(pMsg, pszTag, ustrlen(pszTag));
459+ pMsg->iFacility = iFacility;
460+ pMsg->iSeverity = iSeverity;
461+ /* note: we do NOT use rate-limiting, as the kernel itself does rate-limiting */
462+ CHKiRet(submitMsg2(pMsg));
463+
464+finalize_it:
465+ RETiRet;
466+}
467+
468+/* parse the PRI from a kernel message. At least BSD seems to have
469+ * non-kernel messages inside the kernel log...
470+ * Expected format: "<pri>". piPri is only valid if the function
471+ * successfully returns. If there was a proper pri ppSz is advanced to the
472+ * position right after ">".
473+ * rgerhards, 2008-04-14
474+ */
475+static rsRetVal
476+parsePRI(uchar **ppSz, int *piPri)
477+{
478+ DEFiRet;
479+ int i;
480+ uchar *pSz;
481+
482+ assert(ppSz != NULL);
483+ pSz = *ppSz;
484+ assert(pSz != NULL);
485+ assert(piPri != NULL);
486+
487+ if(*pSz != '<' || !isdigit(*(pSz+1)))
488+ ABORT_FINALIZE(RS_RET_INVALID_PRI);
489+
490+ ++pSz;
491+ i = 0;
492+ while(isdigit(*pSz)) {
493+ i = i * 10 + *pSz++ - '0';
494+ }
495+
496+ if(*pSz != '>')
497+ ABORT_FINALIZE(RS_RET_INVALID_PRI);
498+
499+ /* OK, we have a valid PRI */
500+ *piPri = i;
501+ *ppSz = pSz + 1; /* update msg ptr to position after PRI */
502+
503+finalize_it:
504+ RETiRet;
505+}
506+
507+
508+/* log an imklog-internal message
509+ * rgerhards, 2008-04-14
510+ */
511+rsRetVal imklogLogIntMsg(int priority, char *fmt, ...)
512+{
513+ DEFiRet;
514+ va_list ap;
515+ uchar msgBuf[2048]; /* we use the same size as sysklogd to remain compatible */
516+
517+ va_start(ap, fmt);
518+ vsnprintf((char*)msgBuf, sizeof(msgBuf) / sizeof(char), fmt, ap);
519+ va_end(ap);
520+
521+ logmsgInternal(NO_ERRCODE ,priority, msgBuf, 0);
522+
523+ RETiRet;
524+}
525+
526+
527+/* log a kernel message. If tp is non-NULL, it contains the message creation
528+ * time to use.
529+ * rgerhards, 2008-04-14
530+ */
531+rsRetVal Syslog(int priority, uchar *pMsg, struct timeval *tp)
532+{
533+ int pri = -1;
534+ rsRetVal localRet;
535+ DEFiRet;
536+
537+ /* then check if we have two PRIs. This can happen in case of systemd,
538+ * in which case the second PRI is the right one.
539+ */
540+ if(pMsg[3] == '<' || (pMsg[3] == ' ' && pMsg[4] == '<')) { /* could be a pri... */
541+ uchar *pMsgTmp = pMsg + ((pMsg[3] == '<') ? 3 : 4);
542+ localRet = parsePRI(&pMsgTmp, &pri);
543+ if(localRet == RS_RET_OK && pri >= 8 && pri <= 192) {
544+ /* *this* is our PRI */
545+ DBGPRINTF("imklog detected secondary PRI(%d) in klog msg\n", pri);
546+ pMsg = pMsgTmp;
547+ priority = pri;
548+ }
549+ }
550+ if(pri == -1) {
551+ localRet = parsePRI(&pMsg, &priority);
552+ if(localRet != RS_RET_INVALID_PRI && localRet != RS_RET_OK)
553+ FINALIZE;
554+ }
555+ /* if we don't get the pri, we use whatever we were supplied */
556+
557+ /* ignore non-kernel messages if not permitted */
558+ if(cs.bPermitNonKernel == 0 && pri2fac(priority) != LOG_KERN)
559+ FINALIZE; /* silently ignore */
560+
561+ iRet = enqMsg((uchar*)pMsg, (uchar*) "kernel:", pri2fac(priority), pri2sev(priority), tp);
562+
563+finalize_it:
564+ RETiRet;
565+}
566+
567+
568+/* helper for some klog drivers which need to know the MaxLine global setting. They can
569+ * not obtain it themselfs, because they are no modules and can not query the object hander.
570+ * It would probably be a good idea to extend the interface to support it, but so far
571+ * we create a (sufficiently valid) work-around. -- rgerhards, 2008-11-24
572+ */
573+int klog_getMaxLine(void)
574+{
575+ return glbl.GetMaxLine();
576+}
577+
578+
579+BEGINrunInput
580+CODESTARTrunInput
581+ /* this is an endless loop - it is terminated when the thread is
582+ * signalled to do so. This, however, is handled by the framework,
583+ * right into the sleep below.
584+ */
585+ while(!pThrd->bShallStop) {
586+ /* klogLogKMsg() waits for the next kernel message, obtains it
587+ * and then submits it to the rsyslog main queue.
588+ * rgerhards, 2008-04-09
589+ */
590+ CHKiRet(klogLogKMsg(runModConf));
591+ }
592+finalize_it:
593+ENDrunInput
594+
595+
596+BEGINbeginCnfLoad
597+CODESTARTbeginCnfLoad
598+ loadModConf = pModConf;
599+ pModConf->pConf = pConf;
600+ /* init our settings */
601+ pModConf->pszPath = NULL;
602+ pModConf->bPermitNonKernel = 0;
603+ pModConf->bParseKernelStamp = 0;
604+ pModConf->bKeepKernelStamp = 0;
605+ pModConf->console_log_level = -1;
606+ pModConf->bKeepKernelStamp = 0;
607+ pModConf->iFacilIntMsg = klogFacilIntMsg();
608+ loadModConf->configSetViaV2Method = 0;
609+ bLegacyCnfModGlobalsPermitted = 1;
610+ /* init legacy config vars */
611+ initConfigSettings();
612+ENDbeginCnfLoad
613+
614+
615+BEGINsetModCnf
616+ struct cnfparamvals *pvals = NULL;
617+ int i;
618+CODESTARTsetModCnf
619+ pvals = nvlstGetParams(lst, &modpblk, NULL);
620+ if(pvals == NULL) {
621+ errmsg.LogError(0, RS_RET_MISSING_CNFPARAMS, "error processing module "
622+ "config parameters [module(...)]");
623+ ABORT_FINALIZE(RS_RET_MISSING_CNFPARAMS);
624+ }
625+
626+ if(Debug) {
627+ dbgprintf("module (global) param blk for imklog:\n");
628+ cnfparamsPrint(&modpblk, pvals);
629+ }
630+
631+ for(i = 0 ; i < modpblk.nParams ; ++i) {
632+ if(!pvals[i].bUsed)
633+ continue;
634+ if(!strcmp(modpblk.descr[i].name, "logpath")) {
635+ loadModConf->pszPath = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
636+ } else if(!strcmp(modpblk.descr[i].name, "permitnonkernelfacility")) {
637+ loadModConf->bPermitNonKernel = (int) pvals[i].val.d.n;
638+ } else if(!strcmp(modpblk.descr[i].name, "parsekerneltimestamp")) {
639+ loadModConf->bParseKernelStamp = (int) pvals[i].val.d.n;
640+ } else if(!strcmp(modpblk.descr[i].name, "keepkerneltimestamp")) {
641+ loadModConf->bKeepKernelStamp = (int) pvals[i].val.d.n;
642+ } else if(!strcmp(modpblk.descr[i].name, "consoleloglevel")) {
643+ loadModConf->console_log_level= (int) pvals[i].val.d.n;
644+ } else if(!strcmp(modpblk.descr[i].name, "internalmsgfacility")) {
645+ loadModConf->iFacilIntMsg = (int) pvals[i].val.d.n;
646+ } else {
647+ dbgprintf("imklog: program error, non-handled "
648+ "param '%s' in beginCnfLoad\n", modpblk.descr[i].name);
649+ }
650+ }
651+
652+ /* disable legacy module-global config directives */
653+ bLegacyCnfModGlobalsPermitted = 0;
654+ loadModConf->configSetViaV2Method = 1;
655+
656+finalize_it:
657+ if(pvals != NULL)
658+ cnfparamvalsDestruct(pvals, &modpblk);
659+ENDsetModCnf
660+
661+
662+BEGINendCnfLoad
663+CODESTARTendCnfLoad
664+ if(!loadModConf->configSetViaV2Method) {
665+ /* persist module-specific settings from legacy config system */
666+ loadModConf->bPermitNonKernel = cs.bPermitNonKernel;
667+ loadModConf->bParseKernelStamp = cs.bParseKernelStamp;
668+ loadModConf->bKeepKernelStamp = cs.bKeepKernelStamp;
669+ loadModConf->iFacilIntMsg = cs.iFacilIntMsg;
670+ loadModConf->console_log_level = cs.console_log_level;
671+ if((cs.pszPath == NULL) || (cs.pszPath[0] == '\0')) {
672+ loadModConf->pszPath = NULL;
673+ if(cs.pszPath != NULL)
674+ free(cs.pszPath);
675+ } else {
676+ loadModConf->pszPath = cs.pszPath;
677+ }
678+ cs.pszPath = NULL;
679+ }
680+
681+ loadModConf = NULL; /* done loading */
682+ENDendCnfLoad
683+
684+
685+BEGINcheckCnf
686+CODESTARTcheckCnf
687+ENDcheckCnf
688+
689+
690+BEGINactivateCnfPrePrivDrop
691+CODESTARTactivateCnfPrePrivDrop
692+ runModConf = pModConf;
693+ iRet = klogWillRun(runModConf);
694+ENDactivateCnfPrePrivDrop
695+
696+
697+BEGINactivateCnf
698+CODESTARTactivateCnf
699+ENDactivateCnf
700+
701+
702+BEGINfreeCnf
703+CODESTARTfreeCnf
704+ENDfreeCnf
705+
706+
707+BEGINwillRun
708+CODESTARTwillRun
709+ENDwillRun
710+
711+
712+BEGINafterRun
713+CODESTARTafterRun
714+ iRet = klogAfterRun(runModConf);
715+ENDafterRun
716+
717+
718+BEGINmodExit
719+CODESTARTmodExit
720+ if(pInputName != NULL)
721+ prop.Destruct(&pInputName);
722+ if(pLocalHostIP != NULL)
723+ prop.Destruct(&pLocalHostIP);
724+
725+ /* release objects we used */
726+ objRelease(glbl, CORE_COMPONENT);
727+ objRelease(net, CORE_COMPONENT);
728+ objRelease(datetime, CORE_COMPONENT);
729+ objRelease(prop, CORE_COMPONENT);
730+ objRelease(errmsg, CORE_COMPONENT);
731+ENDmodExit
732+
733+
734+BEGINqueryEtryPt
735+CODESTARTqueryEtryPt
736+CODEqueryEtryPt_STD_IMOD_QUERIES
737+CODEqueryEtryPt_STD_CONF2_QUERIES
738+CODEqueryEtryPt_STD_CONF2_setModCnf_QUERIES
739+CODEqueryEtryPt_STD_CONF2_PREPRIVDROP_QUERIES
740+ENDqueryEtryPt
741+
742+static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal)
743+{
744+ cs.bPermitNonKernel = 0;
745+ cs.bParseKernelStamp = 0;
746+ cs.bKeepKernelStamp = 0;
747+ if(cs.pszPath != NULL) {
748+ free(cs.pszPath);
749+ cs.pszPath = NULL;
750+ }
751+ cs.iFacilIntMsg = klogFacilIntMsg();
752+ return RS_RET_OK;
753+}
754+
755+BEGINmodInit()
756+CODESTARTmodInit
757+ *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
758+CODEmodInit_QueryRegCFSLineHdlr
759+ CHKiRet(objUse(datetime, CORE_COMPONENT));
760+ CHKiRet(objUse(glbl, CORE_COMPONENT));
761+ CHKiRet(objUse(prop, CORE_COMPONENT));
762+ CHKiRet(objUse(net, CORE_COMPONENT));
763+ CHKiRet(objUse(errmsg, CORE_COMPONENT));
764+
765+ /* we need to create the inputName property (only once during our lifetime) */
766+ CHKiRet(prop.CreateStringProp(&pInputName, UCHAR_CONSTANT("imklog"), sizeof("imklog") - 1));
767+ CHKiRet(prop.CreateStringProp(&pLocalHostIP, UCHAR_CONSTANT("127.0.0.1"), sizeof("127.0.0.1") - 1));
768+
769+ /* init legacy config settings */
770+ initConfigSettings();
771+
772+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"debugprintkernelsymbols", 0, eCmdHdlrGoneAway,
773+ NULL, NULL, STD_LOADABLE_MODULE_ID));
774+ CHKiRet(regCfSysLineHdlr2((uchar *)"klogpath", 0, eCmdHdlrGetWord,
775+ NULL, &cs.pszPath, STD_LOADABLE_MODULE_ID, &bLegacyCnfModGlobalsPermitted));
776+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"klogsymbollookup", 0, eCmdHdlrGoneAway,
777+ NULL, NULL, STD_LOADABLE_MODULE_ID));
778+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"klogsymbolstwice", 0, eCmdHdlrGoneAway,
779+ NULL, NULL, STD_LOADABLE_MODULE_ID));
780+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"klogusesyscallinterface", 0, eCmdHdlrGoneAway,
781+ NULL, NULL, STD_LOADABLE_MODULE_ID));
782+ CHKiRet(regCfSysLineHdlr2((uchar *)"klogpermitnonkernelfacility", 0, eCmdHdlrBinary,
783+ NULL, &cs.bPermitNonKernel, STD_LOADABLE_MODULE_ID, &bLegacyCnfModGlobalsPermitted));
784+ CHKiRet(regCfSysLineHdlr2((uchar *)"klogconsoleloglevel", 0, eCmdHdlrInt,
785+ NULL, &cs.console_log_level, STD_LOADABLE_MODULE_ID, &bLegacyCnfModGlobalsPermitted));
786+ CHKiRet(regCfSysLineHdlr2((uchar *)"kloginternalmsgfacility", 0, eCmdHdlrFacility,
787+ NULL, &cs.iFacilIntMsg, STD_LOADABLE_MODULE_ID, &bLegacyCnfModGlobalsPermitted));
788+ CHKiRet(regCfSysLineHdlr2((uchar *)"klogparsekerneltimestamp", 0, eCmdHdlrBinary,
789+ NULL, &cs.bParseKernelStamp, STD_LOADABLE_MODULE_ID, &bLegacyCnfModGlobalsPermitted));
790+ CHKiRet(regCfSysLineHdlr2((uchar *)"klogkeepkerneltimestamp", 0, eCmdHdlrBinary,
791+ NULL, &cs.bKeepKernelStamp, STD_LOADABLE_MODULE_ID, &bLegacyCnfModGlobalsPermitted));
792+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler,
793+ resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
794+ENDmodInit
795+/* vim:set ai:
796+ */
797
798=== added file '.pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog/imklog.h'
799--- .pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog/imklog.h 1970-01-01 00:00:00 +0000
800+++ .pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imklog/imklog.h 2015-01-09 16:11:08 +0000
801@@ -0,0 +1,70 @@
802+/* imklog.h
803+ * These are the definitions for the klog message generation module.
804+ *
805+ * File begun on 2007-12-17 by RGerhards
806+ * Major change: 2008-04-09: switched to a driver interface for
807+ * several platforms
808+ *
809+ * Copyright 2007-2012 Rainer Gerhards and Adiscon GmbH.
810+ *
811+ * This file is part of rsyslog.
812+ *
813+ * Licensed under the Apache License, Version 2.0 (the "License");
814+ * you may not use this file except in compliance with the License.
815+ * You may obtain a copy of the License at
816+ *
817+ * http://www.apache.org/licenses/LICENSE-2.0
818+ * -or-
819+ * see COPYING.ASL20 in the source distribution
820+ *
821+ * Unless required by applicable law or agreed to in writing, software
822+ * distributed under the License is distributed on an "AS IS" BASIS,
823+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
824+ * See the License for the specific language governing permissions and
825+ * limitations under the License.
826+ */
827+#ifndef IMKLOG_H_INCLUDED
828+#define IMKLOG_H_INCLUDED 1
829+
830+#include "rsyslog.h"
831+#include "dirty.h"
832+
833+/* we need to have the modConf type present in all submodules */
834+struct modConfData_s {
835+ rsconf_t *pConf;
836+ int iFacilIntMsg;
837+ uchar *pszPath;
838+ int console_log_level;
839+ sbool bParseKernelStamp;
840+ sbool bKeepKernelStamp;
841+ sbool bPermitNonKernel;
842+ sbool configSetViaV2Method;
843+};
844+
845+/* interface to "drivers"
846+ * the platform specific drivers must implement these entry points. Only one
847+ * driver may be active at any given time, thus we simply rely on the linker
848+ * to resolve the addresses.
849+ * rgerhards, 2008-04-09
850+ */
851+rsRetVal klogLogKMsg(modConfData_t *pModConf);
852+rsRetVal klogWillRun(modConfData_t *pModConf);
853+rsRetVal klogAfterRun(modConfData_t *pModConf);
854+int klogFacilIntMsg();
855+
856+/* the functions below may be called by the drivers */
857+rsRetVal imklogLogIntMsg(int priority, char *fmt, ...) __attribute__((format(printf,2, 3)));
858+rsRetVal Syslog(int priority, uchar *msg, struct timeval *tp);
859+
860+/* prototypes */
861+extern int klog_getMaxLine(void); /* work-around for klog drivers to get configured max line size */
862+extern int InitKsyms(modConfData_t*);
863+extern void DeinitKsyms(void);
864+extern int InitMsyms(void);
865+extern void DeinitMsyms(void);
866+extern char * ExpandKadds(char *, char *);
867+extern void SetParanoiaLevel(int);
868+
869+#endif /* #ifndef IMKLOG_H_INCLUDED */
870+/* vi:set ai:
871+ */
872
873=== added file '.pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imkmsg/imkmsg.c'
874--- .pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imkmsg/imkmsg.c 1970-01-01 00:00:00 +0000
875+++ .pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imkmsg/imkmsg.c 2015-01-09 16:11:08 +0000
876@@ -0,0 +1,295 @@
877+/* The kernel log module.
878+ *
879+ * This is rsyslog Linux only module for reading structured kernel logs.
880+ * Module is based on imklog module so it retains its structure
881+ * and other part is currently in kmsg.c file instead of this (imkmsg.c)
882+ * For more information see that file.
883+ *
884+ * To test under Linux:
885+ * echo test1 > /dev/kmsg
886+ *
887+ * Copyright (C) 2008-2012 Adiscon GmbH
888+ *
889+ * This file is part of rsyslog.
890+ *
891+ * Licensed under the Apache License, Version 2.0 (the "License");
892+ * you may not use this file except in compliance with the License.
893+ * You may obtain a copy of the License at
894+ *
895+ * http://www.apache.org/licenses/LICENSE-2.0
896+ * -or-
897+ * see COPYING.ASL20 in the source distribution
898+ *
899+ * Unless required by applicable law or agreed to in writing, software
900+ * distributed under the License is distributed on an "AS IS" BASIS,
901+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
902+ * See the License for the specific language governing permissions and
903+ * limitations under the License.
904+ */
905+#include "config.h"
906+#include "rsyslog.h"
907+#include <stdio.h>
908+#include <assert.h>
909+#include <string.h>
910+#include <stdarg.h>
911+#include <ctype.h>
912+#include <stdlib.h>
913+#include <sys/socket.h>
914+
915+#include "dirty.h"
916+#include "cfsysline.h"
917+#include "obj.h"
918+#include "msg.h"
919+#include "module-template.h"
920+#include "datetime.h"
921+#include "imkmsg.h"
922+#include "net.h"
923+#include "glbl.h"
924+#include "prop.h"
925+#include "errmsg.h"
926+#include "unicode-helper.h"
927+
928+MODULE_TYPE_INPUT
929+MODULE_TYPE_NOKEEP
930+MODULE_CNFNAME("imkmsg")
931+
932+/* Module static data */
933+DEF_IMOD_STATIC_DATA
934+DEFobjCurrIf(datetime)
935+DEFobjCurrIf(glbl)
936+DEFobjCurrIf(prop)
937+DEFobjCurrIf(net)
938+DEFobjCurrIf(errmsg)
939+
940+/* config settings */
941+typedef struct configSettings_s {
942+ int iFacilIntMsg; /* the facility to use for internal messages (set by driver) */
943+} configSettings_t;
944+static configSettings_t cs;
945+
946+static modConfData_t *loadModConf = NULL;/* modConf ptr to use for the current load process */
947+static modConfData_t *runModConf = NULL;/* modConf ptr to use for the current load process */
948+static int bLegacyCnfModGlobalsPermitted;/* are legacy module-global config parameters permitted? */
949+
950+static prop_t *pInputName = NULL; /* there is only one global inputName for all messages generated by this module */
951+static prop_t *pLocalHostIP = NULL; /* a pseudo-constant propterty for 127.0.0.1 */
952+
953+static inline void
954+initConfigSettings(void)
955+{
956+ cs.iFacilIntMsg = klogFacilIntMsg();
957+}
958+
959+
960+/* enqueue the the kernel message into the message queue.
961+ * The provided msg string is not freed - thus must be done
962+ * by the caller.
963+ * rgerhards, 2008-04-12
964+ */
965+static rsRetVal
966+enqMsg(uchar *msg, uchar* pszTag, int iFacility, int iSeverity, struct timeval *tp, struct json_object *json)
967+{
968+ struct syslogTime st;
969+ msg_t *pMsg;
970+ DEFiRet;
971+
972+ assert(msg != NULL);
973+ assert(pszTag != NULL);
974+
975+ if(tp == NULL) {
976+ CHKiRet(msgConstruct(&pMsg));
977+ } else {
978+ datetime.timeval2syslogTime(tp, &st);
979+ CHKiRet(msgConstructWithTime(&pMsg, &st, tp->tv_sec));
980+ }
981+ MsgSetFlowControlType(pMsg, eFLOWCTL_LIGHT_DELAY);
982+ MsgSetInputName(pMsg, pInputName);
983+ MsgSetRawMsgWOSize(pMsg, (char*)msg);
984+ MsgSetMSGoffs(pMsg, 0); /* we do not have a header... */
985+ MsgSetRcvFrom(pMsg, glbl.GetLocalHostNameProp());
986+ MsgSetRcvFromIP(pMsg, pLocalHostIP);
987+ MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName()));
988+ MsgSetTAG(pMsg, pszTag, ustrlen(pszTag));
989+ pMsg->iFacility = iFacility;
990+ pMsg->iSeverity = iSeverity;
991+ pMsg->json = json;
992+ CHKiRet(submitMsg(pMsg));
993+
994+finalize_it:
995+ RETiRet;
996+}
997+
998+
999+/* log an imkmsg-internal message
1000+ * rgerhards, 2008-04-14
1001+ */
1002+rsRetVal imkmsgLogIntMsg(int priority, char *fmt, ...)
1003+{
1004+ DEFiRet;
1005+ va_list ap;
1006+ uchar msgBuf[2048]; /* we use the same size as sysklogd to remain compatible */
1007+
1008+ va_start(ap, fmt);
1009+ vsnprintf((char*)msgBuf, sizeof(msgBuf) / sizeof(char), fmt, ap);
1010+ va_end(ap);
1011+
1012+ logmsgInternal(NO_ERRCODE ,priority, msgBuf, 0);
1013+
1014+ RETiRet;
1015+}
1016+
1017+
1018+/* log a message from /dev/kmsg
1019+ */
1020+rsRetVal Syslog(int priority, uchar *pMsg, struct timeval *tp, struct json_object *json)
1021+{
1022+ DEFiRet;
1023+ iRet = enqMsg((uchar*)pMsg, (uchar*) "kernel:", pri2fac(priority), pri2sev(priority), tp, json);
1024+ RETiRet;
1025+}
1026+
1027+
1028+/* helper for some klog drivers which need to know the MaxLine global setting. They can
1029+ * not obtain it themselfs, because they are no modules and can not query the object hander.
1030+ * It would probably be a good idea to extend the interface to support it, but so far
1031+ * we create a (sufficiently valid) work-around. -- rgerhards, 2008-11-24
1032+ */
1033+int klog_getMaxLine(void)
1034+{
1035+ return glbl.GetMaxLine();
1036+}
1037+
1038+
1039+BEGINrunInput
1040+CODESTARTrunInput
1041+ /* this is an endless loop - it is terminated when the thread is
1042+ * signalled to do so. This, however, is handled by the framework,
1043+ * right into the sleep below.
1044+ */
1045+ while(!pThrd->bShallStop) {
1046+ /* klogLogKMsg() waits for the next kernel message, obtains it
1047+ * and then submits it to the rsyslog main queue.
1048+ * rgerhards, 2008-04-09
1049+ */
1050+ CHKiRet(klogLogKMsg(runModConf));
1051+ }
1052+finalize_it:
1053+ENDrunInput
1054+
1055+
1056+BEGINbeginCnfLoad
1057+CODESTARTbeginCnfLoad
1058+ loadModConf = pModConf;
1059+ pModConf->pConf = pConf;
1060+ /* init our settings */
1061+ pModConf->iFacilIntMsg = klogFacilIntMsg();
1062+ loadModConf->configSetViaV2Method = 0;
1063+ bLegacyCnfModGlobalsPermitted = 1;
1064+ /* init legacy config vars */
1065+ initConfigSettings();
1066+ENDbeginCnfLoad
1067+
1068+
1069+BEGINendCnfLoad
1070+CODESTARTendCnfLoad
1071+ if(!loadModConf->configSetViaV2Method) {
1072+ /* persist module-specific settings from legacy config system */
1073+ loadModConf->iFacilIntMsg = cs.iFacilIntMsg;
1074+ }
1075+
1076+ loadModConf = NULL; /* done loading */
1077+ENDendCnfLoad
1078+
1079+
1080+BEGINcheckCnf
1081+CODESTARTcheckCnf
1082+ENDcheckCnf
1083+
1084+
1085+BEGINactivateCnfPrePrivDrop
1086+CODESTARTactivateCnfPrePrivDrop
1087+ runModConf = pModConf;
1088+ iRet = klogWillRun(runModConf);
1089+ENDactivateCnfPrePrivDrop
1090+
1091+
1092+BEGINactivateCnf
1093+CODESTARTactivateCnf
1094+ENDactivateCnf
1095+
1096+
1097+BEGINfreeCnf
1098+CODESTARTfreeCnf
1099+ENDfreeCnf
1100+
1101+
1102+BEGINwillRun
1103+CODESTARTwillRun
1104+ENDwillRun
1105+
1106+
1107+BEGINafterRun
1108+CODESTARTafterRun
1109+ iRet = klogAfterRun(runModConf);
1110+ENDafterRun
1111+
1112+
1113+BEGINmodExit
1114+CODESTARTmodExit
1115+ if(pInputName != NULL)
1116+ prop.Destruct(&pInputName);
1117+ if(pLocalHostIP != NULL)
1118+ prop.Destruct(&pLocalHostIP);
1119+
1120+ /* release objects we used */
1121+ objRelease(glbl, CORE_COMPONENT);
1122+ objRelease(net, CORE_COMPONENT);
1123+ objRelease(datetime, CORE_COMPONENT);
1124+ objRelease(prop, CORE_COMPONENT);
1125+ objRelease(errmsg, CORE_COMPONENT);
1126+ENDmodExit
1127+
1128+
1129+BEGINqueryEtryPt
1130+CODESTARTqueryEtryPt
1131+CODEqueryEtryPt_STD_IMOD_QUERIES
1132+CODEqueryEtryPt_STD_CONF2_QUERIES
1133+CODEqueryEtryPt_STD_CONF2_PREPRIVDROP_QUERIES
1134+ENDqueryEtryPt
1135+
1136+static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal)
1137+{
1138+ cs.iFacilIntMsg = klogFacilIntMsg();
1139+ return RS_RET_OK;
1140+}
1141+
1142+BEGINmodInit()
1143+CODESTARTmodInit
1144+ *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
1145+CODEmodInit_QueryRegCFSLineHdlr
1146+ CHKiRet(objUse(datetime, CORE_COMPONENT));
1147+ CHKiRet(objUse(glbl, CORE_COMPONENT));
1148+ CHKiRet(objUse(prop, CORE_COMPONENT));
1149+ CHKiRet(objUse(net, CORE_COMPONENT));
1150+ CHKiRet(objUse(errmsg, CORE_COMPONENT));
1151+
1152+ /* we need to create the inputName property (only once during our lifetime) */
1153+ CHKiRet(prop.CreateStringProp(&pInputName, UCHAR_CONSTANT("imkmsg"), sizeof("imkmsg") - 1));
1154+ CHKiRet(prop.CreateStringProp(&pLocalHostIP, UCHAR_CONSTANT("127.0.0.1"), sizeof("127.0.0.1") - 1));
1155+
1156+ /* init legacy config settings */
1157+ initConfigSettings();
1158+
1159+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"debugprintkernelsymbols", 0, eCmdHdlrGoneAway,
1160+ NULL, NULL, STD_LOADABLE_MODULE_ID));
1161+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"klogsymbollookup", 0, eCmdHdlrGoneAway,
1162+ NULL, NULL, STD_LOADABLE_MODULE_ID));
1163+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"klogsymbolstwice", 0, eCmdHdlrGoneAway,
1164+ NULL, NULL, STD_LOADABLE_MODULE_ID));
1165+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"klogusesyscallinterface", 0, eCmdHdlrGoneAway,
1166+ NULL, NULL, STD_LOADABLE_MODULE_ID));
1167+ CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler,
1168+ resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
1169+ENDmodInit
1170+/* vim:set ai:
1171+ */
1172
1173=== added file '.pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imkmsg/imkmsg.h'
1174--- .pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imkmsg/imkmsg.h 1970-01-01 00:00:00 +0000
1175+++ .pc/11-fix-infinite-loop-openvz-vms.patch/plugins/imkmsg/imkmsg.h 2015-01-09 16:11:08 +0000
1176@@ -0,0 +1,64 @@
1177+/* imkmsg.h
1178+ * These are the definitions for the kmsg message generation module.
1179+ *
1180+ * Copyright 2007-2012 Rainer Gerhards and Adiscon GmbH.
1181+ *
1182+ * This file is part of rsyslog.
1183+ *
1184+ * Licensed under the Apache License, Version 2.0 (the "License");
1185+ * you may not use this file except in compliance with the License.
1186+ * You may obtain a copy of the License at
1187+ *
1188+ * http://www.apache.org/licenses/LICENSE-2.0
1189+ * -or-
1190+ * see COPYING.ASL20 in the source distribution
1191+ *
1192+ * Unless required by applicable law or agreed to in writing, software
1193+ * distributed under the License is distributed on an "AS IS" BASIS,
1194+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1195+ * See the License for the specific language governing permissions and
1196+ * limitations under the License.
1197+ */
1198+#ifndef IMKLOG_H_INCLUDED
1199+#define IMKLOG_H_INCLUDED 1
1200+
1201+#include "rsyslog.h"
1202+#include "dirty.h"
1203+
1204+/* we need to have the modConf type present in all submodules */
1205+struct modConfData_s {
1206+ rsconf_t *pConf;
1207+ int iFacilIntMsg;
1208+ uchar *pszPath;
1209+ int console_log_level;
1210+ sbool bPermitNonKernel;
1211+ sbool configSetViaV2Method;
1212+};
1213+
1214+/* interface to "drivers"
1215+ * the platform specific drivers must implement these entry points. Only one
1216+ * driver may be active at any given time, thus we simply rely on the linker
1217+ * to resolve the addresses.
1218+ * rgerhards, 2008-04-09
1219+ */
1220+rsRetVal klogLogKMsg(modConfData_t *pModConf);
1221+rsRetVal klogWillRun(modConfData_t *pModConf);
1222+rsRetVal klogAfterRun(modConfData_t *pModConf);
1223+int klogFacilIntMsg();
1224+
1225+/* the functions below may be called by the drivers */
1226+rsRetVal imkmsgLogIntMsg(int priority, char *fmt, ...) __attribute__((format(printf,2, 3)));
1227+rsRetVal Syslog(int priority, uchar *msg, struct timeval *tp, struct json_object *json);
1228+
1229+/* prototypes */
1230+extern int klog_getMaxLine(void); /* work-around for klog drivers to get configured max line size */
1231+extern int InitKsyms(modConfData_t*);
1232+extern void DeinitKsyms(void);
1233+extern int InitMsyms(void);
1234+extern void DeinitMsyms(void);
1235+extern char * ExpandKadds(char *, char *);
1236+extern void SetParanoiaLevel(int);
1237+
1238+#endif /* #ifndef IMKLOG_H_INCLUDED */
1239+/* vi:set ai:
1240+ */
1241
1242=== modified file 'debian/changelog'
1243--- debian/changelog 2015-01-05 10:52:48 +0000
1244+++ debian/changelog 2015-01-09 16:11:08 +0000
1245@@ -1,3 +1,10 @@
1246+rsyslog (7.4.4-1ubuntu2.5) trusty-proposed; urgency=medium
1247+
1248+ * Applied updated upstream patch fixing infinite loop on OpenVZ VMs.
1249+ (LP: #1366829)
1250+
1251+ -- Paul Donohue <ubuntu-rsyslog@PaulSD.com> Fri, 09 Jan 2015 10:50:36 -0500
1252+
1253 rsyslog (7.4.4-1ubuntu2.4) trusty-proposed; urgency=medium
1254
1255 * Applied upstream patch fixing infinite loop on OpenVZ VMs. Thanks to Paul
1256
1257=== modified file 'debian/patches/11-fix-infinite-loop-openvz-vms.patch'
1258--- debian/patches/11-fix-infinite-loop-openvz-vms.patch 2015-01-05 10:52:48 +0000
1259+++ debian/patches/11-fix-infinite-loop-openvz-vms.patch 2015-01-09 16:11:08 +0000
1260@@ -3,27 +3,46 @@
1261 Author: Paul Donohue <git@PaulSD.com>
1262 Applied-Upstream: commit 86904f96805d70fad6b4b1b90e06dcb8f789605c
1263
1264-Index: rsyslog-7.4.4/plugins/imkmsg/kmsg.c
1265+Index: rsyslog.trusty/plugins/imkmsg/kmsg.c
1266 ===================================================================
1267---- rsyslog-7.4.4.orig/plugins/imkmsg/kmsg.c
1268-+++ rsyslog-7.4.4/plugins/imkmsg/kmsg.c
1269-@@ -157,6 +157,7 @@ submitSyslog(uchar *buf)
1270+--- rsyslog.trusty.orig/plugins/imkmsg/kmsg.c
1271++++ rsyslog.trusty/plugins/imkmsg/kmsg.c
1272+@@ -155,18 +155,41 @@ submitSyslog(uchar *buf)
1273+ /* open the kernel log - will be called inside the willRun() imkmsg entry point
1274+ */
1275 rsRetVal
1276- klogWillRun(modConfData_t *pModConf)
1277+-klogWillRun(modConfData_t *pModConf)
1278++klogWillRunPrePrivDrop(modConfData_t *pModConf)
1279 {
1280-+ int i;
1281 char errmsg[2048];
1282 DEFiRet;
1283
1284-@@ -167,6 +168,16 @@ klogWillRun(modConfData_t *pModConf)
1285+ fklog = open(_PATH_KLOG, O_RDONLY, 0);
1286+ if (fklog < 0) {
1287+- imkmsgLogIntMsg(RS_RET_ERR_OPEN_KLOG, "imkmsg: cannot open kernel log(%s): %s.",
1288++ imkmsgLogIntMsg(LOG_ERR, "imkmsg: cannot open kernel log (%s): %s.",
1289+ _PATH_KLOG, rs_strerror_r(errno, errmsg, sizeof(errmsg)));
1290 ABORT_FINALIZE(RS_RET_ERR_OPEN_KLOG);
1291 }
1292
1293-+ /* make sure the kernel log is readable */
1294-+ /* this normally returns EINVAL - on an OpenVZ VM, we get EBADF */
1295-+ i = read(fklog, NULL, 0);
1296-+ if (i < 0 && errno == EBADF) {
1297-+ imkmsgLogIntMsg(RS_RET_ERR_OPEN_KLOG, "imkmsg: cannot read kernel log(%s): %s.",
1298++finalize_it:
1299++ RETiRet;
1300++}
1301++
1302++/* make sure the kernel log is readable after dropping privileges
1303++ */
1304++rsRetVal
1305++klogWillRunPostPrivDrop(modConfData_t *pModConf)
1306++{
1307++ char errmsg[2048];
1308++ int r;
1309++ DEFiRet;
1310++
1311++ /* this normally returns EINVAL */
1312++ /* on an OpenVZ VM, we get EPERM */
1313++ r = read(fklog, NULL, 0);
1314++ if (r < 0 && errno != EINVAL) {
1315++ imkmsgLogIntMsg(LOG_ERR, "imkmsg: cannot open kernel log (%s): %s.",
1316 + _PATH_KLOG, rs_strerror_r(errno, errmsg, sizeof(errmsg)));
1317 + fklog = -1;
1318 + ABORT_FINALIZE(RS_RET_ERR_OPEN_KLOG);
1319@@ -32,10 +51,10 @@
1320 finalize_it:
1321 RETiRet;
1322 }
1323-Index: rsyslog-7.4.4/runtime/rsyslog.h
1324+Index: rsyslog.trusty/runtime/rsyslog.h
1325 ===================================================================
1326---- rsyslog-7.4.4.orig/runtime/rsyslog.h
1327-+++ rsyslog-7.4.4/runtime/rsyslog.h
1328+--- rsyslog.trusty.orig/runtime/rsyslog.h
1329++++ rsyslog.trusty/runtime/rsyslog.h
1330 @@ -358,7 +358,7 @@ enum rsRetVal_ /** return value. All
1331 RS_RET_VAR_NOT_FOUND = -2142, /**< variable not found */
1332 RS_RET_EMPTY_MSG = -2143, /**< provided (raw) MSG is empty */
1333@@ -45,3 +64,126 @@
1334 RS_RET_ERR_AQ_CONLOG = -2146, /**< error aquiring console log (on solaris) */
1335 RS_RET_ERR_DOOR = -2147, /**< some problems with handling the Solaris door functionality */
1336 RS_RET_NO_SRCNAME_TPL = -2150, /**< sourcename template was not specified where one was needed (omudpspoof spoof addr) */
1337+Index: rsyslog.trusty/plugins/imklog/bsd.c
1338+===================================================================
1339+--- rsyslog.trusty.orig/plugins/imklog/bsd.c
1340++++ rsyslog.trusty/plugins/imklog/bsd.c
1341+@@ -164,7 +164,7 @@ static uchar *GetPath(modConfData_t *pMo
1342+ * entry point. -- rgerhards, 2008-04-09
1343+ */
1344+ rsRetVal
1345+-klogWillRun(modConfData_t *pModConf)
1346++klogWillRunPrePrivDrop(modConfData_t *pModConf)
1347+ {
1348+ char errmsg[2048];
1349+ int r;
1350+@@ -172,7 +172,7 @@ klogWillRun(modConfData_t *pModConf)
1351+
1352+ fklog = open((char*)GetPath(pModConf), O_RDONLY, 0);
1353+ if (fklog < 0) {
1354+- imklogLogIntMsg(LOG_ERR, "imklog: cannot open kernel log(%s): %s.",
1355++ imklogLogIntMsg(LOG_ERR, "imklog: cannot open kernel log (%s): %s.",
1356+ GetPath(pModConf), rs_strerror_r(errno, errmsg, sizeof(errmsg)));
1357+ ABORT_FINALIZE(RS_RET_ERR_OPEN_KLOG);
1358+ }
1359+@@ -192,6 +192,29 @@ klogWillRun(modConfData_t *pModConf)
1360+
1361+ finalize_it:
1362+ RETiRet;
1363++}
1364++
1365++/* make sure the kernel log is readable after dropping privileges
1366++ */
1367++rsRetVal
1368++klogWillRunPostPrivDrop(modConfData_t *pModConf)
1369++{
1370++ char errmsg[2048];
1371++ int r;
1372++ DEFiRet;
1373++
1374++ /* this normally returns EINVAL */
1375++ /* on an OpenVZ VM, we get EPERM */
1376++ r = read(fklog, NULL, 0);
1377++ if (r < 0 && errno != EINVAL) {
1378++ imklogLogIntMsg(LOG_ERR, "imklog: cannot open kernel log (%s): %s.",
1379++ GetPath(pModConf), rs_strerror_r(errno, errmsg, sizeof(errmsg)));
1380++ fklog = -1;
1381++ ABORT_FINALIZE(RS_RET_ERR_OPEN_KLOG);
1382++ }
1383++
1384++finalize_it:
1385++ RETiRet;
1386+ }
1387+
1388+
1389+Index: rsyslog.trusty/plugins/imklog/imklog.c
1390+===================================================================
1391+--- rsyslog.trusty.orig/plugins/imklog/imklog.c
1392++++ rsyslog.trusty/plugins/imklog/imklog.c
1393+@@ -382,7 +382,7 @@ ENDcheckCnf
1394+ BEGINactivateCnfPrePrivDrop
1395+ CODESTARTactivateCnfPrePrivDrop
1396+ runModConf = pModConf;
1397+- iRet = klogWillRun(runModConf);
1398++ iRet = klogWillRunPrePrivDrop(runModConf);
1399+ ENDactivateCnfPrePrivDrop
1400+
1401+
1402+@@ -398,6 +398,7 @@ ENDfreeCnf
1403+
1404+ BEGINwillRun
1405+ CODESTARTwillRun
1406++ iRet = klogWillRunPostPrivDrop(runModConf);
1407+ ENDwillRun
1408+
1409+
1410+Index: rsyslog.trusty/plugins/imklog/imklog.h
1411+===================================================================
1412+--- rsyslog.trusty.orig/plugins/imklog/imklog.h
1413++++ rsyslog.trusty/plugins/imklog/imklog.h
1414+@@ -48,8 +48,9 @@ struct modConfData_s {
1415+ * rgerhards, 2008-04-09
1416+ */
1417+ rsRetVal klogLogKMsg(modConfData_t *pModConf);
1418+-rsRetVal klogWillRun(modConfData_t *pModConf);
1419+ rsRetVal klogAfterRun(modConfData_t *pModConf);
1420++rsRetVal klogWillRunPrePrivDrop(modConfData_t *pModConf);
1421++rsRetVal klogWillRunPostPrivDrop(modConfData_t *pModConf);
1422+ int klogFacilIntMsg();
1423+
1424+ /* the functions below may be called by the drivers */
1425+Index: rsyslog.trusty/plugins/imkmsg/imkmsg.c
1426+===================================================================
1427+--- rsyslog.trusty.orig/plugins/imkmsg/imkmsg.c
1428++++ rsyslog.trusty/plugins/imkmsg/imkmsg.c
1429+@@ -209,7 +209,7 @@ ENDcheckCnf
1430+ BEGINactivateCnfPrePrivDrop
1431+ CODESTARTactivateCnfPrePrivDrop
1432+ runModConf = pModConf;
1433+- iRet = klogWillRun(runModConf);
1434++ iRet = klogWillRunPrePrivDrop(runModConf);
1435+ ENDactivateCnfPrePrivDrop
1436+
1437+
1438+@@ -225,6 +225,7 @@ ENDfreeCnf
1439+
1440+ BEGINwillRun
1441+ CODESTARTwillRun
1442++ iRet = klogWillRunPostPrivDrop(runModConf);
1443+ ENDwillRun
1444+
1445+
1446+Index: rsyslog.trusty/plugins/imkmsg/imkmsg.h
1447+===================================================================
1448+--- rsyslog.trusty.orig/plugins/imkmsg/imkmsg.h
1449++++ rsyslog.trusty/plugins/imkmsg/imkmsg.h
1450+@@ -42,7 +42,8 @@ struct modConfData_s {
1451+ * rgerhards, 2008-04-09
1452+ */
1453+ rsRetVal klogLogKMsg(modConfData_t *pModConf);
1454+-rsRetVal klogWillRun(modConfData_t *pModConf);
1455++rsRetVal klogWillRunPrePrivDrop(modConfData_t *pModConf);
1456++rsRetVal klogWillRunPostPrivDrop(modConfData_t *pModConf);
1457+ rsRetVal klogAfterRun(modConfData_t *pModConf);
1458+ int klogFacilIntMsg();
1459+
1460
1461=== modified file 'plugins/imklog/bsd.c'
1462--- plugins/imklog/bsd.c 2013-03-18 16:21:35 +0000
1463+++ plugins/imklog/bsd.c 2015-01-09 16:11:08 +0000
1464@@ -164,7 +164,7 @@
1465 * entry point. -- rgerhards, 2008-04-09
1466 */
1467 rsRetVal
1468-klogWillRun(modConfData_t *pModConf)
1469+klogWillRunPrePrivDrop(modConfData_t *pModConf)
1470 {
1471 char errmsg[2048];
1472 int r;
1473@@ -172,7 +172,7 @@
1474
1475 fklog = open((char*)GetPath(pModConf), O_RDONLY, 0);
1476 if (fklog < 0) {
1477- imklogLogIntMsg(LOG_ERR, "imklog: cannot open kernel log(%s): %s.",
1478+ imklogLogIntMsg(LOG_ERR, "imklog: cannot open kernel log (%s): %s.",
1479 GetPath(pModConf), rs_strerror_r(errno, errmsg, sizeof(errmsg)));
1480 ABORT_FINALIZE(RS_RET_ERR_OPEN_KLOG);
1481 }
1482@@ -194,6 +194,29 @@
1483 RETiRet;
1484 }
1485
1486+/* make sure the kernel log is readable after dropping privileges
1487+ */
1488+rsRetVal
1489+klogWillRunPostPrivDrop(modConfData_t *pModConf)
1490+{
1491+ char errmsg[2048];
1492+ int r;
1493+ DEFiRet;
1494+
1495+ /* this normally returns EINVAL */
1496+ /* on an OpenVZ VM, we get EPERM */
1497+ r = read(fklog, NULL, 0);
1498+ if (r < 0 && errno != EINVAL) {
1499+ imklogLogIntMsg(LOG_ERR, "imklog: cannot open kernel log (%s): %s.",
1500+ GetPath(pModConf), rs_strerror_r(errno, errmsg, sizeof(errmsg)));
1501+ fklog = -1;
1502+ ABORT_FINALIZE(RS_RET_ERR_OPEN_KLOG);
1503+ }
1504+
1505+finalize_it:
1506+ RETiRet;
1507+}
1508+
1509
1510 /* Read kernel log while data are available, split into lines.
1511 */
1512
1513=== modified file 'plugins/imklog/imklog.c'
1514--- plugins/imklog/imklog.c 2014-10-02 11:32:50 +0000
1515+++ plugins/imklog/imklog.c 2015-01-09 16:11:08 +0000
1516@@ -382,7 +382,7 @@
1517 BEGINactivateCnfPrePrivDrop
1518 CODESTARTactivateCnfPrePrivDrop
1519 runModConf = pModConf;
1520- iRet = klogWillRun(runModConf);
1521+ iRet = klogWillRunPrePrivDrop(runModConf);
1522 ENDactivateCnfPrePrivDrop
1523
1524
1525@@ -398,6 +398,7 @@
1526
1527 BEGINwillRun
1528 CODESTARTwillRun
1529+ iRet = klogWillRunPostPrivDrop(runModConf);
1530 ENDwillRun
1531
1532
1533
1534=== modified file 'plugins/imklog/imklog.h'
1535--- plugins/imklog/imklog.h 2013-03-18 16:21:35 +0000
1536+++ plugins/imklog/imklog.h 2015-01-09 16:11:08 +0000
1537@@ -48,8 +48,9 @@
1538 * rgerhards, 2008-04-09
1539 */
1540 rsRetVal klogLogKMsg(modConfData_t *pModConf);
1541-rsRetVal klogWillRun(modConfData_t *pModConf);
1542 rsRetVal klogAfterRun(modConfData_t *pModConf);
1543+rsRetVal klogWillRunPrePrivDrop(modConfData_t *pModConf);
1544+rsRetVal klogWillRunPostPrivDrop(modConfData_t *pModConf);
1545 int klogFacilIntMsg();
1546
1547 /* the functions below may be called by the drivers */
1548
1549=== modified file 'plugins/imkmsg/imkmsg.c'
1550--- plugins/imkmsg/imkmsg.c 2014-10-02 11:32:50 +0000
1551+++ plugins/imkmsg/imkmsg.c 2015-01-09 16:11:08 +0000
1552@@ -209,7 +209,7 @@
1553 BEGINactivateCnfPrePrivDrop
1554 CODESTARTactivateCnfPrePrivDrop
1555 runModConf = pModConf;
1556- iRet = klogWillRun(runModConf);
1557+ iRet = klogWillRunPrePrivDrop(runModConf);
1558 ENDactivateCnfPrePrivDrop
1559
1560
1561@@ -225,6 +225,7 @@
1562
1563 BEGINwillRun
1564 CODESTARTwillRun
1565+ iRet = klogWillRunPostPrivDrop(runModConf);
1566 ENDwillRun
1567
1568
1569
1570=== modified file 'plugins/imkmsg/imkmsg.h'
1571--- plugins/imkmsg/imkmsg.h 2012-10-29 16:30:14 +0000
1572+++ plugins/imkmsg/imkmsg.h 2015-01-09 16:11:08 +0000
1573@@ -42,7 +42,8 @@
1574 * rgerhards, 2008-04-09
1575 */
1576 rsRetVal klogLogKMsg(modConfData_t *pModConf);
1577-rsRetVal klogWillRun(modConfData_t *pModConf);
1578+rsRetVal klogWillRunPrePrivDrop(modConfData_t *pModConf);
1579+rsRetVal klogWillRunPostPrivDrop(modConfData_t *pModConf);
1580 rsRetVal klogAfterRun(modConfData_t *pModConf);
1581 int klogFacilIntMsg();
1582
1583
1584=== modified file 'plugins/imkmsg/kmsg.c'
1585--- plugins/imkmsg/kmsg.c 2015-01-05 10:52:48 +0000
1586+++ plugins/imkmsg/kmsg.c 2015-01-09 16:11:08 +0000
1587@@ -155,24 +155,36 @@
1588 /* open the kernel log - will be called inside the willRun() imkmsg entry point
1589 */
1590 rsRetVal
1591-klogWillRun(modConfData_t *pModConf)
1592+klogWillRunPrePrivDrop(modConfData_t *pModConf)
1593 {
1594- int i;
1595 char errmsg[2048];
1596 DEFiRet;
1597
1598 fklog = open(_PATH_KLOG, O_RDONLY, 0);
1599 if (fklog < 0) {
1600- imkmsgLogIntMsg(RS_RET_ERR_OPEN_KLOG, "imkmsg: cannot open kernel log(%s): %s.",
1601+ imkmsgLogIntMsg(LOG_ERR, "imkmsg: cannot open kernel log (%s): %s.",
1602 _PATH_KLOG, rs_strerror_r(errno, errmsg, sizeof(errmsg)));
1603 ABORT_FINALIZE(RS_RET_ERR_OPEN_KLOG);
1604 }
1605
1606- /* make sure the kernel log is readable */
1607- /* this normally returns EINVAL - on an OpenVZ VM, we get EBADF */
1608- i = read(fklog, NULL, 0);
1609- if (i < 0 && errno == EBADF) {
1610- imkmsgLogIntMsg(RS_RET_ERR_OPEN_KLOG, "imkmsg: cannot read kernel log(%s): %s.",
1611+finalize_it:
1612+ RETiRet;
1613+}
1614+
1615+/* make sure the kernel log is readable after dropping privileges
1616+ */
1617+rsRetVal
1618+klogWillRunPostPrivDrop(modConfData_t *pModConf)
1619+{
1620+ char errmsg[2048];
1621+ int r;
1622+ DEFiRet;
1623+
1624+ /* this normally returns EINVAL */
1625+ /* on an OpenVZ VM, we get EPERM */
1626+ r = read(fklog, NULL, 0);
1627+ if (r < 0 && errno != EINVAL) {
1628+ imkmsgLogIntMsg(LOG_ERR, "imkmsg: cannot open kernel log (%s): %s.",
1629 _PATH_KLOG, rs_strerror_r(errno, errmsg, sizeof(errmsg)));
1630 fklog = -1;
1631 ABORT_FINALIZE(RS_RET_ERR_OPEN_KLOG);

Subscribers

People subscribed via source and target branches

to all changes: