diff options
author | Milan <mbartos@redhat.com> | 2013-05-15 14:24:03 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-05-20 21:18:46 +0200 |
commit | 864421ed5b705b62635940507dade451267c7f7a (patch) | |
tree | bd0a9f78fe672f4e34fd5a84640763f63bebcf24 /plugins/imjournal/imjournal.c | |
parent | 1f2b6f1a9b110fec5995582285f0fe9dcd628c99 (diff) | |
download | rsyslog-864421ed5b705b62635940507dade451267c7f7a.tar.gz rsyslog-864421ed5b705b62635940507dade451267c7f7a.tar.bz2 rsyslog-864421ed5b705b62635940507dade451267c7f7a.zip |
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.
Diffstat (limited to 'plugins/imjournal/imjournal.c')
-rwxr-xr-x | plugins/imjournal/imjournal.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c index 42d3cf6d..b7bd3c64 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: " |