summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/Makefile.am2
-rw-r--r--runtime/Makefile.in8
-rw-r--r--runtime/atomic.h2
-rw-r--r--runtime/msg.c49
-rw-r--r--runtime/nsd_gtls.c4
-rw-r--r--runtime/parser.c8
-rw-r--r--runtime/prop.h2
-rw-r--r--runtime/rsyslog.h66
-rw-r--r--runtime/srutils.c1
-rw-r--r--runtime/syslogd-types.h5
-rw-r--r--runtime/typedefs.h4
-rw-r--r--runtime/wti.h2
-rw-r--r--runtime/wtp.h4
13 files changed, 110 insertions, 47 deletions
diff --git a/runtime/Makefile.am b/runtime/Makefile.am
index a100938..d07409e 100644
--- a/runtime/Makefile.am
+++ b/runtime/Makefile.am
@@ -106,7 +106,7 @@ else
librsyslog_la_CPPFLAGS = -DSD_EXPORT_SYMBOLS -D_PATH_MODDIR=\"$(pkglibdir)/\" -I\$(top_srcdir) -I\$(top_srcdir)/grammar
endif
#librsyslog_la_LDFLAGS = -module -avoid-version
-librsyslog_la_CPPFLAGS += $(PTHREADS_CFLAGS) $(LIBUUID_CFLAGS) $(JSON_C_CFLAGS) -I\$(top_srcdir)/tools
+librsyslog_la_CPPFLAGS += $(PTHREADS_CFLAGS) $(LIBUUID_CFLAGS) $(JSON_C_CFLAGS) ${LIBLOGGING_STDLOG_CFLAGS} -I\$(top_srcdir)/tools
librsyslog_la_LIBADD = $(DL_LIBS) $(RT_LIBS) $(LIBUUID_LIBS) $(JSON_C_LIBS)
#
diff --git a/runtime/Makefile.in b/runtime/Makefile.in
index 79862c3..a3339d8 100644
--- a/runtime/Makefile.in
+++ b/runtime/Makefile.in
@@ -583,7 +583,9 @@ librsyslog_la_SOURCES = \
@WITH_MODDIRS_FALSE@ -D_PATH_MODDIR=\"$(pkglibdir)/\" \
@WITH_MODDIRS_FALSE@ -I\$(top_srcdir) -I\$(top_srcdir)/grammar \
@WITH_MODDIRS_FALSE@ $(PTHREADS_CFLAGS) $(LIBUUID_CFLAGS) \
-@WITH_MODDIRS_FALSE@ $(JSON_C_CFLAGS) -I\$(top_srcdir)/tools
+@WITH_MODDIRS_FALSE@ $(JSON_C_CFLAGS) \
+@WITH_MODDIRS_FALSE@ ${LIBLOGGING_STDLOG_CFLAGS} \
+@WITH_MODDIRS_FALSE@ -I\$(top_srcdir)/tools
# the files with ../ we need to work on - so that they either become part of the
# runtime or will no longer be needed. -- rgerhards, 2008-06-13
#
@@ -591,7 +593,9 @@ librsyslog_la_SOURCES = \
@WITH_MODDIRS_TRUE@librsyslog_la_CPPFLAGS = -DSD_EXPORT_SYMBOLS \
@WITH_MODDIRS_TRUE@ -D_PATH_MODDIR=\"$(pkglibdir)/:$(moddirs)\" \
@WITH_MODDIRS_TRUE@ $(PTHREADS_CFLAGS) $(LIBUUID_CFLAGS) \
-@WITH_MODDIRS_TRUE@ $(JSON_C_CFLAGS) -I\$(top_srcdir)/tools
+@WITH_MODDIRS_TRUE@ $(JSON_C_CFLAGS) \
+@WITH_MODDIRS_TRUE@ ${LIBLOGGING_STDLOG_CFLAGS} \
+@WITH_MODDIRS_TRUE@ -I\$(top_srcdir)/tools
librsyslog_la_LIBADD = $(DL_LIBS) $(RT_LIBS) $(LIBUUID_LIBS) $(JSON_C_LIBS)
@ENABLE_REGEXP_TRUE@lmregexp_la_SOURCES = regexp.c regexp.h
@ENABLE_REGEXP_TRUE@lmregexp_la_CPPFLAGS = $(PTHREADS_CFLAGS) $(RSRT_CFLAGS)
diff --git a/runtime/atomic.h b/runtime/atomic.h
index 49c17d8..d59858a 100644
--- a/runtime/atomic.h
+++ b/runtime/atomic.h
@@ -221,7 +221,7 @@
return(val);
}
-# define DEF_ATOMIC_HELPER_MUT64(x) pthread_mutex_t x
+# define DEF_ATOMIC_HELPER_MUT64(x) pthread_mutex_t x;
# define INIT_ATOMIC_HELPER_MUT64(x) pthread_mutex_init(&(x), NULL)
# define DESTROY_ATOMIC_HELPER_MUT64(x) pthread_mutex_destroy(&(x))
#endif /* #ifdef HAVE_ATOMIC_BUILTINS64 */
diff --git a/runtime/msg.c b/runtime/msg.c
index 66c3b7b..d911b8b 100644
--- a/runtime/msg.c
+++ b/runtime/msg.c
@@ -125,7 +125,7 @@ static char *years[] = {
static struct {
uchar *pszName;
short lenName;
-} syslog_pri_names[192] = {
+} syslog_pri_names[200] = {
{ UCHAR_CONSTANT("0"), 3},
{ UCHAR_CONSTANT("1"), 3},
{ UCHAR_CONSTANT("2"), 3},
@@ -317,22 +317,30 @@ static struct {
{ UCHAR_CONSTANT("188"), 5},
{ UCHAR_CONSTANT("189"), 5},
{ UCHAR_CONSTANT("190"), 5},
- { UCHAR_CONSTANT("191"), 5}
+ { UCHAR_CONSTANT("191"), 5},
+ { UCHAR_CONSTANT("192"), 5},
+ { UCHAR_CONSTANT("193"), 5},
+ { UCHAR_CONSTANT("194"), 5},
+ { UCHAR_CONSTANT("195"), 5},
+ { UCHAR_CONSTANT("196"), 5},
+ { UCHAR_CONSTANT("197"), 5},
+ { UCHAR_CONSTANT("198"), 5},
+ { UCHAR_CONSTANT("199"), 5}
};
static char hexdigit[16] =
{'0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'A', 'B', 'C', 'D', 'E', 'F' };
/*syslog facility names (as of RFC5424) */
-static char *syslog_fac_names[24] = { "kern", "user", "mail", "daemon", "auth", "syslog", "lpr",
+static char *syslog_fac_names[LOG_NFACILITIES] = { "kern", "user", "mail", "daemon", "auth", "syslog", "lpr",
"news", "uucp", "cron", "authpriv", "ftp", "ntp", "audit",
"alert", "clock", "local0", "local1", "local2", "local3",
- "local4", "local5", "local6", "local7" };
+ "local4", "local5", "local6", "local7", "invld" };
/* length of the facility names string (for optimizatiions) */
-static short len_syslog_fac_names[24] = { 4, 4, 4, 6, 4, 6, 3,
+static short len_syslog_fac_names[LOG_NFACILITIES] = { 4, 4, 4, 6, 4, 6, 3,
4, 4, 4, 8, 3, 3, 5,
5, 5, 6, 6, 6, 6,
- 6, 6, 6, 6 };
+ 6, 6, 6, 6, 5 };
/* table of severity names (in numerical order)*/
static char *syslog_severity_names[8] = { "emerg", "alert", "crit", "err", "warning", "notice", "info", "debug" };
@@ -342,8 +350,8 @@ static short len_syslog_severity_names[8] = { 5, 5, 4, 3, 7, 6, 4, 5 };
* and facility values to a numerical string... -- rgerhars, 2009-06-17
*/
-static char *syslog_number_names[24] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
- "15", "16", "17", "18", "19", "20", "21", "22", "23" };
+static char *syslog_number_names[LOG_NFACILITIES] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
+ "15", "16", "17", "18", "19", "20", "21", "22", "23", "24" };
/* global variables */
#if defined(HAVE_MALLOC_TRIM) && !defined(HAVE_ATOMIC_BUILTINS)
@@ -700,8 +708,8 @@ static inline rsRetVal msgBaseConstruct(msg_t **ppThis)
pM->flowCtlType = 0;
pM->bParseSuccess = 0;
pM->iRefCount = 1;
- pM->iSeverity = -1;
- pM->iFacility = -1;
+ pM->iSeverity = LOG_DEBUG;
+ pM->iFacility = LOG_INVLD;
pM->iLenPROGNAME = -1;
pM->offAfterPRI = 0;
pM->offMSG = -1;
@@ -1544,7 +1552,10 @@ uchar *getMSG(msg_t * const pM)
/* Get PRI value as integer */
static int getPRIi(msg_t * const pM)
{
- return (pM->iFacility << 3) + (pM->iSeverity);
+ int pri = (pM->iFacility << 3) + (pM->iSeverity);
+ if(pri > 191)
+ pri = LOG_PRI_INVLD;
+ return pri;
}
@@ -2626,11 +2637,11 @@ void MsgSetRawMsgWOSize(msg_t * const pMsg, char* pszRawMsg)
char *textpri(char *pRes, int pri)
{
assert(pRes != NULL);
- memcpy(pRes, syslog_fac_names[LOG_FAC(pri)], len_syslog_fac_names[LOG_FAC(pri)]);
- pRes[len_syslog_fac_names[LOG_FAC(pri)]] = '.';
- memcpy(pRes+len_syslog_fac_names[LOG_FAC(pri)]+1,
- syslog_severity_names[LOG_PRI(pri)],
- len_syslog_severity_names[LOG_PRI(pri)]+1 /* for \0! */);
+ memcpy(pRes, syslog_fac_names[pri2fac(pri)], len_syslog_fac_names[pri2fac(pri)]);
+ pRes[len_syslog_fac_names[pri2fac(pri)]] = '.';
+ memcpy(pRes+len_syslog_fac_names[pri2fac(pri)]+1,
+ syslog_severity_names[pri2sev(pri)],
+ len_syslog_severity_names[pri2sev(pri)]+1 /* for \0! */);
return pRes;
}
@@ -4074,7 +4085,11 @@ MsgSetPropsViaJSON(msg_t *__restrict__ const pMsg, const uchar *__restrict__ con
err = tokener->err;
if(err != json_tokener_continue)
- errMsg = json_tokener_errors[err];
+# if HAVE_JSON_TOKENER_ERROR_DESC
+ errMsg = json_tokener_error_desc(err);
+# else
+ errMsg = json_tokener_errors[err];
+# endif
else
errMsg = "Unterminated input";
} else if(!json_object_is_type(json, json_type_object))
diff --git a/runtime/nsd_gtls.c b/runtime/nsd_gtls.c
index 056699d..b2ecabd 100644
--- a/runtime/nsd_gtls.c
+++ b/runtime/nsd_gtls.c
@@ -1584,7 +1584,9 @@ finalize_it:
static rsRetVal
EnableKeepAlive(nsd_t *pNsd)
{
- return nsd_ptcp.EnableKeepAlive(pNsd);
+ nsd_gtls_t *pThis = (nsd_gtls_t*) pNsd;
+ ISOBJ_TYPE_assert(pThis, nsd_gtls);
+ return nsd_ptcp.EnableKeepAlive(pThis->pTcp);
}
diff --git a/runtime/parser.c b/runtime/parser.c
index 5607484..1baa502 100644
--- a/runtime/parser.c
+++ b/runtime/parser.c
@@ -620,11 +620,11 @@ ParsePRI(msg_t *pMsg)
}
if(*msg == '>')
++msg;
- if(pri & ~(LOG_FACMASK|LOG_PRIMASK))
- pri = DEFUPRI;
+ if(pri > LOG_MAXPRI)
+ pri = LOG_PRI_INVLD;
}
- pMsg->iFacility = LOG_FAC(pri);
- pMsg->iSeverity = LOG_PRI(pri);
+ pMsg->iFacility = pri2fac(pri);
+ pMsg->iSeverity = pri2sev(pri);
MsgSetAfterPRIOffs(pMsg, msg - pMsg->pszRawMsg);
}
RETiRet;
diff --git a/runtime/prop.h b/runtime/prop.h
index 7cb2743..38d801d 100644
--- a/runtime/prop.h
+++ b/runtime/prop.h
@@ -33,7 +33,7 @@ struct prop_s {
uchar sz[CONF_PROP_BUFSIZE];
} szVal;
int len; /* we use int intentionally, otherwise we may get some troubles... */
- DEF_ATOMIC_HELPER_MUT(mutRefCount);
+ DEF_ATOMIC_HELPER_MUT(mutRefCount)
};
/* interfaces */
diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h
index 6711bd1..f7d5b8a 100644
--- a/runtime/rsyslog.h
+++ b/runtime/rsyslog.h
@@ -3,7 +3,7 @@
*
* Begun 2005-09-15 RGerhards
*
- * Copyright (C) 2005-2013 by Rainer Gerhards and Adiscon GmbH
+ * Copyright (C) 2005-2014 by Rainer Gerhards and Adiscon GmbH
*
* This file is part of the rsyslog runtime library.
*
@@ -77,19 +77,58 @@
* # End Config Settings # *
* ############################################################# */
-/* portability: not all platforms have these defines, so we
- * define them here if they are missing. -- rgerhards, 2008-03-04
+/* make sure we uses consistent macros, no matter what the
+ * platform gives us.
*/
-#ifndef LOG_MAKEPRI
-# define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
-#endif
-#ifndef LOG_PRI
-# define LOG_PRI(p) ((p) & LOG_PRIMASK)
-#endif
-#ifndef LOG_FAC
-# define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
-#endif
-
+#define LOG_NFACILITIES 24+1 /* plus one for our special "invld" facility! */
+#define LOG_MAXPRI 191 /* highest supported valid PRI value --> RFC3164, RFC5424 */
+#undef LOG_MAKEPRI
+#define LOG_PRI_INVLD LOG_INVLD|LOG_DEBUG /* PRI is invalid --> special "invld.=debug" PRI code (rsyslog-specific) */
+
+#define LOG_EMERG 0 /* system is unusable */
+#define LOG_ALERT 1 /* action must be taken immediately */
+#define LOG_CRIT 2 /* critical conditions */
+#define LOG_ERR 3 /* error conditions */
+#define LOG_WARNING 4 /* warning conditions */
+#define LOG_NOTICE 5 /* normal but significant condition */
+#define LOG_INFO 6 /* informational */
+#define LOG_DEBUG 7 /* debug-level messages */
+
+#define LOG_KERN (0<<3) /* kernel messages */
+#define LOG_USER (1<<3) /* random user-level messages */
+#define LOG_MAIL (2<<3) /* mail system */
+#define LOG_DAEMON (3<<3) /* system daemons */
+#define LOG_AUTH (4<<3) /* security/authorization messages */
+#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
+#define LOG_LPR (6<<3) /* line printer subsystem */
+#define LOG_NEWS (7<<3) /* network news subsystem */
+#define LOG_UUCP (8<<3) /* UUCP subsystem */
+#define LOG_CRON (9<<3) /* clock daemon */
+#define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
+#define LOG_FTP (11<<3) /* ftp daemon */
+#define LOG_LOCAL0 (16<<3) /* reserved for local use */
+#define LOG_LOCAL1 (17<<3) /* reserved for local use */
+#define LOG_LOCAL2 (18<<3) /* reserved for local use */
+#define LOG_LOCAL3 (19<<3) /* reserved for local use */
+#define LOG_LOCAL4 (20<<3) /* reserved for local use */
+#define LOG_LOCAL5 (21<<3) /* reserved for local use */
+#define LOG_LOCAL6 (22<<3) /* reserved for local use */
+#define LOG_LOCAL7 (23<<3) /* reserved for local use */
+#define LOG_FAC_INVLD 24
+#define LOG_INVLD (LOG_FAC_INVLD<<3) /* invalid facility/PRI code */
+
+/* we need to use a function to avoid side-effects. This MUST guard
+ * against invalid facility values. rgerhards, 2014-09-16
+ */
+static inline int pri2fac(const int pri)
+{
+ int fac = pri >> 3;
+ return (fac > 23) ? LOG_FAC_INVLD : fac;
+}
+static inline int pri2sev(const int pri)
+{
+ return pri & 0x07;
+}
/* the rsyslog core provides information about present feature to plugins
* asking it. Below are feature-test macros which must be used to query
@@ -386,6 +425,7 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_CONF_WRN_FULLDLY_BELOW_HIGHWTR = -2358,/**< warning queue full delay mark below high wtr mark */
RS_RET_RESUMED = -2359,/**< status: action was resumed (used for reporting) */
RS_RET_RELP_NO_TLS = -2360,/**< librel does not support TLS (but TLS requested) */
+ RS_RET_STATEFILE_WRONG_FNAME = -2361,/**< state file is for wrong file */
/* up to 2400 reserved for 7.5 & 7.6 */
RS_RET_INVLD_OMOD = -2400, /**< invalid output module, does not provide proper interfaces */
diff --git a/runtime/srutils.c b/runtime/srutils.c
index 6d842ab..d7e71ed 100644
--- a/runtime/srutils.c
+++ b/runtime/srutils.c
@@ -105,6 +105,7 @@ syslogName_t syslogFacNames[] = {
{"local5", LOG_LOCAL5},
{"local6", LOG_LOCAL6},
{"local7", LOG_LOCAL7},
+ {"invld", LOG_INVLD},
{NULL, -1},
};
diff --git a/runtime/syslogd-types.h b/runtime/syslogd-types.h
index 4b5d135..fe9dfa9 100644
--- a/runtime/syslogd-types.h
+++ b/runtime/syslogd-types.h
@@ -4,7 +4,7 @@
*
* File begun on 2007-07-13 by RGerhards (extracted from syslogd.c)
*
- * Copyright 2007-2012 Adiscon GmbH.
+ * Copyright 2007-2014 Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@@ -27,9 +27,6 @@
#include "stringbuf.h"
#include <sys/param.h>
-#if HAVE_SYSLOG_H
-#include <syslog.h>
-#endif
/* we use RSTRUE/FALSE to prevent name claches with other packages */
#define RSFALSE 0
diff --git a/runtime/typedefs.h b/runtime/typedefs.h
index f2f5af6..bf92021 100644
--- a/runtime/typedefs.h
+++ b/runtime/typedefs.h
@@ -268,4 +268,8 @@ struct msgPropDescr_s {
int nameLen; /* properties (JSON) */
};
+/* some forward-definitions from the grammar */
+struct nvlst;
+struct cnfobj;
+
#endif /* multi-include protection */
diff --git a/runtime/wti.h b/runtime/wti.h
index 487abb7..496ef23 100644
--- a/runtime/wti.h
+++ b/runtime/wti.h
@@ -72,7 +72,7 @@ struct wti_s {
actWrkrInfo_t *actWrkrInfo; /* *array* of action wrkr infos for all actions
(sized for max nbr of actions in config!) */
pthread_cond_t pcondBusy; /* condition to wake up the worker, protected by pmutUsr in wtp */
- DEF_ATOMIC_HELPER_MUT(mutIsRunning);
+ DEF_ATOMIC_HELPER_MUT(mutIsRunning)
struct {
uint8_t bPrevWasSuspended;
uint8_t bDoAutoCommit; /* do a commit after each message
diff --git a/runtime/wtp.h b/runtime/wtp.h
index 4bc284c..531355f 100644
--- a/runtime/wtp.h
+++ b/runtime/wtp.h
@@ -63,8 +63,8 @@ struct wtp_s {
rsRetVal (*pfDoWork)(void *pUsr, void *pWti);
/* end user objects */
uchar *pszDbgHdr; /* header string for debug messages */
- DEF_ATOMIC_HELPER_MUT(mutCurNumWrkThrd);
- DEF_ATOMIC_HELPER_MUT(mutWtpState);
+ DEF_ATOMIC_HELPER_MUT(mutCurNumWrkThrd)
+ DEF_ATOMIC_HELPER_MUT(mutWtpState)
};
/* some symbolic constants for easier reference */