summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Heinrich <theinric@redhat.com>2013-05-12 18:37:00 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2013-05-14 15:41:14 +0200
commite43c8f37a3a698dd61e822d94d3a9c5d70d3b6cb (patch)
treec54dcaf1457b6033a54f3abf55636dade6966e5d
parent4341b2a37d5bc1bda71e949577c28c0cd8225e9b (diff)
downloadrsyslog-e43c8f37a3a698dd61e822d94d3a9c5d70d3b6cb.tar.gz
rsyslog-e43c8f37a3a698dd61e822d94d3a9c5d70d3b6cb.tar.bz2
rsyslog-e43c8f37a3a698dd61e822d94d3a9c5d70d3b6cb.zip
Fix a condition in imjournal
This prevented state file from being written with newer systemd. Add some more debug information.
-rw-r--r--plugins/imjournal/imjournal.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c
index 2af1958e..090bfb8a 100644
--- a/plugins/imjournal/imjournal.c
+++ b/plugins/imjournal/imjournal.c
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <time.h>
#include <sys/socket.h>
+#include <errno.h>
#include "dirty.h"
#include "cfsysline.h"
@@ -337,7 +338,9 @@ persistJournalState () {
char *cursor;
int ret = 0;
- if ((ret = sd_journal_get_cursor(j, &cursor)) > 0) {
+ /* On success, sd_journal_get_cursor() returns 1 in systemd
+ 197 or older and 0 in systemd 198 or newer */
+ if ((ret = sd_journal_get_cursor(j, &cursor)) >= 0) {
if ((sf = fopen(cs.stateFile, "wb")) != NULL) {
if (fprintf(sf, "%s", cursor) < 0) {
iRet = RS_RET_IO_ERROR;
@@ -345,9 +348,15 @@ persistJournalState () {
fclose(sf);
free(cursor);
} else {
+ char errmsg[256];
+ rs_strerror_r(errno, errmsg, sizeof(errmsg));
+ dbgprintf("fopen() failed: '%s'\n", errmsg);
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);
iRet = RS_RET_ERR;
}
RETiRet;