Here are several smaller patches: - the first moves the imjournal state file into the workdir - the second gets rid of a macro that didn't have any effect - the third cleans up some warnings in [io]mjournal
Tomas
>From 181074056f97e02923fb2b2f1cd95f61d738b4c2 Mon Sep 17 00:00:00 2001 From: Milan <[email protected]> Date: Wed, 15 May 2013 14:24:03 +0200 Subject: [PATCH 1/3] Imjournal state files can be stored in WorkDirectory When the imjournal state file path doesn't start with '/', then it's by default stored in WorkDirectory. When path starts with '/', full path is used. --- plugins/imjournal/imjournal.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c index 42d3cf6..b7bd3c6 100755 --- a/plugins/imjournal/imjournal.c +++ b/plugins/imjournal/imjournal.c @@ -392,12 +392,24 @@ CODESTARTrunInput */ int count = 0; - char readCursor[128 + 1]; - FILE *r_sf; + if (cs.stateFile[0] != '/') { + char *new_stateFile; + + if (-1 == asprintf(&new_stateFile, "%s/%s", (char *)glbl.GetWorkDir(), cs.stateFile)) { + errmsg.LogError(0, RS_RET_OUT_OF_MEMORY, "imjournal: asprintf failed\n"); + ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY); + } + free (cs.stateFile); + cs.stateFile = new_stateFile; + } /* if state file exists, set cursor to appropriate position */ if (access(cs.stateFile, F_OK|R_OK) != -1) { + FILE *r_sf; + if ((r_sf = fopen(cs.stateFile, "rb")) != NULL) { + char readCursor[128 + 1]; + if (fscanf(r_sf, "%128s\n", readCursor) != EOF) { if (sd_journal_seek_cursor(j, readCursor) != 0) { errmsg.LogError(0, RS_RET_ERR, "imjournal: " -- 1.7.10.4
>From bddf144052d7e6c7d1f802012c23afedee53de26 Mon Sep 17 00:00:00 2001 From: Tomas Heinrich <[email protected]> Date: Wed, 15 May 2013 14:27:03 +0200 Subject: [PATCH 2/3] Drop unneeded macro definition The macro itself was a malformed version of "_GNU_SOURCE" and thus had no effect. It is not needed as this macro is already defined via AC_GNU_SOURCE. --- tools/syslogd.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/syslogd.c b/tools/syslogd.c index 1b38bf9..7a8e21c 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -51,7 +51,6 @@ #include <stddef.h> #include <ctype.h> #include <limits.h> -#define GNU_SOURCE #include <string.h> #include <stdarg.h> #include <time.h> -- 1.7.10.4
>From 5ddc1ff63dc5d0d82e7255a32ae25d24b621092c Mon Sep 17 00:00:00 2001 From: Tomas Heinrich <[email protected]> Date: Wed, 15 May 2013 16:25:25 +0200 Subject: [PATCH 3/3] Clean up warnings in imjournal and omjournal --- plugins/imjournal/imjournal.c | 21 ++++++++++++--------- plugins/omjournal/omjournal.c | 2 ++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c index b7bd3c6..3633ec0 100755 --- a/plugins/imjournal/imjournal.c +++ b/plugins/imjournal/imjournal.c @@ -44,6 +44,7 @@ #include "glbl.h" #include "prop.h" #include "errmsg.h" +#include "srUtils.h" #include "unicode-helper.h" #include <systemd/sd-journal.h> @@ -137,6 +138,7 @@ readjournal() { uint64_t timestamp; struct json_object *json = NULL; + int r; /* Information from messages */ char *message; @@ -230,15 +232,15 @@ readjournal() { } if (sys_pid) { - asprintf(&sys_iden_help, "%s[%s]:", sys_iden, sys_pid); + r = asprintf(&sys_iden_help, "%s[%s]:", sys_iden, sys_pid); } else { - asprintf(&sys_iden_help, "%s:", sys_iden); + r = asprintf(&sys_iden_help, "%s:", sys_iden); } free (sys_iden); free (sys_pid); - if (sys_iden_help == NULL) { + if (-1 == r) { iRet = RS_RET_OUT_OF_MEMORY; goto finalize_it; } @@ -369,15 +371,16 @@ persistJournalState () { fclose(sf); free(cursor); } else { - char errmsg[256]; - rs_strerror_r(errno, errmsg, sizeof(errmsg)); - dbgprintf("fopen() failed: '%s'\n", errmsg); + char errStr[256]; + rs_strerror_r(errno, errStr, sizeof(errStr)); + errmsg.LogError(0, RS_RET_FOPEN_FAILURE, "fopen() failed: " + "'%s', path: '%s'\n", errStr, cs.stateFile); iRet = RS_RET_FOPEN_FAILURE; } } else { - char errmsg[256]; - rs_strerror_r(-(ret), errmsg, sizeof(errmsg)); - dbgprintf("sd_journal_get_cursor() failed: '%s'\n", errmsg); + char errStr[256]; + rs_strerror_r(-(ret), errStr, sizeof(errStr)); + errmsg.LogError(0, RS_RET_ERR, "sd_journal_get_cursor() failed: '%s'\n", errStr); iRet = RS_RET_ERR; } RETiRet; diff --git a/plugins/omjournal/omjournal.c b/plugins/omjournal/omjournal.c index c340287..160c369 100644 --- a/plugins/omjournal/omjournal.c +++ b/plugins/omjournal/omjournal.c @@ -107,6 +107,7 @@ CODESTARTnewActInst * the lst ptr. However, we will most probably need params in the * future. */ + (void) lst; /* prevent compiler warning */ DBGPRINTF("newActInst (mmjournal)\n"); CODE_STD_STRING_REQUESTnewActInst(1) CHKiRet(OMSRsetEntry(*ppOMSR, 0, NULL, OMSR_TPL_AS_MSG)); @@ -145,6 +146,7 @@ CODESTARTdoAction "SYSLOG_IDENTIFIER=%s", tag, NULL); /* FIXME: think about what to do with errors ;) */ + (void) r; /* prevent compiler warning */ ENDdoAction -- 1.7.10.4
_______________________________________________ rsyslog mailing list http://lists.adiscon.net/mailman/listinfo/rsyslog http://www.rsyslog.com/professional-services/ What's up with rsyslog? Follow https://twitter.com/rgerhards NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE THAT.

