summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2013-05-15 18:11:39 +0200
committerMichael Biebl <biebl@debian.org>2013-05-15 18:11:39 +0200
commit91bc2744cf85809ac50535129ba4a3c4faae081b (patch)
tree9a447d9be1ce5e082e8c964215ad01573bab3b4e /plugins
parentd5e3be17e7d29f5464bf8ed0130e92928ad099e8 (diff)
downloadrsyslog-91bc2744cf85809ac50535129ba4a3c4faae081b.tar.gz
Imported Upstream version 7.3.15upstream/7.3.15
Diffstat (limited to 'plugins')
-rwxr-xr-x[-rw-r--r--]plugins/imjournal/imjournal.c38
-rw-r--r--plugins/omrelp/omrelp.c58
2 files changed, 35 insertions, 61 deletions
diff --git a/plugins/imjournal/imjournal.c b/plugins/imjournal/imjournal.c
index 2af1958..42d3cf6 100644..100755
--- 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"
@@ -139,13 +140,16 @@ readjournal() {
/* Information from messages */
char *message;
+ char *sys_pid;
char *sys_iden;
char *sys_iden_help;
const void *get;
+ const void *pidget;
char *parse;
char *get2;
size_t length;
+ size_t pidlength;
const void *equal_sign;
struct json_object *jval;
@@ -203,7 +207,7 @@ readjournal() {
goto free_message;
}
- /* Get message identifier and add ':' */
+ /* Get message identifier, client pid and add ':' */
if (sd_journal_get_data(j, "SYSLOG_IDENTIFIER", &get, &length) >= 0) {
sys_iden = strndup(get+18, length-18);
} else {
@@ -214,12 +218,30 @@ readjournal() {
goto free_message;
}
- asprintf(&sys_iden_help, "%s:", sys_iden);
+ if (sd_journal_get_data(j, "SYSLOG_PID", &pidget, &pidlength) >= 0) {
+ sys_pid = strndup(pidget+11, pidlength-11);
+ if (sys_pid == NULL) {
+ iRet = RS_RET_OUT_OF_MEMORY;
+ free (sys_iden);
+ goto free_message;
+ }
+ } else {
+ sys_pid = NULL;
+ }
+
+ if (sys_pid) {
+ asprintf(&sys_iden_help, "%s[%s]:", sys_iden, sys_pid);
+ } else {
+ asprintf(&sys_iden_help, "%s:", sys_iden);
+ }
+
+ free (sys_iden);
+ free (sys_pid);
+
if (sys_iden_help == NULL) {
iRet = RS_RET_OUT_OF_MEMORY;
goto finalize_it;
}
- free (sys_iden);
json = json_object_new_object();
@@ -337,7 +359,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 +369,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;
diff --git a/plugins/omrelp/omrelp.c b/plugins/omrelp/omrelp.c
index c9e3244..ae65f40 100644
--- a/plugins/omrelp/omrelp.c
+++ b/plugins/omrelp/omrelp.c
@@ -59,7 +59,6 @@ static relpEngine_t *pRelpEngine; /* our relp engine */
typedef struct _instanceData {
uchar *target;
- int compressionLevel; /* 0 - no compression, else level for zlib */
uchar *port;
int bInitialConnect; /* is this the initial connection request of our module? (0-no, 1-yes) */
int bIsConnected; /* currently connected to server? 0 - no, 1 - yes */
@@ -121,6 +120,7 @@ finalize_it:
BEGINcreateInstance
CODESTARTcreateInstance
pData->bInitialConnect = 1;
+ pData->timeout = 90;
ENDcreateInstance
BEGINfreeInstance
@@ -279,62 +279,6 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
if((iRet = createInstance(&pData)) != RS_RET_OK)
FINALIZE;
- /* we are now after the protocol indicator. Now check if we should
- * use compression. We begin to use a new option format for this:
- * @(option,option)host:port
- * The first option defined is "z[0..9]" where the digit indicates
- * the compression level. If it is not given, 9 (best compression) is
- * assumed. An example action statement might be:
- * :omrelp:(z5,o)127.0.0.1:1400
- * Which means send via TCP with medium (5) compresion (z) to the local
- * host on port 1400. The '0' option means that octet-couting (as in
- * IETF I-D syslog-transport-tls) is to be used for framing (this option
- * applies to TCP-based syslog only and is ignored when specified with UDP).
- * That is not yet implemented.
- * rgerhards, 2006-12-07
- * TODO: think of all this in spite of RELP -- rgerhards, 2008-03-13
- */
- if(*p == '(') {
- /* at this position, it *must* be an option indicator */
- do {
- ++p; /* eat '(' or ',' (depending on when called) */
- /* check options */
- if(*p == 'z') { /* compression */
-# ifdef USE_NETZIP
- ++p; /* eat */
- if(isdigit((int) *p)) {
- int iLevel;
- iLevel = *p - '0';
- ++p; /* eat */
- pData->compressionLevel = iLevel;
- } else {
- errmsg.LogError(0, NO_ERRCODE, "Invalid compression level '%c' specified in "
- "forwardig action - NOT turning on compression.",
- *p);
- }
-# else
- errmsg.LogError(0, NO_ERRCODE, "Compression requested, but rsyslogd is not compiled "
- "with compression support - request ignored.");
-# endif /* #ifdef USE_NETZIP */
- } else { /* invalid option! Just skip it... */
- errmsg.LogError(0, NO_ERRCODE, "Invalid option %c in forwarding action - ignoring.", *p);
- ++p; /* eat invalid option */
- }
- /* the option processing is done. We now do a generic skip
- * to either the next option or the end of the option
- * block.
- */
- while(*p && *p != ')' && *p != ',')
- ++p; /* just skip it */
- } while(*p && *p == ','); /* Attention: do.. while() */
- if(*p == ')')
- ++p; /* eat terminator, on to next */
- else
- /* we probably have end of string - leave it for the rest
- * of the code to handle it (but warn the user)
- */
- errmsg.LogError(0, NO_ERRCODE, "Option block not terminated in forwarding action.");
- }
/* extract the host first (we do a trick - we replace the ';' or ':' with a '\0')
* now skip to port and then template name. rgerhards 2005-07-06
*/