Merge branch 'fcr-master' into merge-1041

This commit is contained in:
Rainer Gerhards 2016-10-11 14:58:08 +02:00
commit 3aa7eabfae
167 changed files with 3139 additions and 1704 deletions

View File

@ -22,6 +22,7 @@ addons:
- pkg-config
- libtool
- autoconf
#- autoconf-archive
- autotools-dev
- gdb
- valgrind
@ -74,14 +75,19 @@ matrix:
env: BUILD_FROM_TARBALL="YES", GROK="YES", KAFKA="YES", CHECK="YES", CFLAGS="-g -O2 -W -Wall -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute", RS_TESTBENCH_VALGRIND_EXTRA_OPTS="--suppressions=travis/trusty.supp --gen-suppressions=all"
dist: trusty
- compiler: "clang"
env: CHECK="YES", ESTEST="YES", CFLAGS="-g -O1 -fsanitize=address -fno-color-diagnostics"
# we run this test without assert() enabled, so that we get "production timing"
env: CHECK="YES", ESTEST="YES", CFLAGS="-g -O1 -fsanitize=address -fno-color-diagnostics", CONFIGURE_FLAGS="--disable-debug"
- compiler: "clang"
dist: trusty
env: AD_PPA="v8-devel", CHECK="YES", CFLAGS="-g -O1 -fsanitize=address -fno-color-diagnostics"
services:
- elasticsearch
before_install:
- sudo add-apt-repository ppa:adiscon/v8-stable -y
- if [ "${AD_PPA}x" == "x" ] ; then AD_PPA="v8-stable"; fi
- sudo add-apt-repository ppa:adiscon/$AD_PPA -y
- sudo add-apt-repository ppa:qpid/released -y
- sudo apt-get update -qq
- mysql -u root -e "CREATE USER 'rsyslog'@'localhost' IDENTIFIED BY 'testbench';"

133
ChangeLog
View File

@ -1,7 +1,140 @@
------------------------------------------------------------------------------
Version 8.23.0 [v8-stable] 2016-11-15
- imfile: new timeout feature for multi-line reads
When using startmsg.regex, messages are held until the next one is written.
We now provide a "readTimeout" parameter family (see doc) to timeout such
reads and ensure messages are not held for a very long time.
see also https://github.com/rsyslog/rsyslog/issues/1133
- omfile: improve robustness against network file system failures
in case of failure, a close and re-open is tried, which often solves the
issue (and wasn't handle before this patch).
see also https://github.com/rsyslog/rsyslog/pull/1161
Thanks to github user hese10 for the patch.
- pmaixforwardedfrom: support for AIX syslogd -s option
if syslog in AIX started with "-s" option, AIX syslog adds only "From "
instead of "Message forwarded from ". With this patch, both are now
detected.
Thanks to github user patelritesh for the patch.
- bugfix imfile: ReopenOnTruncate processing, file open processing
This fixes
* ReopenOnTrucate was only honored when a state file existed
see https://github.com/rsyslog/rsyslog/issues/1090
* open processing could run into a loop
see https://github.com/rsyslog/rsyslog/issues/1174
This is done via refactoring the open file handling, which provides
overall cleaner and easier-to-follow code.
Thanks to Owen Smith for analyzing the problem and providing a
prototype PR which greatly helped towards the final solution.
- bugfix omrelp: invalid module name imrelp was used in some error messages
Thanks to Chris Pilkington for the patch.
- bugfix external module perl skeleton: did not work properly
Thanks to github user Igorjan666 for the patch.
- bugfix build system: Fix detection of pthread_setschedparam() on platforms
such as FreeBSD
see also https://github.com/rsyslog/rsyslog/pull/1147
Thanks to Matthew Seaman for the patch.
- build environment: --enable-debug now defaults to new "auto" mode
previously, DEBUG mode (and thus assert() macros) was disabled by default
and explicitly needed to be enabled by providing the --enable-debug
./configure switch. Now, a new --enable-debug=auto mode has been added
and made the default. It enables DEBUG mode if we build from git and only
disables it when a release build is done (from the release tarball). This
aims at better error checking during testbench runs and developer testing.
- testbench improvements
* imfile ReopenOnTruncate option is now being tested
* the CI environment now runs most tests in debug mode, but some in
release mode to cover potential release-mode races
------------------------------------------------------------------------------
Version 8.22.0 [v8-stable] 2016-10-04
- ompgsql: add template support
Thanks to Radu Gheorghe for implementing this.
- generate somewhat better error message on config file syntax error
a common case (object at invalid location) has received it's own error
message; for the rest we still rely on the generic flex/bison handler
- general cleanup and code improvement
mostly guided by compiler warnings induced by newer opensuse builbot
environment
------------------------------------------------------------------------------
Version 8.21.0 [v8-stable] 2016-08-23
- CHANGE OF BEHAVIOUR:
by default, internal messages are no longer logged via the internal
bridge to rsyslog but via the syslog() API call [either directly or
via liblogging). For the typical single-rsyslogd-instance installation this
is mostly unnoticable (except for some additional latency). If multiple
instances are run, only the "main" (the one processing system log messages)
will see all messages. To return to the old behaviour, do either of those
two:
1) add in rsyslog.conf:
global(processInternalMessages="on")
2) export the environment variable RSYSLOG_DFLT_LOG_INTERNAL=1
This will set a new default - the value can still be overwritten via
rsyslog.conf (method 1). Note that the environment variable must be
set in your **startup script**.
For more information, please visit
http://www.rsyslog.com/rsyslog-error-reporting-improved/
- slightly improved TLS syslog error messages
- queue subsystem: improved robustness
The .qi file is now persisted whenever an existing queue file is fully
written and a new file is begun. This helps with rsyslog aborts, including
the common case where the OS issues kill -9 because of insufficiently
configured termination timout (this is an OS config error, but a frequent
one). Also, a situation where an orphaned empty file could be left in the
queue work directory has been fixed. We expect that this change causes
fewer permanent queue failures.
- bugfix: build failed on some platforms due to missing include files
------------------------------------------------------------------------------
Version 8.20.0 [v8-stable] 2016-07-12
- NEW BUILD REQUIREMENT: librelp, was 1.2.5, now is 1.2.12
This is only needed if --enable-relp is used. The new version is needed
to support the new timeout parameter in omrelp.
- NEW BUILD SUGGESTION: libfastjson 0.99.3
while not strictly necessary, previous versions of libfastjson have a bug
in unicode processing that can result in non US-ASCII characters to be
improperly encoded and may (very unlikely) also cause a segfault.
This version will become mandatory in rsyslog 8.20.1.
- omrelp: add configurable connection timeout
Thanks to Nathan Brown for implementing this feature.
- pmrfc3164: add support for slashes in hostname
added parameter "permit.slashesinhostname" to support this, off by default
[Note that the RFC5424 always supported this, as 5424 is a different
standard]
- bugfix omfile: handle chown() failure correctly
If the file creation succeeds, but chown() failed, the file was
still writen, even if the user requested that this should be treated
as a failure case. This is corrected now.
Also, some refactoring was done to create better error messages.
- omfile now better conveys status of unwritable files back to core
- config files recursively including themselfes are now detected
and an error message is emitted in that case; Previously, this
misconfiguration resulted in rsyslog loop and abort during startup.
closes https://github.com/rsyslog/rsyslog/issues/1058
- refactored code to not emit compiler warnings in "strict mode"
We changed the compiler warning settings to be rather strict and cleaned up
the code to work without generating any warning messages.
This results in an overall even more improved code quality, which will now
also be enforced via our CI systems.
- bugfix: fix some issues with action CommitTransaction() handling
An action that returns an error from CommitTransaction() caused a
loop in rsyslog action processing. Similarly, retry processing was not
properly handled in regard to CommitTransaction().
This is a first shot at fixing the situation. It solves the
immediate problems, but does not implement the full desired
functionality (like error file).
see also https://github.com/rsyslog/rsyslog/issues/974
see also https://github.com/rsyslog/rsyslog/issues/500
- bugfix omqmqp1: connecting to the message bus fails on nonstandard port
Thanks to Ken Giusti for the patch.
see also: https://github.com/rsyslog/rsyslog/pull/1064
- testbench/CI enhancements
* new tests for RELP components
* new tests for core action processing and retry
* travis tests now also run against all unstable versions of supporting
libraries. This helps to track interdependency problems early.
* new tests for hostname parsing
* new tests for RainerScript comparisons
------------------------------------------------------------------------------
Version 8.19.0 [v8-stable] 2016-05-31
- NEW BUILD REQUIREMENT: autoconf-archive
- omelasticsearch: add option to permit unsigned certs (experimentally)
This adds plumbing as suggested by Joerg Heinemann and Radu Gheorghe,
but is otherwise untested. Chances are good it works. If you use it,

View File

@ -39,7 +39,6 @@ Follow the instructions at: http://www.rsyslog.com/doc/build_from_repo.html
### Build Environment
In general, you need
* libestr
@ -49,15 +48,15 @@ It is best to build these from source.
#### CentOS 6
for json-c, we need
For json-c, we need:
```
$ export PKG_CONFIG_PATH=/lib64/pkgconfig/
export PKG_CONFIG_PATH=/lib64/pkgconfig/
```
```
sudo yum install git valgrind autoconf automake flex bison python-docutils python-sphinx json-c-devel libuuid-devel libgcrypt-devel zlib-devel openssl-devel libcurl-devel gnutls-devel mysql-devel postgresql-devel libdbi-dbd-mysql libdbi-devel net-snmp-devel
```
#### Ubuntu
Note: this list is (obviously) incomplete. We intend to complete it as we
@ -65,7 +64,8 @@ have more information and install additional systems.
```
sudo apt-get install libdbi-dev libmysqlclient-dev postgresql-client libpq-dev libnet-dev librdkafka-dev libgrok-dev libgrok1 libgrok-dev libpcre3-dev libtokyocabinet-dev libglib2.0-dev libmongo-client-dev libhiredis-dev
```
for KSI, from the Adiscon PPA:
For KSI, from the Adiscon PPA:
```
sudo apt-get install libksi0 libksi-devel
```
@ -75,20 +75,20 @@ sudo apt-get install libksi0 libksi-devel
```
sudo zypper install gcc make autoconf automake libtool libcurl-devel flex bison valgrind python-docutils libjson-devel uuid-devel libgcrypt-devel libgnutls-devel libmysqlclient-devel libdbi-devel libnet-devel postgresql-devel net-snmp-devellibuuid-devel libdbi-drivers-dbd-mysql
```
For the testbench VMs:
```
sudo zypper install gvim mutt
```
#### SUSE LINUX Enterprise Server 11
Available Packages:
Available packages:
```
zypper install gcc make autoconf libtool flex bison
```
Missing Packages:
Missing packages:
```
libcurl-devel valgrind python-docutils uuid-devel libgcrypt-devel libgnutls-devel libmysqlclient-devel libdbi-devel postgresql-devel net-snmp-devel libdbi-drivers-dbd-mysql json-c zlib-dev libdbi
```

View File

@ -111,6 +111,8 @@
#include "parserif.h"
#include "statsobj.h"
#pragma GCC diagnostic ignored "-Wswitch-enum"
#define NO_TIME_PROVIDED 0 /* indicate we do not provide any cached time */
/* forward definitions */
@ -197,6 +199,29 @@ static struct cnfparamblk pblk =
cnfparamdescr
};
/* primarily a helper for debug purposes, get human-readble name of state */
/* currently not needed, but may be useful in the future!
static const char *
batchState2String(const batch_state_t state)
{
switch(state) {
case BATCH_STATE_RDY:
return "BATCH_STATE_RDY";
case BATCH_STATE_BAD:
return "BATCH_STATE_BAD";
case BATCH_STATE_SUB:
return "BATCH_STATE_SUB";
case BATCH_STATE_COMM:
return "BATCH_STATE_COMM";
case BATCH_STATE_DISC:
return "BATCH_STATE_DISC";
default:
return "ERROR, batch state not known!";
}
}
*/
/* ------------------------------ methods ------------------------------ */
/* This function returns the "current" time for this action. Current time
@ -221,7 +246,7 @@ static struct cnfparamblk pblk =
* because that would provide little to no benefit but complicate things
* a lot. So we simply return the system time.
*/
static inline time_t
static time_t
getActNow(action_t * const pThis)
{
assert(pThis != NULL);
@ -642,7 +667,7 @@ static void actionRetry(action_t * const pThis, wti_t * const pWti)
* CPU time. TODO: maybe a config option for that?
* rgerhards, 2007-08-02
*/
static inline void
static void
actionSuspend(action_t * const pThis, wti_t * const pWti)
{
time_t ttNow;
@ -716,12 +741,14 @@ actionDoRetry(action_t * const pThis, wti_t * const pWti)
iRetries = 0;
while((*pWti->pbShutdownImmediate == 0) && getActionState(pWti, pThis) == ACT_STATE_RTRY) {
DBGPRINTF("actionDoRetry: %s enter loop, iRetries=%d\n", pThis->pszName, iRetries);
DBGPRINTF("actionDoRetry: %s enter loop, iRetries=%d, ResumeInRow %d\n",
pThis->pszName, iRetries, getActionResumeInRow(pWti, pThis));
iRet = pThis->pMod->tryResume(pWti->actWrkrInfo[pThis->iActionNbr].actWrkrData);
DBGPRINTF("actionDoRetry: %s action->tryResume returned %d\n", pThis->pszName, iRet);
if((getActionResumeInRow(pWti, pThis) > 9) && (getActionResumeInRow(pWti, pThis) % 10 == 0)) {
bTreatOKasSusp = 1;
setActionResumeInRow(pWti, pThis, 0);
iRet = RS_RET_SUSPENDED;
} else {
bTreatOKasSusp = 0;
}
@ -844,7 +871,7 @@ finalize_it:
* depending on its current state.
* rgerhards, 2009-05-07
*/
static inline rsRetVal
static rsRetVal
actionPrepare(action_t *__restrict__ const pThis, wti_t *__restrict__ const pWti)
{
DEFiRet;
@ -1058,21 +1085,16 @@ handleActionExecResult(action_t *__restrict__ const pThis,
pThis->bHadAutoCommit = 1;
actionSetActionWorked(pThis, pWti); /* we had a successful call! */
break;
case RS_RET_SUSPENDED:
actionRetry(pThis, pWti);
break;
case RS_RET_DISABLE_ACTION:
actionDisable(pThis);
break;
default:/* permanent failure of this message - no sense in retrying. This is
* not yet handled (but easy TODO)
*/
iRet = ret;
FINALIZE;
case RS_RET_SUSPENDED:
default:/* error happened - if it hits us here, we treat it as suspension */
actionRetry(pThis, pWti);
break;
}
iRet = getReturnCode(pThis, pWti);
finalize_it:
RETiRet;
}
@ -1133,7 +1155,7 @@ actionCallCommitTransaction(action_t * const pThis,
* this readies the action and then calls doAction()
* rgerhards, 2008-01-28
*/
rsRetVal
static rsRetVal
actionProcessMessage(action_t * const pThis, void *actParams, wti_t * const pWti)
{
DEFiRet;
@ -1174,6 +1196,8 @@ doTransaction(action_t *__restrict__ const pThis, wti_t *__restrict__ const pWti
}
}
finalize_it:
if(iRet == RS_RET_DEFER_COMMIT || iRet == RS_RET_PREVIOUS_COMMITTED)
iRet = RS_RET_OK; /* this is expected for transactional action! */
RETiRet;
}
@ -1184,9 +1208,10 @@ actionTryCommit(action_t *__restrict__ const pThis, wti_t *__restrict__ const pW
{
DEFiRet;
doTransaction(pThis, pWti);
CHKiRet(actionPrepare(pThis, pWti));
CHKiRet(doTransaction(pThis, pWti));
if(getActionState(pWti, pThis) == ACT_STATE_ITX) {
iRet = pThis->pMod->mod.om.endTransaction(pWti->actWrkrInfo[pThis->iActionNbr].actWrkrData);
switch(iRet) {
@ -1221,6 +1246,26 @@ finalize_it:
RETiRet;
}
/* If a transcation failed, we write the error file (if configured).
* TODO: implement
*/
static void
actionWriteErrorFile(action_t *__restrict__ const pThis, wti_t *__restrict__ const pWti)
{
unsigned i;
actWrkrInfo_t *const wrkrInfo = &(pWti->actWrkrInfo[pThis->iActionNbr]);
const unsigned nMsgs = wrkrInfo->p.tx.currIParam;
DBGPRINTF("action %d commit failed, writing %u messages to error file\n",
pThis->iActionNbr, nMsgs);
for(i = 0 ; i < nMsgs ; ++i) {
// TODO: get actual param count!
dbgprintf("msg %d: '%s'\n", i,
actParam(wrkrInfo->p.tx.iparams, 1, i, 0).param);
}
}
/* Note: we currently need to return an iRet, as this is used in
* direct mode. TODO: However, it may be worth further investigating this,
* as it looks like there is no ultimate consumer of this code.
@ -1255,11 +1300,21 @@ actionCommit(action_t *__restrict__ const pThis, wti_t *__restrict__ const pWti)
bDone = 0;
do {
iRet = actionTryCommit(pThis, pWti);
DBGPRINTF("actionCommit, in retry loop, iRet %d\n", iRet);
DBGPRINTF("actionCommit, action %d, in retry loop, iRet %d\n",
pThis->iActionNbr, iRet);
if(iRet == RS_RET_FORCE_TERM) {
ABORT_FINALIZE(RS_RET_FORCE_TERM);
} else if(iRet == RS_RET_SUSPENDED) {
iRet = actionDoRetry(pThis, pWti);
if(iRet == RS_RET_FORCE_TERM) {
ABORT_FINALIZE(RS_RET_FORCE_TERM);
} else if(iRet != RS_RET_OK) {
actionWriteErrorFile(pThis, pWti);
bDone = 1;
}
continue;
} else if(iRet == RS_RET_OK ||
iRet == RS_RET_SUSPENDED ||
iRet == RS_RET_SUSPENDED ||
iRet == RS_RET_ACTION_FAILED) {
bDone = 1;
}
@ -1284,7 +1339,7 @@ actionCommitAllDirect(wti_t *__restrict__ const pWti)
pAction = pWti->actWrkrInfo[i].pAction;
if(pAction == NULL)
continue;
DBGPRINTF("actionCommitAll: action %d, state %u, nbr to commit %d "
DBGPRINTF("actionCommitAllDirect: action %d, state %u, nbr to commit %d "
"isTransactional %d\n",
i, getActionStateByNbr(pWti, i), pWti->actWrkrInfo->p.tx.currIParam,
pAction->isTransactional);
@ -1868,7 +1923,7 @@ resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unus
/* initialize (current) config variables.
* Used at program start and when a new scope is created.
*/
static inline void
static void
initConfigVariables(void)
{
cs.bActionWriteAllMarkMsgs = 1;

View File

@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT([rsyslog],[8.20.0.master],[rsyslog@lists.adiscon.com])
AC_INIT([rsyslog],[8.23.0.master],[rsyslog@lists.adiscon.com])
AM_INIT_AUTOMAKE([subdir-objects])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
@ -22,6 +22,24 @@ AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_CANONICAL_HOST
m4_ifdef([AX_IS_RELEASE], [
AX_IS_RELEASE([git-directory])
m4_ifdef([AX_COMPILER_FLAGS], [
AX_COMPILER_FLAGS()
], [
if test "$GCC" = "yes"
then CFLAGS="$CFLAGS -W -Wall -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute -g"
fi
AC_MSG_WARN([missing AX_COMPILER_FLAGS macro, not using it])
])
], [
if test "$GCC" = "yes"
then CFLAGS="$CFLAGS -W -Wall -Wformat-security -Wshadow -Wcast-align -Wpointer-arith -Wmissing-format-attribute -g"
fi
AC_MSG_WARN([missing AX_IS_RELEASE macro, not using AX_COMPILER_FLAGS macro because of this])
])
PKG_PROG_PKG_CONFIG
# modules we require
@ -61,6 +79,10 @@ case "${host}" in
;;
esac
# Running from git source?
in_git_src=no
AS_IF([test -d "$srcdir"/.git && ! test -f "$srcdir"/.tarball-version], [in_git_src=yes])
AC_DEFINE_UNQUOTED([HOSTENV], "$host", [the host environment, can be queried via a system variable])
# Checks for libraries.
@ -294,10 +316,14 @@ AC_CHECK_LIB(
[1],
[Can set thread-name.])])
AC_CHECK_FUNCS(
AC_SEARCH_LIBS(
[pthread_setschedparam],
[pthread],
[
rsyslog_have_pthread_setschedparam=yes
AC_DEFINE([HAVE_PTHREAD_SETSCHEDPARAM],
[1],
[Can set thread scheduling parameters])
],
[
rsyslog_have_pthread_setschedparam=no
@ -435,14 +461,23 @@ AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_sy
# debug
AC_ARG_ENABLE(debug,
[AS_HELP_STRING([--enable-debug],[Enable debug mode @<:@default=no@:>@])],
[AS_HELP_STRING([--enable-debug],[Enable debug mode @<:@default=auto@:>@])],
[case "${enableval}" in
yes) enable_debug="yes" ;;
no) enable_debug="no" ;;
yes) enable_debug="yes" ;;
no) enable_debug="no" ;;
auto) enable_debug="auto" ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
esac],
[enable_debug="no"]
[enable_debug="auto"]
)
if test "$enable_debug" = "auto"; then
if test "x$in_git_src" = "xyes"; then
enable_debug="yes"
else
enable_debug="no"
fi
AC_MSG_NOTICE([enable-debug in auto mode, enable-debug is set to ${enable_debug}])
fi
if test "$enable_debug" = "yes"; then
AC_DEFINE(DEBUG, 1, [Defined if debug mode is enabled (its easier to check).])
fi
@ -831,6 +866,7 @@ if test "$GCC" = "yes"; then
RSRT_CFLAGS="$RSRT_CFLAGS -g"
fi
fi
RSRT_CFLAGS="$RSRT_CFLAGS $WARN_CFLAGS"
RSRT_LIBS="\$(RSRT_LIBS1) \$(LIBESTR_LIBS) \$(JSON_C_LIBS)"
AC_SUBST(RSRT_CFLAGS1)
AC_SUBST(RSRT_LIBS1)
@ -885,6 +921,23 @@ AC_ARG_ENABLE(mysql_tests,
AM_CONDITIONAL(ENABLE_MYSQL_TESTS, test x$enable_mysql_tests = xyes)
# capability to enable PostgreSQL testbench tests. This requries that a Syslog database
# with the default schema (see plugins/ompgsql/createDB.sql) has been created on the
# local (127.0.0.1) PostgreSQL server and a user "rsyslog" with password "testbench"
# exists, is able to login with default parameters and has sufficient (read: all)
# privileges on that database
AC_ARG_ENABLE(pgsql_tests,
[AS_HELP_STRING([--enable-pgsql-tests],[enable PostgreSQL specific tests in testbench @<:@default=no@:>@])],
[case "${enableval}" in
yes) enable_pgsql_tests="yes" ;;
no) enable_pgsql_tests="no" ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-pgsql-tests) ;;
esac],
[enable_pgsql_tests=no]
)
AM_CONDITIONAL(ENABLE_PGSQL_TESTS, test x$enable_pgsql_tests = xyes)
# Mail support (so far we do not need a library, but we need to turn this on and off)
AC_ARG_ENABLE(mail,
[AS_HELP_STRING([--enable-mail],[Enable mail support @<:@default=no@:>@])],
@ -1093,7 +1146,8 @@ AC_ARG_ENABLE(relp,
[enable_relp=no]
)
if test "x$enable_relp" = "xyes"; then
PKG_CHECK_MODULES(RELP, relp >= 1.2.5)
PKG_CHECK_MODULES(RELP, relp >= 1.2.12)
AC_DEFINE([ENABLE_RELP], [1], [Indicator that RELP is present])
fi
AM_CONDITIONAL(ENABLE_RELP, test x$enable_relp = xyes)
@ -1761,10 +1815,6 @@ AC_ARG_ENABLE(distcheck-workaround,
AM_CONDITIONAL(ENABLE_DISTCHECK_WORKAROUND, test x$enable_distcheck_workaround = xyes)
# Running from git source?
in_git_src=no
AS_IF([test -d "$srcdir"/.git && ! test -f "$srcdir"/.tarball-version], [in_git_src=yes])
if test "x$in_git_src" = "xyes"; then
AC_MSG_NOTICE([Running from git source])
@ -1948,6 +1998,7 @@ echo "---{ debugging support }---"
echo " Testbench enabled: $enable_testbench"
echo " Extended Testbench enabled: $enable_extended_tests"
echo " MySQL Tests enabled: $enable_mysql_tests"
echo " PostgreSQL Tests enabled: $enable_pgsql_tests"
echo " Kafka Tests enabled: $enable_kafka_tests"
echo " Debug mode enabled: $enable_debug"
echo " Runtime Instrumentation enabled: $enable_rtinst"

View File

@ -161,8 +161,8 @@ setInstParamDefaults(instanceData *pData)
pData->valueFrom = 0;
pData->valueTo = INT_MAX;
pData->step = 1;
pData->pszKey = "";
pData->pszVar = JSON_VAR_NAME;
pData->pszKey = (char*)"";
pData->pszVar = (char*)JSON_VAR_NAME;
}
BEGINnewActInst

View File

@ -120,7 +120,7 @@ typedef struct _instanceData {
} instanceData;
typedef struct wrkrInstanceData {
instanceData *pData;
instanceData *pData;
} wrkrInstanceData_t;
@ -825,9 +825,25 @@ static void *amqp1_thread(void *arg)
while (!ps->stopped) {
// setup a connection:
ps->conn = pn_reactor_connection(ps->reactor, handler);
const char *host = pn_url_get_host(cfg->url);
const char *port = pn_url_get_port(cfg->url);
if (!port) port = "5672";
#if PN_VERSION_MAJOR == 0 && PN_VERSION_MINOR >= 13
ps->conn = pn_reactor_connection_to_host(ps->reactor,
host,
port,
handler);
pn_connection_set_hostname(ps->conn, host);
#else
{
char host_addr[300];
ps->conn = pn_reactor_connection(ps->reactor, handler);
snprintf(host_addr, sizeof(host_addr), "%s:%s", host, port);
pn_connection_set_hostname(ps->conn, host_addr);
}
#endif
pn_connection_set_container(ps->conn, "rsyslogd-omamqp1");
pn_connection_set_hostname(ps->conn, pn_url_get_host(cfg->url));
#if PN_VERSION_MAJOR == 0 && PN_VERSION_MINOR >= 10
// proton version <= 0.9 did not support Cyrus SASL

View File

@ -69,7 +69,6 @@ typedef struct _instanceData {
typedef struct wrkrInstanceData {
instanceData *pData; /* instanc data */
redisContext *conn; /* redis connection */
redisReply **replies; /* array to hold replies from redis */
int count; /* count of command sent for current batch */
} wrkrInstanceData_t;
@ -112,8 +111,7 @@ static void closeHiredis(wrkrInstanceData_t *pWrkrData)
}
}
/* Free our instance data.
* TODO: free **replies */
/* Free our instance data. */
BEGINfreeInstance
CODESTARTfreeInstance
if (pData->server != NULL) {
@ -248,14 +246,22 @@ ENDdoAction
BEGINendTransaction
CODESTARTendTransaction
dbgprintf("omhiredis: endTransaction called\n");
redisReply *reply;
int i;
pWrkrData->replies = malloc ( sizeof ( redisReply* ) * pWrkrData->count );
for ( i = 0; i < pWrkrData->count; i++ ) {
redisGetReply ( pWrkrData->conn, (void *)&pWrkrData->replies[i] );
/* TODO: add error checking here! */
freeReplyObject ( pWrkrData->replies[i] );
redisGetReply ( pWrkrData->conn, (void*)&reply);
if( pWrkrData->conn->err ){
dbgprintf("omhiredis: %s\n", pWrkrData->conn->errstr);
closeHiredis(pWrkrData);
ABORT_FINALIZE(RS_RET_SUSPENDED);
}
else {
freeReplyObject(reply);
}
}
free ( pWrkrData->replies );
finalize_it:
RETiRet;
ENDendTransaction
/* set defaults. note server is set to NULL

View File

@ -188,7 +188,7 @@ httpfs_init_curl(wrkrInstanceData_t *pWrkrData, instanceData *pData)
* @return rsRetVal
*/
static rsRetVal
httpfs_build_url(wrkrInstanceData_t *pWrkrData, char* op, es_str_t** url_buf)
httpfs_build_url(wrkrInstanceData_t *pWrkrData, const char* op, es_str_t** url_buf)
{
*url_buf = es_newStr(HTTPFS_URL_BUFFER_LENGTH);
@ -234,7 +234,7 @@ httpfs_build_url(wrkrInstanceData_t *pWrkrData, char* op, es_str_t** url_buf)
* @param char* op
* @return void
*/
void httpfs_set_url(wrkrInstanceData_t *pWrkrData, char* op)
static void httpfs_set_url(wrkrInstanceData_t *pWrkrData, const char* op)
{
es_str_t* url;
char* url_cstr;
@ -250,7 +250,7 @@ void httpfs_set_url(wrkrInstanceData_t *pWrkrData, char* op)
* @param CURL* curl
* @return void
*/
void httpfs_curl_set_put(CURL* curl)
static void httpfs_curl_set_put(CURL* curl)
{
curl_easy_setopt(curl, CURLOPT_HTTPGET, 0L);
curl_easy_setopt(curl, CURLOPT_NOBODY, 0L);
@ -260,29 +260,13 @@ void httpfs_curl_set_put(CURL* curl)
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
}
/**
* Set http method to GET
*
* @param CURL* curl
* @return void
*/
void httpfs_curl_set_get(CURL* curl)
{
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
curl_easy_setopt(curl, CURLOPT_NOBODY, 0L);
curl_easy_setopt(curl, CURLOPT_POST, 0L);
curl_easy_setopt(curl, CURLOPT_PUT, 0L);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 0L);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "GET");
}
/**
* Set http method to POST
*
* @param CURL* curl
* @return void
*/
void httpfs_curl_set_post(CURL* curl)
static void httpfs_curl_set_post(CURL* curl)
{
curl_easy_setopt(curl, CURLOPT_HTTPGET, 0L);
curl_easy_setopt(curl, CURLOPT_NOBODY, 0L);
@ -301,7 +285,7 @@ void httpfs_curl_set_post(CURL* curl)
* @param ...
* @return struct curl_slist*
*/
struct curl_slist*
static struct curl_slist*
httpfs_curl_add_header(struct curl_slist* headers, int hdr_count, ...)
{
const char* hdr;
@ -405,18 +389,6 @@ httpfs_curl_result_callback(void *contents, size_t size, size_t nmemb, void *use
return -1; \
}
/**
* convert integer permission to string
*
* @param int permission
* @param char* perm_string
* @return int
*/
int httpfs_permission_to_string(int permission, char* perm_string)
{
return sprintf(perm_string, "%04o", permission);
}
/**
* Parse remote exception json string
*

View File

@ -1,7 +1,7 @@
/* pmaixforwardedfrom.c
*
* this cleans up messages forwarded from AIX
*
*
* instead of actually parsing the message, this modifies the message and then falls through to allow a later parser to handle the now modified message
*
* created 2010-12-13 by David Lang based on pmlastmsg
@ -11,11 +11,11 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* -or-
* see COPYING.ASL20 in the source distribution
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -68,7 +68,9 @@ ENDisCompatibleWithFeature
BEGINparse
uchar *p2parse;
int lenMsg;
int skipLen = 0;
#define OpeningText "Message forwarded from "
#define OpeningText2 "From "
CODESTARTparse
dbgprintf("Message will now be parsed by fix AIX Forwarded From parser.\n");
assert(pMsg != NULL);
@ -82,28 +84,34 @@ CODESTARTparse
--lenMsg;
++p2parse;
}
if((unsigned) lenMsg < 42) {
if((unsigned) lenMsg < 24) {
/* too short, can not be "our" message */
/* minimum message, 16 character timestamp, 'Message forwarded from ", 1 character name, ': '*/
/* minimum message, 16 character timestamp, 'From ", 1 character name, ': '*/
ABORT_FINALIZE(RS_RET_COULD_NOT_PARSE);
}
/* skip over timestamp */
lenMsg -=16;
p2parse +=16;
/* if there is the string "Message forwarded from " were the hostname should be */
if(strncasecmp((char*) p2parse, OpeningText, sizeof(OpeningText)-1) != 0) {
/* if there is the string "Message forwarded from " were the hostname should be */
if(!strncasecmp((char*) p2parse, OpeningText, sizeof(OpeningText)-1))
skipLen = 23;
/* or "From " */
if(!strncasecmp((char*) p2parse, OpeningText2, sizeof(OpeningText2)-1))
skipLen = 5;
DBGPRINTF("pmaixforwardedfrom: skipLen %d\n", skipLen);
if(!skipLen) {
/* wrong opening text */
DBGPRINTF("not a AIX message forwarded from mangled log!\n");
ABORT_FINALIZE(RS_RET_COULD_NOT_PARSE);
}
/* bump the message portion up by 23 characters to overwrite the "Message forwarded from " with the hostname */
lenMsg -=23;
memmove(p2parse, p2parse + 23, lenMsg);
/* bump the message portion up by skipLen(23 or 5) characters to overwrite the "Message forwarded from " or "From " with the hostname */
lenMsg -=skipLen;
memmove(p2parse, p2parse + skipLen, lenMsg);
*(p2parse + lenMsg) = '\n';
*(p2parse + lenMsg + 1) = '\0';
pMsg->iLenRawMsg -=23;
pMsg->iLenMSG -=23;
pMsg->iLenRawMsg -=skipLen;
pMsg->iLenMSG -=skipLen;
/* now look for the : after the hostname to walk past the hostname, also watch for a space in case this isn't really an AIX log, but has a similar preamble */
while(lenMsg && *p2parse != ' ' && *p2parse != ':') {
--lenMsg;

View File

@ -8,7 +8,7 @@
* PRI filter) are very hard to beat in ease of use, at least for simpler
* cases.
*
* Copyright 2011-2014 Rainer Gerhards and Adiscon GmbH.
* Copyright 2011-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -27,6 +27,13 @@
* limitations under the License.
*/
%{
/* shut off warnings that we can't change anyhow */
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
#pragma GCC diagnostic ignored "-Wredundant-decls"
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
#pragma GCC diagnostic ignored "-Wswitch-default"
#include "config.h"
#include <stdio.h>
#include <libestr.h>
@ -34,10 +41,11 @@
#include "parserif.h"
#define YYDEBUG 1
extern int yylineno;
extern char *yytext;
/* keep compile rule clean of errors */
extern int yylex(void);
extern int yyerror(char*);
extern int yyerror(const char*);
%}
%union {
@ -175,6 +183,7 @@ stmt: actlst { $$ = $1; }
| PRIFILT block { $$ = cnfstmtNewPRIFILT($1, $2); }
| PROPFILT block { $$ = cnfstmtNewPROPFILT($1, $2); }
| RELOAD_LOOKUP_TABLE_PROCEDURE '(' fparams ')' { $$ = cnfstmtNewReloadLookupTable($3);}
| BEGINOBJ { $$ = NULL; parser_errmsg("declarative object '%s' not permitted in action block [stmt]", yytext);}
block: stmt { $$ = $1; }
| '{' script '}' { $$ = $2; }
actlst: s_act { $$ = $1; }

View File

@ -332,6 +332,16 @@ cnfSetLexFile(char *fname)
int r = 0;
struct bufstack *bs;
/* check for invalid recursive include */
for(bs = currbs ; bs != NULL ; bs = bs->prev) {
if(!strcmp(fname, bs->fn)) {
parser_errmsg("trying to include file '%s', "
"which is already included - ignored", fname);
r = 1;
goto done;
}
}
if(fname == NULL) {
fp = stdin;
} else {

View File

@ -20,10 +20,9 @@
#define PARSERIF_H_DEFINED
#include "rainerscript.h"
int cnfSetLexFile(char*);
int yyparse();
void dbgprintf(char *fmt, ...) __attribute__((format(printf, 1, 2)));
void parser_errmsg(char *fmt, ...) __attribute__((format(printf, 1, 2)));
void parser_warnmsg(char *fmt, ...) __attribute__((format(printf, 1, 2)));
int yyparse(void);
void parser_errmsg(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
void parser_warnmsg(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
void tellLexEndParsing(void);
extern int yydebug;
extern int yylineno;

View File

@ -2,7 +2,7 @@
*
* Module begun 2011-07-01 by Rainer Gerhards
*
* Copyright 2011-2014 Rainer Gerhards and Adiscon GmbH.
* Copyright 2011-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -52,6 +52,8 @@
#include "wti.h"
#include "unicode-helper.h"
#pragma GCC diagnostic ignored "-Wswitch-enum"
DEFobjCurrIf(obj)
DEFobjCurrIf(regexp)
@ -67,10 +69,10 @@ struct cnffunc * cnffuncNew_prifilt(int fac);
* NOTE: This function MUST be updated if new tokens are defined in the
* grammar.
*/
const char *
static const char *
tokenToString(const int token)
{
char *tokstr;
const char *tokstr;
static char tokbuf[512];
switch(token) {
@ -134,7 +136,7 @@ tokenToString(const int token)
const char*
getFIOPName(const unsigned iFIOP)
{
char *pRet;
const char *pRet;
switch(iFIOP) {
case FIOP_CONTAINS:
pRet = "contains";
@ -161,6 +163,67 @@ getFIOPName(const unsigned iFIOP)
return pRet;
}
const char*
cnfFiltType2str(const enum cnfFiltType filttype)
{
switch(filttype) {
case CNFFILT_NONE:
return("filter:none");
case CNFFILT_PRI:
return("filter:pri");
case CNFFILT_PROP:
return("filter:prop");
case CNFFILT_SCRIPT:
return("filter:script");
default:
return("error:invalid_filter_type"); /* should never be reached */
}
}
const char*
cnfobjType2str(const enum cnfobjType ot)
{
switch(ot) {
case CNFOBJ_ACTION:
return "action";
break;
case CNFOBJ_RULESET:
return "ruleset";
break;
case CNFOBJ_GLOBAL:
return "global";
break;
case CNFOBJ_INPUT:
return "input";
break;
case CNFOBJ_MODULE:
return "module";
break;
case CNFOBJ_TPL:
return "template";
break;
case CNFOBJ_PROPERTY:
return "property";
break;
case CNFOBJ_CONSTANT:
return "constant";
break;
case CNFOBJ_MAINQ:
return "main_queue";
case CNFOBJ_LOOKUP_TABLE:
return "lookup_table";
case CNFOBJ_PARSER:
return "parser";
break;
case CNFOBJ_TIMEZONE:
return "timezone";
break;
case CNFOBJ_DYN_STATS:
return "dyn_stats";
break;
default:return "error: invalid cnfobjType";
}
}
/* This function takes the filter part of a property
* based filter and decodes it. It processes the line up to the beginning
@ -576,8 +639,8 @@ nvlstFindName(struct nvlst *lst, es_str_t *name)
* for classical C strings. This is useful because the config system
* uses C string constants.
*/
static inline struct nvlst*
nvlstFindNameCStr(struct nvlst *lst, char *name)
static struct nvlst*
nvlstFindNameCStr(struct nvlst *lst, const char *const __restrict__ name)
{
es_size_t lenName = strlen(name);
while(lst != NULL && es_strcasebufcmp(lst->name, (uchar*)name, lenName))
@ -589,7 +652,7 @@ nvlstFindNameCStr(struct nvlst *lst, char *name)
/* check if there are duplicate names inside a nvlst and emit
* an error message, if so.
*/
static inline void
static void
nvlstChkDupes(struct nvlst *lst)
{
char *cstr;
@ -630,7 +693,7 @@ nvlstChkUnused(struct nvlst *lst)
}
static inline int
static int
doGetSize(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -681,7 +744,7 @@ doGetSize(struct nvlst *valnode, struct cnfparamdescr *param,
}
static inline int
static int
doGetBinary(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -700,7 +763,7 @@ doGetBinary(struct nvlst *valnode, struct cnfparamdescr *param,
return r;
}
static inline int
static int
doGetQueueType(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -729,7 +792,7 @@ doGetQueueType(struct nvlst *valnode, struct cnfparamdescr *param,
/* A file create-mode must be a four-digit octal number
* starting with '0'.
*/
static inline int
static int
doGetFileCreateMode(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -761,7 +824,7 @@ doGetFileCreateMode(struct nvlst *valnode, struct cnfparamdescr *param,
return fmtOK;
}
static inline int
static int
doGetGID(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -788,7 +851,7 @@ doGetGID(struct nvlst *valnode, struct cnfparamdescr *param,
return r;
}
static inline int
static int
doGetUID(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -818,7 +881,7 @@ doGetUID(struct nvlst *valnode, struct cnfparamdescr *param,
/* note: we support all integer formats that es_str2num support,
* so hex and octal representations are also valid.
*/
static inline int
static int
doGetInt(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -835,7 +898,7 @@ doGetInt(struct nvlst *valnode, struct cnfparamdescr *param,
return bSuccess;
}
static inline int
static int
doGetNonNegInt(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -851,7 +914,7 @@ doGetNonNegInt(struct nvlst *valnode, struct cnfparamdescr *param,
return bSuccess;
}
static inline int
static int
doGetPositiveInt(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -867,7 +930,7 @@ doGetPositiveInt(struct nvlst *valnode, struct cnfparamdescr *param,
return bSuccess;
}
static inline int
static int
doGetWord(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -890,7 +953,7 @@ doGetWord(struct nvlst *valnode, struct cnfparamdescr *param,
return r;
}
static inline int
static int
doGetArray(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -914,7 +977,7 @@ doGetArray(struct nvlst *valnode, struct cnfparamdescr *param,
return r;
}
static inline int
static int
doGetChar(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -933,7 +996,7 @@ doGetChar(struct nvlst *valnode, struct cnfparamdescr *param,
/* get a single parameter according to its definition. Helper to
* nvlstGetParams. returns 1 if success, 0 otherwise
*/
static inline int
static int
nvlstGetParam(struct nvlst *valnode, struct cnfparamdescr *param,
struct cnfparamvals *val)
{
@ -1203,7 +1266,7 @@ done:
}
static inline int64_t
static int64_t
str2num(es_str_t *s, int *bSuccess)
{
size_t i;
@ -1259,7 +1322,7 @@ static es_str_t *
var2String(struct var *__restrict__ const r, int *__restrict__ const bMustFree)
{
es_str_t *estr;
char *cstr;
const char *cstr;
rs_size_t lenstr;
if(r->datatype == 'N') {
*bMustFree = 1;
@ -1419,7 +1482,7 @@ finalize_it:
RETiRet;
}
static inline void
static void
doFunc_re_extract(struct cnffunc *func, struct var *ret, void* usrptr)
{
size_t submatchnbr;
@ -1540,7 +1603,7 @@ doFunc_exec_template(struct cnffunc *__restrict__ const func,
return;
}
static inline es_str_t*
static es_str_t*
doFuncReplace(struct var *__restrict__ const operandVal, struct var *__restrict__ const findVal, struct var *__restrict__ const replaceWithVal) {
int freeOperand, freeFind, freeReplacement;
es_str_t *str = var2String(operandVal, &freeOperand);
@ -1597,7 +1660,7 @@ doFuncReplace(struct var *__restrict__ const operandVal, struct var *__restrict_
return res;
}
static inline es_str_t*
static es_str_t*
doFuncWrap(struct var *__restrict__ const sourceVal, struct var *__restrict__ const wrapperVal, struct var *__restrict__ const escaperVal) {
int freeSource, freeWrapper;
es_str_t *sourceStr;
@ -1624,7 +1687,7 @@ doFuncWrap(struct var *__restrict__ const sourceVal, struct var *__restrict__ co
return res;
}
static inline long long
static long long
doRandomGen(struct var *__restrict__ const sourceVal) {
int success = 0;
long long max = var2Number(sourceVal, &success);
@ -1648,7 +1711,7 @@ doRandomGen(struct var *__restrict__ const sourceVal) {
/* Perform a function call. This has been moved out of cnfExprEval in order
* to keep the code small and easier to maintain.
*/
static inline void
static void
doFuncCall(struct cnffunc *__restrict__ const func, struct var *__restrict__ const ret,
void *__restrict__ const usrptr)
{
@ -1878,7 +1941,7 @@ doFuncCall(struct cnffunc *__restrict__ const func, struct var *__restrict__ con
}
}
static inline void
static void
evalVar(struct cnfvar *__restrict__ const var, void *__restrict__ const usrptr,
struct var *__restrict__ const ret)
{
@ -2500,7 +2563,7 @@ cnfarrayContentDestruct(struct cnfarray *ar)
free(ar->arr);
}
static inline void
static void
cnffuncDestruct(struct cnffunc *func)
{
unsigned short i;
@ -3310,7 +3373,7 @@ getConstNumber(struct cnfexpr *expr, long long *l, long long *r)
/* constant folding for string concatenation */
static inline void
static void
constFoldConcat(struct cnfexpr *expr)
{
es_str_t *estr;
@ -3363,7 +3426,7 @@ constFoldConcat(struct cnfexpr *expr)
/* optimize comparisons with syslog severity/facility. This is a special
* handler as the numerical values also support GT, LT, etc ops.
*/
static inline struct cnfexpr*
static struct cnfexpr*
cnfexprOptimize_CMP_severity_facility(struct cnfexpr *expr)
{
struct cnffunc *func;
@ -3408,7 +3471,7 @@ finalize_it:
* NOTE: Currently support CMP_EQ, CMP_NE only and code NEEDS
* TO BE CHANGED fgr other comparisons!
*/
static inline struct cnfexpr*
static struct cnfexpr*
cnfexprOptimize_CMP_var(struct cnfexpr *expr)
{
struct cnffunc *func;
@ -3454,7 +3517,7 @@ cnfexprOptimize_CMP_var(struct cnfexpr *expr)
return expr;
}
static inline struct cnfexpr*
static struct cnfexpr*
cnfexprOptimize_NOT(struct cnfexpr *expr)
{
struct cnffunc *func;
@ -3472,7 +3535,7 @@ cnfexprOptimize_NOT(struct cnfexpr *expr)
return expr;
}
static inline struct cnfexpr*
static struct cnfexpr*
cnfexprOptimize_AND_OR(struct cnfexpr *expr)
{
struct cnffunc *funcl, *funcr;
@ -3616,7 +3679,7 @@ cnfexprOptimize(struct cnfexpr *expr)
/* removes NOPs from a statement list and returns the
* first non-NOP entry.
*/
static inline struct cnfstmt *
static struct cnfstmt *
removeNOPs(struct cnfstmt *root)
{
struct cnfstmt *stmt, *toDel, *prevstmt = NULL;
@ -3644,7 +3707,7 @@ removeNOPs(struct cnfstmt *root)
done: return newRoot;
}
static inline void
static void
cnfstmtOptimizeForeach(struct cnfstmt *stmt)
{
stmt->d.s_foreach.iter->collection = cnfexprOptimize(stmt->d.s_foreach.iter->collection);
@ -3653,7 +3716,7 @@ cnfstmtOptimizeForeach(struct cnfstmt *stmt)
}
static inline void
static void
cnfstmtOptimizeIf(struct cnfstmt *stmt)
{
struct cnfstmt *t_then, *t_else;
@ -3690,7 +3753,7 @@ cnfstmtOptimizeIf(struct cnfstmt *stmt)
}
}
static inline void
static void
cnfstmtOptimizeAct(struct cnfstmt *stmt)
{
action_t *pAct;
@ -3877,7 +3940,7 @@ static const char* const numInWords[] = {"zero", "one", "two", "three", "four",
/* Obtain function id from name AND number of params. Issues the
* relevant error messages if errors are detected.
*/
static inline enum cnffuncid
static enum cnffuncid
funcName2ID(es_str_t *fname, unsigned short nParams)
{
if(FUNC_NAME("strlen")) {
@ -3924,7 +3987,7 @@ funcName2ID(es_str_t *fname, unsigned short nParams)
}
static inline rsRetVal
static rsRetVal
initFunc_re_match(struct cnffunc *func)
{
rsRetVal localRet;
@ -3998,7 +4061,7 @@ finalize_it:
}
static inline rsRetVal
static rsRetVal
initFunc_prifilt(struct cnffunc *func)
{
struct funcData_prifilt *pData;
@ -4027,7 +4090,7 @@ finalize_it:
}
static inline rsRetVal
static rsRetVal
resolveLookupTable(struct cnffunc *func)
{
uchar *cstr = NULL;
@ -4062,7 +4125,7 @@ finalize_it:
RETiRet;
}
static inline rsRetVal
static rsRetVal
initFunc_dyn_stats(struct cnffunc *func)
{
uchar *cstr = NULL;
@ -4291,7 +4354,7 @@ cnfparamvalsDestruct(const struct cnfparamvals *paramvals, const struct cnfparam
* stage the (considerable!) extra overhead is OK. -- rgerhards, 2011-07-19
*/
int
cnfparamGetIdx(struct cnfparamblk *params, char *name)
cnfparamGetIdx(struct cnfparamblk *params, const char *name)
{
int i;
for(i = 0 ; i < params->nParams ; ++i)
@ -4304,7 +4367,7 @@ cnfparamGetIdx(struct cnfparamblk *params, char *name)
void
cstrPrint(char *text, es_str_t *estr)
cstrPrint(const char *text, es_str_t *estr)
{
char *str;
str = es_str2cstr(estr, NULL);
@ -4343,7 +4406,7 @@ isodigit(uchar c)
* @param[in] c a character containing 0..9, A..Z, a..z anything else
* is an (undetected) error.
*/
static inline int
static int
hexDigitVal(char c)
{
int r;
@ -4359,7 +4422,7 @@ hexDigitVal(char c)
/* Handle the actual unescaping.
* a helper to unescapeStr(), to help make the function easier to read.
*/
static inline void
static void
doUnescape(unsigned char *c, int len, int *iSrc, int iDst)
{
if(c[*iSrc] == '\\') {
@ -4469,8 +4532,8 @@ unescapeStr(uchar *s, int len)
}
}
char *
tokenval2str(int tok)
const char *
tokenval2str(const int tok)
{
if(tok < 256) return "";
switch(tok) {

View File

@ -1,6 +1,6 @@
/* rsyslog rainerscript definitions
*
* Copyright 2011-2014 Rainer Gerhards
* Copyright 2011-2016 Rainer Gerhards
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -32,8 +32,6 @@
* others, this is used to size data structures).
*/
extern int Debug; /* 1 if in debug mode, 0 otherwise -- to be enhanced */
enum cnfobjType {
CNFOBJ_ACTION,
CNFOBJ_RULESET,
@ -51,46 +49,7 @@ enum cnfobjType {
CNFOBJ_INVALID = 0
};
static inline char*
cnfobjType2str(enum cnfobjType ot)
{
switch(ot) {
case CNFOBJ_ACTION:
return "action";
break;
case CNFOBJ_RULESET:
return "ruleset";
break;
case CNFOBJ_GLOBAL:
return "global";
break;
case CNFOBJ_INPUT:
return "input";
break;
case CNFOBJ_MODULE:
return "module";
break;
case CNFOBJ_TPL:
return "template";
break;
case CNFOBJ_PROPERTY:
return "property";
break;
case CNFOBJ_CONSTANT:
return "constant";
break;
case CNFOBJ_MAINQ:
return "main_queue";
case CNFOBJ_LOOKUP_TABLE:
return "lookup_table";
case CNFOBJ_DYN_STATS:
return "dyn_stats";
break;
default:return "error: invalid cnfobjType";
}
}
enum cnfactType { CNFACT_V2, CNFACT_LEGACY };
const char* cnfobjType2str(enum cnfobjType ot);
/* a variant type, for example used for expression evaluation
* 2011-07-15/rger: note that there exists a "legacy" object var_t,
@ -160,21 +119,7 @@ struct nvlst {
#define S_RELOAD_LOOKUP_TABLE 4010
enum cnfFiltType { CNFFILT_NONE, CNFFILT_PRI, CNFFILT_PROP, CNFFILT_SCRIPT };
static inline char*
cnfFiltType2str(enum cnfFiltType filttype)
{
switch(filttype) {
case CNFFILT_NONE:
return("filter:none");
case CNFFILT_PRI:
return("filter:pri");
case CNFFILT_PROP:
return("filter:prop");
case CNFFILT_SCRIPT:
return("filter:script");
}
return("error:invalid_filter_type"); /* should never be reached */
}
const char* cnfFiltType2str(const enum cnfFiltType filttype);
struct cnfstmt {
@ -312,7 +257,7 @@ struct x {
* to care.
*/
struct cnfparamdescr { /* first the param description */
char *name; /**< not a es_str_t to ease definition in code */
const char *name;/**< not a es_str_t to ease definition in code */
ecslCmdHdrlType type;
unsigned flags;
};
@ -368,7 +313,7 @@ struct cnfvar* cnfvarNew(char *name);
struct cnffunc * cnffuncNew(es_str_t *fname, struct cnffparamlst* paramlst);
struct cnffparamlst * cnffparamlstNew(struct cnfexpr *expr, struct cnffparamlst *next);
int cnfDoInclude(char *name);
int cnfparamGetIdx(struct cnfparamblk *params, char *name);
int cnfparamGetIdx(struct cnfparamblk *params, const char *name);
struct cnfparamvals* nvlstGetParams(struct nvlst *lst, struct cnfparamblk *params,
struct cnfparamvals *vals);
void cnfparamsPrint(const struct cnfparamblk *params, const struct cnfparamvals *vals);
@ -400,8 +345,8 @@ void cnfarrayContentDestruct(struct cnfarray *ar);
const char* getFIOPName(unsigned iFIOP);
rsRetVal initRainerscript(void);
void unescapeStr(uchar *s, int len);
char * tokenval2str(int tok);
const char * tokenval2str(int tok);
/* debug helper */
void cstrPrint(char *text, es_str_t *estr);
void cstrPrint(const char *text, es_str_t *estr);
#endif

View File

@ -26,7 +26,7 @@ use IO::Select;
# skeleton config parameters
my $maxAtOnce = 1024; # max nbr of messages that are processed within one batch
my $pollPeriod = 10; #timeout
# App logic global variables
my $OUTFILE; # Output Filehandle

View File

@ -196,7 +196,7 @@ getFirstWord(uchar **ppszSrc, uchar *pszBuf, size_t lenBuf, int options)
* rgerhards, 2009-05-27
*/
static rsRetVal __attribute__((format(printf, 2, 3)))
sendResponse(tcps_sess_t *pSess, char *fmt, ...)
sendResponse(tcps_sess_t *pSess, const char *const __restrict__ fmt, ...)
{
va_list ap;
ssize_t len;

View File

@ -5,7 +5,7 @@
*
* Work originally begun on 2008-02-01 by Rainer Gerhards
*
* Copyright 2008-2015 Adiscon GmbH.
* Copyright 2008-2016 Adiscon GmbH.
*
* This file is part of rsyslog.
*
@ -34,6 +34,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <glob.h>
#include <poll.h>
#include <fnmatch.h>
#ifdef HAVE_SYS_INOTIFY_H
#include <sys/inotify.h>
@ -50,7 +51,6 @@
#include "stream.h"
#include "errmsg.h"
#include "glbl.h"
#include "datetime.h"
#include "unicode-helper.h"
#include "prop.h"
#include "stringbuf.h"
@ -69,7 +69,6 @@ MODULE_CNFNAME("imfile")
DEF_IMOD_STATIC_DATA /* must be present, starts static data */
DEFobjCurrIf(errmsg)
DEFobjCurrIf(glbl)
DEFobjCurrIf(datetime)
DEFobjCurrIf(strm)
DEFobjCurrIf(prop)
DEFobjCurrIf(ruleset)
@ -99,6 +98,7 @@ typedef struct lstn_s {
uchar *pszTag;
size_t lenTag;
uchar *pszStateFile; /* file in which state between runs is to be stored (dynamic if NULL) */
int readTimeout;
int iFacility;
int iSeverity;
int maxLinesAtOnce;
@ -147,6 +147,7 @@ struct instanceConf_s {
int iPersistStateInterval;
int iFacility;
int iSeverity;
int readTimeout;
sbool bRMStateOnDel;
uint8_t readMode;
uchar *startRegex;
@ -174,16 +175,19 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
struct modConfData_s {
rsconf_t *pConf; /* our overall config object */
int iPollInterval; /* number of seconds to sleep when there was no file activity */
int readTimeout;
int timeoutGranularity; /* value in ms */
instanceConf_t *root, *tail;
lstn_t *pRootLstn;
lstn_t *pTailLstn;
uint8_t opMode;
sbool configSetViaV2Method;
sbool haveReadTimeouts; /* use special processing if read timeouts exist */
};
static modConfData_t *loadModConf = NULL;/* modConf ptr to use for the current load process */
static modConfData_t *runModConf = NULL;/* modConf ptr to use for the current load process */
#if HAVE_INOTIFY_INIT
#ifdef HAVE_INOTIFY_INIT
/* support for inotify mode */
/* we need to track directories */
@ -236,6 +240,7 @@ struct wd_map_s {
int wd; /* ascending sort key */
lstn_t *pLstn; /* NULL, if this is a dir entry, otherwise pointer into listener(file) table */
int dirIdx; /* index into dirs table, undefined if pLstn == NULL */
time_t timeoutBase; /* what time to calculate the timeout against? */
};
typedef struct wd_map_s wd_map_t;
static wd_map_t *wdmap = NULL;
@ -250,6 +255,8 @@ static prop_t *pInputName = NULL; /* there is only one global inputName for all
/* module-global parameters */
static struct cnfparamdescr modpdescr[] = {
{ "pollinginterval", eCmdHdlrPositiveInt, 0 },
{ "readtimeout", eCmdHdlrPositiveInt, 0 },
{ "timeoutgranularity", eCmdHdlrPositiveInt, 0 },
{ "mode", eCmdHdlrGetWord, 0 }
};
static struct cnfparamblk modpblk =
@ -278,6 +285,7 @@ static struct cnfparamdescr inppdescr[] = {
{ "addmetadata", eCmdHdlrBinary, 0 },
{ "addceetag", eCmdHdlrBinary, 0 },
{ "statefile", eCmdHdlrString, CNFPARAM_DEPRECATED },
{ "readtimeout", eCmdHdlrPositiveInt, 0 },
{ "freshstarttail", eCmdHdlrBinary, 0}
};
static struct cnfparamblk inppblk =
@ -289,7 +297,7 @@ static struct cnfparamblk inppblk =
#include "im-helper.h" /* must be included AFTER the type definitions! */
#if HAVE_INOTIFY_INIT
#ifdef HAVE_INOTIFY_INIT
/* support for inotify mode */
#if 0 /* enable if you need this for debugging */
@ -468,7 +476,7 @@ static rsRetVal enqLine(lstn_t *const __restrict__ pLstn,
MsgSetInputName(pMsg, pInputName);
if (pLstn->addCeeTag) {
size_t msgLen = cstrLen(cstrLine);
char *ceeToken = "@cee:";
const char *const ceeToken = "@cee:";
size_t ceeMsgSize = msgLen + strlen(ceeToken) +1;
char *ceeMsg;
CHKmalloc(ceeMsg = MALLOC(ceeMsgSize));
@ -492,11 +500,11 @@ finalize_it:
}
/* try to open a file. This involves checking if there is a status file and,
* if so, reading it in. Processing continues from the last know location.
/* try to open a file which has a state file. If the state file does not
* exist or cannot be read, an error is returned.
*/
static rsRetVal
openFile(lstn_t *pLstn)
openFileWithStateFile(lstn_t *const __restrict__ pLstn)
{
DEFiRet;
strm_t *psSF = NULL;
@ -504,7 +512,6 @@ openFile(lstn_t *pLstn)
size_t lenSFNam;
struct stat stat_buf;
uchar statefile[MAXFNAME];
sbool isFreshStart = 0;
uchar *const statefn = getStateFileName(pLstn, statefile, sizeof(statefile));
DBGPRINTF("imfile: trying to open state for '%s', state file '%s'\n",
@ -516,8 +523,7 @@ openFile(lstn_t *pLstn)
/* check if the file exists */
if(stat((char*) pszSFNam, &stat_buf) == -1) {
if(errno == ENOENT) {
DBGPRINTF("imfile: clean startup, state file for '%s'\n", pLstn->pszFileName);
isFreshStart = 1;
DBGPRINTF("imfile: NO state file exists for '%s'\n", pLstn->pszFileName);
ABORT_FINALIZE(RS_RET_FILE_NOT_FOUND);
} else {
char errStr[1024];
@ -538,7 +544,6 @@ openFile(lstn_t *pLstn)
/* read back in the object */
CHKiRet(obj.Deserialize(&pLstn->pStrm, (uchar*) "strm", psSF, NULL, pLstn));
CHKiRet(strm.SetbReopenOnTruncate(pLstn->pStrm, pLstn->reopenOnTruncate));
DBGPRINTF("imfile: deserialized state file, state file base name '%s', "
"configured base name '%s'\n", pLstn->pStrm->pszFName,
pLstn->pszFileName);
@ -563,26 +568,59 @@ finalize_it:
if(psSF != NULL)
strm.Destruct(&psSF);
if(iRet != RS_RET_OK) {
if(pLstn->pStrm != NULL)
strm.Destruct(&pLstn->pStrm);
CHKiRet(strm.Construct(&pLstn->pStrm));
CHKiRet(strm.SettOperationsMode(pLstn->pStrm, STREAMMODE_READ));
CHKiRet(strm.SetsType(pLstn->pStrm, STREAMTYPE_FILE_MONITOR));
CHKiRet(strm.SetFName(pLstn->pStrm, pLstn->pszFileName, strlen((char*) pLstn->pszFileName)));
CHKiRet(strm.ConstructFinalize(pLstn->pStrm));
RETiRet;
}
/* If state file not exist, this is a fresh start. seek to file end
* when freshStartTail is on.
*/
if(pLstn->freshStartTail && isFreshStart){
if(stat((char*) pLstn->pszFileName, &stat_buf) != -1) {
pLstn->pStrm->iCurrOffs = stat_buf.st_size;
CHKiRet(strm.SeekCurrOffs(pLstn->pStrm));
}
/* try to open a file for which no state file exists. This function does NOT
* check if a state file actually exists or not -- this must have been
* checked before calling it.
*/
static rsRetVal
openFileWithoutStateFile(lstn_t *const __restrict__ pLstn)
{
DEFiRet;
struct stat stat_buf;
DBGPRINTF("imfile: clean startup withOUT state file for '%s'\n", pLstn->pszFileName);
if(pLstn->pStrm != NULL)
strm.Destruct(&pLstn->pStrm);
CHKiRet(strm.Construct(&pLstn->pStrm));
CHKiRet(strm.SettOperationsMode(pLstn->pStrm, STREAMMODE_READ));
CHKiRet(strm.SetsType(pLstn->pStrm, STREAMTYPE_FILE_MONITOR));
CHKiRet(strm.SetFName(pLstn->pStrm, pLstn->pszFileName, strlen((char*) pLstn->pszFileName)));
CHKiRet(strm.ConstructFinalize(pLstn->pStrm));
/* As a state file not exist, this is a fresh start. seek to file end
* when freshStartTail is on.
*/
if(pLstn->freshStartTail){
if(stat((char*) pLstn->pszFileName, &stat_buf) != -1) {
pLstn->pStrm->iCurrOffs = stat_buf.st_size;
CHKiRet(strm.SeekCurrOffs(pLstn->pStrm));
}
}
strmSetReadTimeout(pLstn->pStrm, pLstn->readTimeout);
finalize_it:
RETiRet;
}
/* try to open a file. This involves checking if there is a status file and,
* if so, reading it in. Processing continues from the last know location.
*/
static rsRetVal
openFile(lstn_t *const __restrict__ pLstn)
{
DEFiRet;
CHKiRet_Hdlr(openFileWithStateFile(pLstn)) {
CHKiRet(openFileWithoutStateFile(pLstn));
}
DBGPRINTF("imfile: breopenOnTruncate %d for '%s'\n",
pLstn->reopenOnTruncate, pLstn->pszFileName);
CHKiRet(strm.SetbReopenOnTruncate(pLstn->pStrm, pLstn->reopenOnTruncate));
finalize_it:
RETiRet;
}
@ -606,13 +644,13 @@ static rsRetVal
pollFile(lstn_t *pLstn, int *pbHadFileData)
{
cstr_t *pCStr = NULL;
int nProcessed = 0;
DEFiRet;
/* Note: we must do pthread_cleanup_push() immediately, because the POXIS macros
* otherwise do not work if I include the _cleanup_pop() inside an if... -- rgerhards, 2008-08-14
*/
pthread_cleanup_push(pollFileCancelCleanup, &pCStr);
int nProcessed = 0;
if(pLstn->pStrm == NULL) {
CHKiRet(openFile(pLstn)); /* open file */
}
@ -680,6 +718,7 @@ createInstance(instanceConf_t **pinst)
inst->addMetadata = ADD_METADATA_UNSPECIFIED;
inst->addCeeTag = 0;
inst->freshStartTail = 0;
inst->readTimeout = loadModConf->readTimeout;
/* node created, let's add to config */
if(loadModConf->tail == NULL) {
@ -824,6 +863,7 @@ addInstance(void __attribute__((unused)) *pVal, uchar *pNewVal)
inst->addMetadata = 0;
inst->addCeeTag = 0;
inst->bRMStateOnDel = 0;
inst->readTimeout = loadModConf->readTimeout;
CHKiRet(checkInstance(inst));
@ -892,61 +932,6 @@ lstnDel(lstn_t *pLstn)
free(pLstn);
}
/* Duplicate an existing listener. This is called when a new file is to
* be monitored due to wildcard detection. Returns the new pLstn in
* the ppExisting parameter.
*/
static rsRetVal
lstnDup(lstn_t **ppExisting, uchar *const __restrict__ newname)
{
DEFiRet;
lstn_t *const existing = *ppExisting;
lstn_t *pThis;
CHKiRet(lstnAdd(&pThis));
pThis->pszDirName = existing->pszDirName; /* read-only */
pThis->pszBaseName = (uchar*)strdup((char*)newname);
if(asprintf((char**)&pThis->pszFileName, "%s/%s", (char*)pThis->pszDirName, (char*)newname) == -1) {
DBGPRINTF("imfile/lstnDup: asprintf failed, malfunction can happen\n");
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
pThis->pszTag = (uchar*) strdup((char*) existing->pszTag);
pThis->lenTag = ustrlen(pThis->pszTag);
pThis->pszStateFile = existing->pszStateFile == NULL ? NULL : (uchar*) strdup((char*) existing->pszStateFile);
CHKiRet(ratelimitNew(&pThis->ratelimiter, "imfile", (char*)pThis->pszFileName));
pThis->multiSub.maxElem = existing->multiSub.maxElem;
pThis->multiSub.nElem = 0;
CHKmalloc(pThis->multiSub.ppMsgs = MALLOC(pThis->multiSub.maxElem * sizeof(msg_t*)));
pThis->iSeverity = existing->iSeverity;
pThis->iFacility = existing->iFacility;
pThis->maxLinesAtOnce = existing->maxLinesAtOnce;
pThis->trimLineOverBytes = existing->trimLineOverBytes;
pThis->iPersistStateInterval = existing->iPersistStateInterval;
pThis->readMode = existing->readMode;
pThis->startRegex = existing->startRegex; /* no strdup, as it is read-only */
if(pThis->startRegex != NULL) // TODO: make this a single function with better error handling
if(regcomp(&pThis->end_preg, (char*)pThis->startRegex, REG_EXTENDED)) {
DBGPRINTF("imfile: error regex compile\n");
ABORT_FINALIZE(RS_RET_ERR);
}
pThis->bRMStateOnDel = existing->bRMStateOnDel;
pThis->hasWildcard = existing->hasWildcard;
pThis->escapeLF = existing->escapeLF;
pThis->reopenOnTruncate = existing->reopenOnTruncate;
pThis->addMetadata = existing->addMetadata;
pThis->addCeeTag = existing->addCeeTag;
pThis->freshStartTail = existing->freshStartTail;
pThis->pRuleset = existing->pRuleset;
pThis->nRecords = 0;
pThis->pStrm = NULL;
pThis->prevLineSegment = NULL;
pThis->masterLstn = existing;
*ppExisting = pThis;
finalize_it:
RETiRet;
}
/* This function is called when a new listener shall be added.
* It also does some late stage error checking on the config
* and reports issues it finds.
@ -1006,6 +991,7 @@ addListner(instanceConf_t *inst)
pThis->addMetadata = (inst->addMetadata == ADD_METADATA_UNSPECIFIED) ?
hasWildcard : inst->addMetadata;
pThis->addCeeTag = inst->addCeeTag;
pThis->readTimeout = inst->readTimeout;
pThis->freshStartTail = inst->freshStartTail;
pThis->pRuleset = inst->pBindRuleset;
pThis->nRecords = 0;
@ -1084,6 +1070,8 @@ CODESTARTnewInpInst
inst->iPersistStateInterval = pvals[i].val.d.n;
} else if(!strcmp(inppblk.descr[i].name, "maxsubmitatonce")) {
inst->nMultiSub = pvals[i].val.d.n;
} else if(!strcmp(inppblk.descr[i].name, "readtimeout")) {
inst->readTimeout = pvals[i].val.d.n;
} else {
DBGPRINTF("imfile: program error, non-handled "
"param '%s'\n", inppblk.descr[i].name);
@ -1095,6 +1083,8 @@ CODESTARTnewInpInst
"at the same time --- remove one of them");
ABORT_FINALIZE(RS_RET_PARAM_NOT_PERMITTED);
}
if(inst->readTimeout != 0)
loadModConf->haveReadTimeouts = 1;
CHKiRet(checkInstance(inst));
finalize_it:
CODE_STD_FINALIZERnewInpInst
@ -1109,6 +1099,9 @@ CODESTARTbeginCnfLoad
loadModConf->opMode = OPMODE_POLLING;
loadModConf->iPollInterval = DFLT_PollInterval;
loadModConf->configSetViaV2Method = 0;
loadModConf->readTimeout = 0; /* default: no timeout */
loadModConf->timeoutGranularity = 1000; /* default: 1 second */
loadModConf->haveReadTimeouts = 0; /* default: no timeout */
bLegacyCnfModGlobalsPermitted = 1;
/* init legacy config vars */
cs.pszFileName = NULL;
@ -1146,6 +1139,11 @@ CODESTARTsetModCnf
continue;
if(!strcmp(modpblk.descr[i].name, "pollinginterval")) {
loadModConf->iPollInterval = (int) pvals[i].val.d.n;
} else if(!strcmp(modpblk.descr[i].name, "readtimeout")) {
loadModConf->readTimeout = (int) pvals[i].val.d.n;
} else if(!strcmp(modpblk.descr[i].name, "timeoutgranularity")) {
/* note: we need ms, thus "* 1000" */
loadModConf->timeoutGranularity = (int) pvals[i].val.d.n * 1000;
} else if(!strcmp(modpblk.descr[i].name, "mode")) {
if(!es_strconstcmp(pvals[i].val.d.estr, "polling"))
loadModConf->opMode = OPMODE_POLLING;
@ -1297,7 +1295,7 @@ doPolling(void)
}
#if HAVE_INOTIFY_INIT
#ifdef HAVE_INOTIFY_INIT
static rsRetVal
fileTableInit(fileTable_t *const __restrict__ tab, const int nelem)
{
@ -1563,6 +1561,62 @@ startLstnFile(lstn_t *const __restrict__ pLstn)
done: return;
}
/* Duplicate an existing listener. This is called when a new file is to
* be monitored due to wildcard detection. Returns the new pLstn in
* the ppExisting parameter.
*/
static rsRetVal
lstnDup(lstn_t **ppExisting, uchar *const __restrict__ newname)
{
DEFiRet;
lstn_t *const existing = *ppExisting;
lstn_t *pThis;
CHKiRet(lstnAdd(&pThis));
pThis->pszDirName = existing->pszDirName; /* read-only */
pThis->pszBaseName = (uchar*)strdup((char*)newname);
if(asprintf((char**)&pThis->pszFileName, "%s/%s", (char*)pThis->pszDirName, (char*)newname) == -1) {
DBGPRINTF("imfile/lstnDup: asprintf failed, malfunction can happen\n");
ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
}
pThis->pszTag = (uchar*) strdup((char*) existing->pszTag);
pThis->lenTag = ustrlen(pThis->pszTag);
pThis->pszStateFile = existing->pszStateFile == NULL ? NULL : (uchar*) strdup((char*) existing->pszStateFile);
CHKiRet(ratelimitNew(&pThis->ratelimiter, "imfile", (char*)pThis->pszFileName));
pThis->multiSub.maxElem = existing->multiSub.maxElem;
pThis->multiSub.nElem = 0;
CHKmalloc(pThis->multiSub.ppMsgs = MALLOC(pThis->multiSub.maxElem * sizeof(msg_t*)));
pThis->iSeverity = existing->iSeverity;
pThis->iFacility = existing->iFacility;
pThis->maxLinesAtOnce = existing->maxLinesAtOnce;
pThis->trimLineOverBytes = existing->trimLineOverBytes;
pThis->iPersistStateInterval = existing->iPersistStateInterval;
pThis->readMode = existing->readMode;
pThis->startRegex = existing->startRegex; /* no strdup, as it is read-only */
if(pThis->startRegex != NULL) // TODO: make this a single function with better error handling
if(regcomp(&pThis->end_preg, (char*)pThis->startRegex, REG_EXTENDED)) {
DBGPRINTF("imfile: error regex compile\n");
ABORT_FINALIZE(RS_RET_ERR);
}
pThis->bRMStateOnDel = existing->bRMStateOnDel;
pThis->hasWildcard = existing->hasWildcard;
pThis->escapeLF = existing->escapeLF;
pThis->reopenOnTruncate = existing->reopenOnTruncate;
pThis->addMetadata = existing->addMetadata;
pThis->addCeeTag = existing->addCeeTag;
pThis->readTimeout = existing->readTimeout;
pThis->freshStartTail = existing->freshStartTail;
pThis->pRuleset = existing->pRuleset;
pThis->nRecords = 0;
pThis->pStrm = NULL;
pThis->prevLineSegment = NULL;
pThis->masterLstn = existing;
*ppExisting = pThis;
finalize_it:
RETiRet;
}
/* Setup a new file watch for dynamically discovered files (via wildcards).
* Note: we need to try to read this file, as it may already contain data this
* needs to be processed, and we won't get an event for that as notifications
@ -1636,7 +1690,7 @@ done: return;
/* setup our initial set of watches, based on user config */
static void
in_setupInitialWatches()
in_setupInitialWatches(void)
{
int i;
for(i = 0 ; i < currMaxDirs ; ++i) {
@ -1848,12 +1902,30 @@ in_processEvent(struct inotify_event *ev)
done: return;
}
static void
in_do_timeout_processing(void)
{
int i;
DBGPRINTF("imfile: readTimeouts are configured, checking if some apply\n");
for(i = 0 ; i < nWdmap ; ++i) {
dbgprintf("imfile: wdmap %d, plstn %p\n", i, wdmap[i].pLstn);
lstn_t *const pLstn = wdmap[i].pLstn;
if(pLstn != NULL && strmReadMultiLine_isTimedOut(pLstn->pStrm)) {
dbgprintf("imfile: wdmap %d, timeout occured\n", i);
pollFile(pLstn, NULL);
}
}
}
/* Monitor files in inotify mode */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align" /* TODO: how can we fix these warnings? */
/* Problem with the warnings: they seem to stem back from the way the API is structured */
static rsRetVal
do_inotify()
do_inotify(void)
{
char iobuf[8192];
struct inotify_event *ev;
@ -1872,6 +1944,29 @@ do_inotify()
in_setupInitialWatches();
while(glbl.GetGlobalInputTermState() == 0) {
if(runModConf->haveReadTimeouts) {
int r;
struct pollfd pollfd;
pollfd.fd = ino_fd;
pollfd.events = POLLIN;
do {
r = poll(&pollfd, 1, runModConf->timeoutGranularity);
} while(r == -1 && errno == EINTR);
if(r == 0) {
in_do_timeout_processing();
continue;
} else if (r == -1) {
char errStr[1024];
rs_strerror_r(errno, errStr, sizeof(errStr));
DBGPRINTF("%s:%d: unexpected error during poll timeout wait: %s\n",
__FILE__, __LINE__, errStr);
ABORT_FINALIZE(RS_RET_IO_ERROR);
} else if(r != 1) {
DBGPRINTF("%s:%d: ERROR: poll returned %d, but we had only one fd!\n",
__FILE__, __LINE__, r);
ABORT_FINALIZE(RS_RET_IO_ERROR);
}
}
rd = read(ino_fd, iobuf, sizeof(iobuf));
if(rd < 0 && Debug) {
char errStr[1024];
@ -1895,7 +1990,7 @@ finalize_it:
#else /* #if HAVE_INOTIFY_INIT */
static rsRetVal
do_inotify()
do_inotify(void)
{
errmsg.LogError(0, RS_RET_NOT_IMPLEMENTED, "imfile: mode set to inotify, but the "
"platform does not support inotify");
@ -2013,12 +2108,11 @@ BEGINmodExit
CODESTARTmodExit
/* release objects we used */
objRelease(strm, CORE_COMPONENT);
objRelease(datetime, CORE_COMPONENT);
objRelease(glbl, CORE_COMPONENT);
objRelease(errmsg, CORE_COMPONENT);
objRelease(prop, CORE_COMPONENT);
objRelease(ruleset, CORE_COMPONENT);
#if HAVE_INOTIFY_INIT
#ifdef HAVE_INOTIFY_INIT
/* we use these vars only in inotify mode */
if(dirs != NULL) {
free(dirs->active.listeners);
@ -2091,7 +2185,6 @@ CODESTARTmodInit
CODEmodInit_QueryRegCFSLineHdlr
CHKiRet(objUse(errmsg, CORE_COMPONENT));
CHKiRet(objUse(glbl, CORE_COMPONENT));
CHKiRet(objUse(datetime, CORE_COMPONENT));
CHKiRet(objUse(strm, CORE_COMPONENT));
CHKiRet(objUse(ruleset, CORE_COMPONENT));
CHKiRet(objUse(prop, CORE_COMPONENT));

View File

@ -3,7 +3,7 @@
* To test under Linux:
* emmit log message into systemd journal
*
* Copyright (C) 2008-2014 Adiscon GmbH
* Copyright (C) 2008-2016 Adiscon GmbH
*
* This file is part of rsyslog.
*
@ -105,7 +105,7 @@ static int bLegacyCnfModGlobalsPermitted = 1;/* are legacy module-global config
static prop_t *pInputName = NULL; /* there is only one global inputName for all messages generated by this module */
static prop_t *pLocalHostIP = NULL; /* a pseudo-constant propterty for 127.0.0.1 */
static char *pid_field_name; /* read-only after startup */
static const char *pid_field_name; /* read-only after startup */
static ratelimit_t *ratelimiter = NULL;
static sd_journal *j;
@ -218,7 +218,8 @@ finalize_it:
* record of printk buffer.
*/
static rsRetVal
readjournal() {
readjournal(void)
{
DEFiRet;
struct timeval tv;
@ -372,7 +373,8 @@ finalize_it:
/* This function gets journal cursor and saves it into state file
*/
static rsRetVal
persistJournalState () {
persistJournalState (void)
{
DEFiRet;
FILE *sf; /* state file */
char *cursor;
@ -408,7 +410,7 @@ persistJournalState () {
* except for the special handling of EINTR.
*/
static rsRetVal
pollJournal()
pollJournal(void)
{
DEFiRet;
struct pollfd pollfd;
@ -451,7 +453,8 @@ finalize_it:
static rsRetVal
skipOldMessages() {
skipOldMessages(void)
{
DEFiRet;
if (sd_journal_seek_tail(j) < 0) {
@ -479,7 +482,7 @@ finalize_it:
/* This function loads a journal cursor from the state file.
*/
static rsRetVal
loadJournalState()
loadJournalState(void)
{
DEFiRet;

View File

@ -167,7 +167,6 @@ rsRetVal
klogWillRunPrePrivDrop(modConfData_t *pModConf)
{
char errmsg[2048];
int r;
DEFiRet;
fklog = open((char*)GetPath(pModConf), O_RDONLY, 0);
@ -180,7 +179,7 @@ klogWillRunPrePrivDrop(modConfData_t *pModConf)
# ifdef OS_LINUX
/* Set level of kernel console messaging.. */
if(pModConf->console_log_level != -1) {
r = klogctl(8, NULL, pModConf->console_log_level);
int r = klogctl(8, NULL, pModConf->console_log_level);
if(r != 0) {
imklogLogIntMsg(LOG_WARNING, "imklog: cannot set console log level: %s",
rs_strerror_r(errno, errmsg, sizeof(errmsg)));

View File

@ -21,7 +21,7 @@
* To test under Linux:
* echo test1 > /dev/kmsg
*
* Copyright (C) 2008-2014 Adiscon GmbH
* Copyright (C) 2008-2016 Adiscon GmbH
*
* This file is part of rsyslog.
*
@ -199,7 +199,7 @@ finalize_it:
/* log an imklog-internal message
* rgerhards, 2008-04-14
*/
rsRetVal imklogLogIntMsg(syslog_pri_t priority, char *fmt, ...)
rsRetVal imklogLogIntMsg(syslog_pri_t priority, const char *fmt, ...)
{
DEFiRet;
va_list ap;

View File

@ -51,10 +51,10 @@ rsRetVal klogLogKMsg(modConfData_t *pModConf);
rsRetVal klogAfterRun(modConfData_t *pModConf);
rsRetVal klogWillRunPrePrivDrop(modConfData_t *pModConf);
rsRetVal klogWillRunPostPrivDrop(modConfData_t *pModConf);
int klogFacilIntMsg();
int klogFacilIntMsg(void);
/* the functions below may be called by the drivers */
rsRetVal imklogLogIntMsg(syslog_pri_t priority, char *fmt, ...) __attribute__((format(printf,2, 3)));
rsRetVal imklogLogIntMsg(syslog_pri_t priority, const char *fmt, ...) __attribute__((format(printf,2, 3)));
rsRetVal Syslog(syslog_pri_t priority, uchar *msg, struct timeval *tp);
/* prototypes */

View File

@ -1,7 +1,7 @@
/* impstats.c
* A module to periodically output statistics gathered by rsyslog.
*
* Copyright 2010-2013 Adiscon GmbH.
* Copyright 2010-2016 Adiscon GmbH.
*
* This file is part of rsyslog.
*
@ -210,13 +210,13 @@ doLogToFile(const char *ln, const size_t lenLn)
time(&t);
iov[0].iov_base = ctime_r(&t, timebuf);
iov[0].iov_len = nexpect = strlen(iov[0].iov_base) - 1; /* -1: strip \n */
iov[1].iov_base = ": ";
iov[1].iov_base = (void*)": ";
iov[1].iov_len = 2;
nexpect += 2;
iov[2].iov_base = (void*)ln;
iov[2].iov_len = lenLn;
nexpect += lenLn;
iov[3].iov_base = "\n";
iov[3].iov_base = (void*)"\n";
iov[3].iov_len = 1;
nexpect++;
nwritten = writev(runModConf->logfd, iov, 4);

View File

@ -1095,7 +1095,7 @@ initConfigSettings(void)
/* add socket to the epoll set
*/
static inline rsRetVal
static rsRetVal
addEPollSock(epolld_type_t typ, void *ptr, int sock, epolld_t **pEpd)
{
DEFiRet;
@ -1136,7 +1136,7 @@ finalize_it:
* For simplicity, we supply the same pointer we had when we created the
* event (it's simple because we have it at hand).
*/
static inline rsRetVal
static rsRetVal
removeEPollSock(int sock, epolld_t *epd)
{
DEFiRet;
@ -1546,7 +1546,7 @@ stopWorkerPool(void)
* This is a one-time stop once the module is set to start.
*/
static inline rsRetVal
startupServers()
startupServers(void)
{
DEFiRet;
rsRetVal localRet, lastErr;
@ -1581,7 +1581,7 @@ startupServers()
static inline rsRetVal
lstnActivity(ptcplstn_t *pLstn)
{
int newSock;
int newSock = -1;
prop_t *peerName;
prop_t *peerIP;
rsRetVal localRet;
@ -1610,7 +1610,7 @@ finalize_it:
/* process new activity on session. This means we need to accept data
* or close the session.
*/
static inline rsRetVal
static rsRetVal
sessActivity(ptcpsess_t *pSess, int *continue_polling)
{
int lenRcv;
@ -1690,7 +1690,8 @@ processWorkItem(epolld_t *epd)
static rsRetVal
initIoQ() {
initIoQ(void)
{
DEFiRet;
CHKiConcCtrl(pthread_mutex_init(&io_q.mut, NULL));
CHKiConcCtrl(pthread_cond_init(&io_q.wakeup_worker, NULL));
@ -1711,7 +1712,8 @@ finalize_it:
}
static void
destroyIoQ() {
destroyIoQ(void)
{
io_req_t *n;
if (io_q.stats != NULL) {
statsobj.Destruct(&io_q.stats);

View File

@ -4,7 +4,7 @@
*
* File begun on 2008-03-13 by RGerhards
*
* Copyright 2008-2015 Adiscon GmbH.
* Copyright 2008-2016 Adiscon GmbH.
*
* This file is part of rsyslog.
*
@ -323,7 +323,7 @@ addListner(modConfData_t __attribute__((unused)) *modConf, instanceConf_t *inst)
DEFiRet;
if(pRelpEngine == NULL) {
CHKiRet(relpEngineConstruct(&pRelpEngine));
CHKiRet(relpEngineSetDbgprint(pRelpEngine, dbgprintf));
CHKiRet(relpEngineSetDbgprint(pRelpEngine, (void (*)(char *, ...))dbgprintf));
CHKiRet(relpEngineSetFamily(pRelpEngine, glbl.GetDefPFFamily()));
CHKiRet(relpEngineSetEnableCmd(pRelpEngine, (uchar*) "syslog", eRelpCmdState_Required));
CHKiRet(relpEngineSetSyslogRcv2(pRelpEngine, onSyslogRcv));

View File

@ -4,7 +4,7 @@
* NOTE: read comments in module-template.h to understand how this file
* works!
*
* Copyright 2007-2015 Rainer Gerhards and Adiscon GmbH.
* Copyright 2007-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of rsyslog.
*
@ -34,7 +34,7 @@
#include <sys/socket.h>
#include <pthread.h>
#include <signal.h>
#if HAVE_SYS_EPOLL_H
#ifdef HAVE_SYS_EPOLL_H
# include <sys/epoll.h>
#endif
#ifdef HAVE_SCHED_H
@ -545,7 +545,7 @@ finalize_it:
* matter where the actual loss occurs - it is always random, because we depend
* on scheduling order. -- rgerhards, 2008-10-02
*/
static inline rsRetVal
static rsRetVal
processSocket(struct wrkrInfo_s *pWrkr, struct lstn_s *lstn, struct sockaddr_storage *frominetPrev, int *pbIsPermitted)
{
int iNbrTimeUsed;
@ -623,9 +623,8 @@ checkSchedulingPriority(modConfData_t *modConf)
modConf->pszSchedPolicy);
ABORT_FINALIZE(RS_RET_VALIDATION_RUN);
}
#endif
finalize_it:
#endif
RETiRet;
}
@ -717,9 +716,9 @@ setSchedParams(modConfData_t *modConf)
if(err != 0) {
errmsg.LogError(err, NO_ERRCODE, "imudp: pthread_setschedparam() failed - ignoring");
}
finalize_it:
# endif
finalize_it:
RETiRet;
}
@ -731,7 +730,8 @@ finalize_it:
*/
#if defined(HAVE_EPOLL_CREATE1) || defined(HAVE_EPOLL_CREATE)
#define NUM_EPOLL_EVENTS 10
rsRetVal rcvMainLoop(struct wrkrInfo_s *pWrkr)
static rsRetVal
rcvMainLoop(struct wrkrInfo_s *const __restrict__ pWrkr)
{
DEFiRet;
int nfds;
@ -819,7 +819,8 @@ finalize_it:
}
#else /* #if HAVE_EPOLL_CREATE1 */
/* this is the code for the select() interface */
rsRetVal rcvMainLoop(thrdInfo_t *pWrkr)
static rsRetVal
rcvMainLoop(struct wrkrInfo_s *const __restrict__ pWrkr)
{
DEFiRet;
int maxfds;
@ -846,7 +847,7 @@ rsRetVal rcvMainLoop(thrdInfo_t *pWrkr)
for(lstn = lcnfRoot ; lstn != NULL ; lstn = lstn->next) {
if (lstn->sock != -1) {
if(Debug)
net.debugListenInfo(lstn->sock, "UDP");
net.debugListenInfo(lstn->sock, (char*)"UDP");
FD_SET(lstn->sock, &readfds);
if(lstn->sock>maxfds) maxfds=lstn->sock;
}
@ -1150,13 +1151,13 @@ static void *
wrkr(void *myself)
{
struct wrkrInfo_s *pWrkr = (struct wrkrInfo_s*) myself;
# if HAVE_PRCTL && defined PR_SET_NAME
# if defined(HAVE_PRCTL) && defined(PR_SET_NAME)
uchar *pszDbgHdr;
# endif
uchar thrdName[32];
snprintf((char*)thrdName, sizeof(thrdName), "imudp(w%d)", pWrkr->id);
# if HAVE_PRCTL && defined PR_SET_NAME
# if defined(HAVE_PRCTL) && defined(PR_SET_NAME)
/* set thread name - we ignore if the call fails, has no harsh consequences... */
if(prctl(PR_SET_NAME, thrdName, 0, 0, 0) != 0) {
DBGPRINTF("prctl failed, not setting thread name for '%s'\n", thrdName);

View File

@ -58,6 +58,8 @@
#include "hashtable.h"
#include "ratelimit.h"
#pragma GCC diagnostic ignored "-Wswitch-enum"
MODULE_TYPE_INPUT
MODULE_TYPE_NOKEEP
MODULE_CNFNAME("imuxsock")
@ -510,7 +512,7 @@ static inline rsRetVal
openLogSocket(lstn_t *pLstn)
{
DEFiRet;
# if HAVE_SCM_CREDENTIALS
# ifdef HAVE_SCM_CREDENTIALS
int one;
# endif /* HAVE_SCM_CREDENTIALS */
@ -546,7 +548,7 @@ openLogSocket(lstn_t *pLstn)
CHKiRet(createLogSocket(pLstn));
}
# if HAVE_SCM_CREDENTIALS
# ifdef HAVE_SCM_CREDENTIALS
if(pLstn->bUseCreds) {
one = 1;
if(setsockopt(pLstn->fd, SOL_SOCKET, SO_PASSCRED, &one, (socklen_t) sizeof(one)) != 0) {
@ -666,7 +668,7 @@ fixPID(uchar *bufTAG, int *lenTag, struct ucred *cred)
* journald. Currently works with Linux /proc filesystem, only.
*/
static rsRetVal
getTrustedProp(struct ucred *cred, char *propName, uchar *buf, size_t lenBuf, int *lenProp)
getTrustedProp(struct ucred *cred, const char *propName, uchar *buf, size_t lenBuf, int *lenProp)
{
int fd;
int i;
@ -1003,7 +1005,7 @@ static rsRetVal readSocket(lstn_t *pLstn)
struct timeval *ts;
uchar bufRcv[4096+1];
uchar *pRcv = NULL; /* receive buffer */
# if HAVE_SCM_CREDENTIALS
# ifdef HAVE_SCM_CREDENTIALS
char aux[128];
# endif
@ -1025,7 +1027,7 @@ static rsRetVal readSocket(lstn_t *pLstn)
memset(&msgh, 0, sizeof(msgh));
memset(&msgiov, 0, sizeof(msgiov));
# if HAVE_SCM_CREDENTIALS
# ifdef HAVE_SCM_CREDENTIALS
if(pLstn->bUseCreds) {
memset(&aux, 0, sizeof(aux));
msgh.msg_control = aux;
@ -1046,7 +1048,7 @@ static rsRetVal readSocket(lstn_t *pLstn)
if(pLstn->bUseCreds) {
struct cmsghdr *cm;
for(cm = CMSG_FIRSTHDR(&msgh); cm; cm = CMSG_NXTHDR(&msgh, cm)) {
# if HAVE_SCM_CREDENTIALS
# ifdef HAVE_SCM_CREDENTIALS
if( pLstn->bUseCreds
&& cm->cmsg_level == SOL_SOCKET && cm->cmsg_type == SCM_CREDENTIALS) {
cred = (struct ucred*) CMSG_DATA(cm);
@ -1079,8 +1081,8 @@ finalize_it:
/* activate current listeners */
static inline rsRetVal
activateListeners()
static rsRetVal
activateListeners(void)
{
register int i;
int actSocks;

View File

@ -284,7 +284,7 @@ writeOctet(uchar *msg, int idx, int *nxtidx, uint8_t octet)
}
/* currently works for IPv4 only! */
void
static void
anonip(instanceData *pData, uchar *msg, int *pLenMsg, int *idx)
{
int i = *idx;

View File

@ -2,7 +2,7 @@
* This core plugin is an interface module to message modification
* modules written in languages other than C.
*
* Copyright 2014 by Rainer Gerhards
* Copyright 2014-2016 by Rainer Gerhards
*
* This file is part of rsyslog.
*
@ -264,7 +264,7 @@ processProgramReply(wrkrInstanceData_t *__restrict__ const pWrkrData, msg_t *con
/* execute the child process (must be called in child context
* after fork).
*/
static void
static void __attribute__((noreturn))
execBinary(wrkrInstanceData_t *pWrkrData, int fdStdin, int fdStdOutErr)
{
int i, iRet;
@ -473,7 +473,7 @@ callExtProg(wrkrInstanceData_t *__restrict__ const pWrkrData, msg_t *__restrict_
iov[0].iov_len = lenWrite - writeOffset;
++i_iov;
}
iov[i_iov].iov_base = "\n";
iov[i_iov].iov_base = (void*)"\n";
iov[i_iov].iov_len = 1;
lenWritten = writev(pWrkrData->fdPipeOut, iov, i_iov+1);
if(lenWritten == -1) {

View File

@ -198,7 +198,7 @@ extractField(instanceData *pData, uchar *msgtext, int lenMsg, int *curridx, ucha
}
static inline rsRetVal
static rsRetVal
parse_fields(instanceData *pData, msg_t *pMsg, uchar *msgtext, int lenMsg)
{
uchar fieldbuf[32*1024];

View File

@ -111,7 +111,7 @@ static modConfData_t *loadModConf = NULL;/* modConf ptr to use for the current l
static modConfData_t *runModConf = NULL;/* modConf ptr to use for the current exec process */
/* callback for liblognorm error messages */
void
static void
errCallBack(void __attribute__((unused)) *cookie, const char *msg,
size_t __attribute__((unused)) lenMsg)
{

View File

@ -225,7 +225,7 @@ parseSD_NAME(uchar *sdbuf, int lenbuf, int *curridx, uchar *namebuf)
}
static inline rsRetVal
static rsRetVal
parseSD_PARAM(uchar *sdbuf, int lenbuf, int *curridx, struct json_object *jroot)
{
int i;

View File

@ -20,6 +20,17 @@
THE SOFTWARE.
*/
/* this code has several warnings, but we ignore them because
* this seems to work and we do not want to engage in that code body. If
* we really run into troubles, it is better to change to libfastjson, which
* we should do in the medium to long term anyhow...
*/
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
#pragma GCC diagnostic ignored "-Wredundant-decls"
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#pragma GCC diagnostic ignored "-Wswitch-default"
#pragma GCC diagnostic ignored "-Wold-style-definition"
/* cJSON */
/* JSON parser in C. */

View File

@ -263,7 +263,7 @@ setBaseURL(instanceData *pData, es_str_t **url)
}
static inline rsRetVal
static rsRetVal
checkConn(wrkrInstanceData_t *pWrkrData)
{
es_str_t *url;
@ -517,7 +517,7 @@ finalize_it:
/*
* Dumps entire bulk request and response in error log
*/
static inline rsRetVal
static rsRetVal
getDataErrorDefault(wrkrInstanceData_t *pWrkrData,cJSON **pReplyRoot,uchar *reqmsg,char **rendered)
{
DEFiRet;
@ -548,7 +548,7 @@ getDataErrorDefault(wrkrInstanceData_t *pWrkrData,cJSON **pReplyRoot,uchar *reqm
* Sets bulkRequestNextSectionStart pointer to next sections start in the buffer pointed by bulkRequest.
* Sections are marked by { and }
*/
static inline rsRetVal
static rsRetVal
getSection(const char* bulkRequest, const char **bulkRequestNextSectionStart )
{
DEFiRet;
@ -571,7 +571,7 @@ getSection(const char* bulkRequest, const char **bulkRequestNextSectionStart )
* Sets the new string in singleRequest for one request in bulkRequest
* and sets lastLocation pointer to the location till which bulkrequest has been parsed.(used as input to make function thread safe.)
*/
static inline rsRetVal
static rsRetVal
getSingleRequest(const char* bulkRequest, char** singleRequest, const char **lastLocation)
{
DEFiRet;
@ -595,7 +595,7 @@ finalize_it:
/*
* check the status of response from ES
*/
int checkReplyStatus(cJSON* ok) {
static int checkReplyStatus(cJSON* ok) {
return (ok == NULL || ok->type != cJSON_Number || ok->valueint < 0 || ok->valueint > 299);
}
@ -613,7 +613,7 @@ typedef struct exeContext{
/*
* get content to be written in error file using context passed
*/
static inline rsRetVal
static rsRetVal
parseRequestAndResponseForContext(wrkrInstanceData_t *pWrkrData,cJSON **pReplyRoot,uchar *reqmsg,context *ctx)
{
DEFiRet;
@ -712,7 +712,7 @@ parseRequestAndResponseForContext(wrkrInstanceData_t *pWrkrData,cJSON **pReplyRo
/*
* Dumps only failed requests of bulk insert
*/
static inline rsRetVal
static rsRetVal
getDataErrorOnly(context *ctx,int itemStatus,char *request,char *response)
{
DEFiRet;
@ -783,7 +783,7 @@ getDataInterleaved(context *ctx,
* Dumps only failed requests of bulk insert interleaved with request and response
*/
static inline rsRetVal
static rsRetVal
getDataErrorOnlyInterleaved(context *ctx,int itemStatus,char *request,char *response)
{
DEFiRet;
@ -800,7 +800,7 @@ getDataErrorOnlyInterleaved(context *ctx,int itemStatus,char *request,char *resp
/*
* get erroronly context
*/
static inline rsRetVal
static rsRetVal
initializeErrorOnlyConext(wrkrInstanceData_t *pWrkrData,context *ctx){
DEFiRet;
ctx->statusCheckOnly=0;
@ -831,7 +831,7 @@ initializeErrorOnlyConext(wrkrInstanceData_t *pWrkrData,context *ctx){
/*
* get interleaved context
*/
static inline rsRetVal
static rsRetVal
initializeInterleavedConext(wrkrInstanceData_t *pWrkrData,context *ctx){
DEFiRet;
ctx->statusCheckOnly=0;
@ -853,7 +853,7 @@ initializeInterleavedConext(wrkrInstanceData_t *pWrkrData,context *ctx){
}
/*get interleaved context*/
static inline rsRetVal
static rsRetVal
initializeErrorInterleavedConext(wrkrInstanceData_t *pWrkrData,context *ctx){
DEFiRet;
ctx->statusCheckOnly=0;
@ -879,7 +879,7 @@ initializeErrorInterleavedConext(wrkrInstanceData_t *pWrkrData,context *ctx){
* Note: we open the file but never close it before exit. If it
* needs to be closed, HUP must be sent.
*/
static inline rsRetVal
static rsRetVal
writeDataError(wrkrInstanceData_t *pWrkrData, instanceData *pData, cJSON **pReplyRoot, uchar *reqmsg)
{
char *rendered = NULL;
@ -982,7 +982,7 @@ finalize_it:
}
static inline rsRetVal
static rsRetVal
checkResultBulkmode(wrkrInstanceData_t *pWrkrData, cJSON *root)
{
DEFiRet;
@ -1000,7 +1000,7 @@ checkResultBulkmode(wrkrInstanceData_t *pWrkrData, cJSON *root)
}
static inline rsRetVal
static rsRetVal
checkResult(wrkrInstanceData_t *pWrkrData, uchar *reqmsg)
{
cJSON *root;
@ -1060,19 +1060,17 @@ curlPost(wrkrInstanceData_t *pWrkrData, uchar *message, int msglen, uchar **tpls
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (char *)message);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, msglen);
code = curl_easy_perform(curl);
switch (code) {
case CURLE_COULDNT_RESOLVE_HOST:
case CURLE_COULDNT_RESOLVE_PROXY:
case CURLE_COULDNT_CONNECT:
case CURLE_WRITE_ERROR:
STATSCOUNTER_INC(indexHTTPReqFail, mutIndexHTTPReqFail);
indexHTTPFail += nmsgs;
DBGPRINTF("omelasticsearch: we are suspending ourselfs due "
"to failure %lld of curl_easy_perform()\n",
(long long) code);
ABORT_FINALIZE(RS_RET_SUSPENDED);
default:
break;
if ( code == CURLE_COULDNT_RESOLVE_HOST
|| code == CURLE_COULDNT_RESOLVE_PROXY
|| code == CURLE_COULDNT_CONNECT
|| code == CURLE_WRITE_ERROR
) {
STATSCOUNTER_INC(indexHTTPReqFail, mutIndexHTTPReqFail);
indexHTTPFail += nmsgs;
DBGPRINTF("omelasticsearch: we are suspending ourselfs due "
"to failure %lld of curl_easy_perform()\n",
(long long) code);
ABORT_FINALIZE(RS_RET_SUSPENDED);
}
DBGPRINTF("omelasticsearch: pWrkrData replyLen = '%d'\n", pWrkrData->replyLen);
@ -1128,7 +1126,7 @@ finalize_it:
ENDendTransaction
/* elasticsearch POST result string ... useful for debugging */
size_t
static size_t
curlResult(void *ptr, size_t size, size_t nmemb, void *userdata)
{
char *p = (char *)ptr;
@ -1184,7 +1182,7 @@ curlSetup(wrkrInstanceData_t *pWrkrData, instanceData *pData)
return RS_RET_OK;
}
static inline void
static void
setInstParamDefaults(instanceData *pData)
{
pData->server = NULL;

View File

@ -180,7 +180,7 @@ CODESTARTtryResume
ENDtryResume
struct iovec *
static struct iovec *
build_iovec(size_t *retargc, struct json_object *json)
{
struct iovec *iov;
@ -244,8 +244,8 @@ fail:
}
void
send_non_template_message(msg_t *pMsg)
static void
send_non_template_message(msg_t *const __restrict__ pMsg)
{
uchar *tag;
int lenTag;
@ -263,8 +263,8 @@ send_non_template_message(msg_t *pMsg)
NULL);
}
void
send_template_message(struct json_object* json)
static void
send_template_message(struct json_object *const __restrict__ json)
{
size_t argc;
struct iovec *iovec;

View File

@ -10,7 +10,7 @@
*
* File begun on 2008-02-14 by RGerhards (extracted from syslogd.c)
*
* Copyright 2008-2014 Adiscon GmbH.
* Copyright 2008-2016 Adiscon GmbH.
*
* This file is part of rsyslog.
*
@ -301,7 +301,8 @@ finalize_it:
/* The following function writes the current log entry
* to an established database connection.
*/
rsRetVal writeDB(uchar *psz, instanceData *pData)
static rsRetVal
writeDB(const uchar *psz, instanceData *const __restrict__ pData)
{
DEFiRet;
dbi_result dbiRes = NULL;
@ -352,7 +353,7 @@ CODESTARTbeginTransaction
if(pWrkrData->pData->conn == NULL) {
CHKiRet(initConn(pWrkrData->pData, 0));
}
# if HAVE_DBI_TXSUPP
# ifdef HAVE_DBI_TXSUPP
if (pData->txSupport == 1) {
if (dbi_conn_transaction_begin(pData->conn) != 0) {
const char *emsg;
@ -372,7 +373,7 @@ BEGINdoAction
CODESTARTdoAction
pthread_mutex_lock(&mutDoAct);
CHKiRet(writeDB(ppString[0], pWrkrData->pData));
# if HAVE_DBI_TXSUPP
# ifdef HAVE_DBI_TXSUPP
if (pData->txSupport == 1) {
iRet = RS_RET_DEFER_COMMIT;
}
@ -384,7 +385,7 @@ ENDdoAction
/* transaction support 2013-03 */
BEGINendTransaction
CODESTARTendTransaction
# if HAVE_DBI_TXSUPP
# ifdef HAVE_DBI_TXSUPP
if (dbi_conn_transaction_commit(pData->conn) != 0) {
const char *emsg;
dbi_conn_error(pData->conn, &emsg);

View File

@ -142,7 +142,7 @@ CODESTARTinitConfVars
ENDinitConfVars
/* forward definitions (as few as possible) */
static rsRetVal Send(int sock, char *msg, size_t len);
static rsRetVal Send(int sock, const char *msg, size_t len);
static rsRetVal readResponse(wrkrInstanceData_t *pWrkrData, int *piState, int iExpected);
@ -365,8 +365,8 @@ serverConnect(wrkrInstanceData_t *pWrkrData)
{
struct addrinfo *res = NULL;
struct addrinfo hints;
char *smtpPort;
char *smtpSrv;
const char *smtpPort;
const char *smtpSrv;
char errStr[1024];
instanceData *pData;
DEFiRet;
@ -418,7 +418,7 @@ finalize_it:
/* send text to the server, blocking send */
static rsRetVal
Send(int sock, char *msg, size_t len)
Send(const int sock, const char *const __restrict__ msg, const size_t len)
{
DEFiRet;
size_t offsBuf = 0;

View File

@ -4,7 +4,7 @@
* mongodb C interface is crap. Obtain the library here:
* https://github.com/algernon/libmongo-client
*
* Copyright 2007-2013 Rainer Gerhards and Adiscon GmbH.
* Copyright 2007-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of rsyslog.
*
@ -176,10 +176,10 @@ reportMongoError(instanceData *pData)
*/
static rsRetVal initMongoDB(instanceData *pData, int bSilent)
{
char *server;
const char *server;
DEFiRet;
server = (pData->server == NULL) ? "127.0.0.1" : (char*) pData->server;
server = (pData->server == NULL) ? "127.0.0.1" : (const char*) pData->server;
DBGPRINTF("ommongodb: trying connect to '%s' at port %d\n", server, pData->port);
pData->conn = mongo_sync_connect(server, pData->port, TRUE);
@ -223,7 +223,7 @@ finalize_it:
* TODO: consider moving this to msg.c - make some dirty "friend" references...
* rgerhards, 2012-03-19
*/
static inline char *
static inline const char *
getLumberjackLevel(short severity)
{
switch(severity) {

View File

@ -237,7 +237,7 @@ finalize_it:
* to an established MySQL session.
* Initially added 2004-10-28 mmeckelein
*/
rsRetVal writeMySQL(wrkrInstanceData_t *pWrkrData, uchar *psz)
static rsRetVal writeMySQL(wrkrInstanceData_t *pWrkrData, uchar *psz)
{
DEFiRet;

View File

@ -63,6 +63,7 @@ typedef struct _instanceData {
char f_dbuid[_DB_MAXUNAMELEN+1]; /* DB user */
char f_dbpwd[_DB_MAXPWDLEN+1]; /* DB user's password */
ConnStatusType eLastPgSQLStatus; /* last status from postgres */
uchar *tplName; /* format template to use */
} instanceData;
typedef struct wrkrInstanceData {
@ -115,6 +116,7 @@ static void closePgSQL(instanceData *pData)
BEGINfreeInstance
CODESTARTfreeInstance
closePgSQL(pData);
free(pData->tplName);
ENDfreeInstance
BEGINfreeWrkrInstance
@ -363,12 +365,15 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
* We specify that the SQL option must be present in the template.
* This is for your own protection (prevent sql injection).
*/
if(*(p-1) == ';')
if(*(p-1) == ';') {
--p; /* TODO: the whole parsing of the MySQL module needs to be re-thought - but this here
* is clean enough for the time being -- rgerhards, 2007-07-30
* kept it for pgsql -- sur5r, 2007-10-19
*/
CHKiRet(cflineParseTemplateName(&p, *ppOMSR, 0, OMSR_RQD_TPL_OPT_SQL, (uchar*) " StdPgSQLFmt"));
CHKiRet(cflineParseTemplateName(&p, *ppOMSR, 0, OMSR_RQD_TPL_OPT_SQL, (uchar*) pData->tplName));
}
else
CHKiRet(cflineParseTemplateName(&p, *ppOMSR, 0, OMSR_RQD_TPL_OPT_SQL, (uchar*)" StdPgSQLFmt"));
/* If we detect invalid properties, we disable logging,
* because right properties are vital at this place.

View File

@ -219,7 +219,7 @@ done: return;
/* execute the child process (must be called in child context
* after fork).
*/
static void
static __attribute__((noreturn)) void
execBinary(wrkrInstanceData_t *pWrkrData, int fdStdin, int fdStdOutErr)
{
int i, iRet;

View File

@ -78,6 +78,7 @@ typedef struct _instanceData {
uchar *port;
int sizeWindow; /**< the RELP window size - 0=use default */
unsigned timeout;
int connTimeout;
unsigned rebindInterval;
sbool bEnableTLS;
sbool bEnableTLSZip;
@ -126,6 +127,7 @@ static struct cnfparamdescr actpdescr[] = {
{ "rebindinterval", eCmdHdlrInt, 0 },
{ "windowsize", eCmdHdlrInt, 0 },
{ "timeout", eCmdHdlrInt, 0 },
{ "conn.timeout", eCmdHdlrInt, 0 },
{ "localclientip", eCmdHdlrGetWord, 0 },
{ "template", eCmdHdlrGetWord, 0 }
};
@ -190,6 +192,9 @@ doCreateRelpClient(wrkrInstanceData_t *pWrkrData)
ABORT_FINALIZE(RS_RET_RELP_ERR);
if(relpCltSetTimeout(pWrkrData->pRelpClt, pData->timeout) != RELP_RET_OK)
ABORT_FINALIZE(RS_RET_RELP_ERR);
if(relpCltSetConnTimeout(pWrkrData->pRelpClt, pData->connTimeout) != RELP_RET_OK) {
ABORT_FINALIZE(RS_RET_RELP_ERR);
}
if(relpCltSetWindowSize(pWrkrData->pRelpClt, pData->sizeWindow) != RELP_RET_OK)
ABORT_FINALIZE(RS_RET_RELP_ERR);
if(relpCltSetUsrPtr(pWrkrData->pRelpClt, pWrkrData) != RELP_RET_OK)
@ -232,6 +237,7 @@ BEGINcreateInstance
CODESTARTcreateInstance
pData->sizeWindow = 0;
pData->timeout = 90;
pData->connTimeout = 10;
pData->rebindInterval = 0;
pData->bEnableTLS = DFLT_ENABLE_TLS;
pData->bEnableTLSZip = DFLT_ENABLE_TLSZIP;
@ -283,6 +289,7 @@ setInstParamDefaults(instanceData *pData)
pData->port = NULL;
pData->tplName = NULL;
pData->timeout = 90;
pData->connTimeout = 10;
pData->sizeWindow = 0;
pData->rebindInterval = 0;
pData->bEnableTLS = DFLT_ENABLE_TLS;
@ -325,6 +332,8 @@ CODESTARTnewActInst
pData->localClientIP = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
} else if(!strcmp(actpblk.descr[i].name, "timeout")) {
pData->timeout = (unsigned) pvals[i].val.d.n;
} else if(!strcmp(actpblk.descr[i].name, "conn.timeout")) {
pData->connTimeout = (int) pvals[i].val.d.n;
} else if(!strcmp(actpblk.descr[i].name, "rebindinterval")) {
pData->rebindInterval = (unsigned) pvals[i].val.d.n;
} else if(!strcmp(actpblk.descr[i].name, "windowsize")) {
@ -405,13 +414,13 @@ static rsRetVal doConnect(wrkrInstanceData_t *pWrkrData)
if(iRet == RELP_RET_OK) {
pWrkrData->bIsConnected = 1;
} else if(iRet == RELP_RET_ERR_NO_TLS) {
errmsg.LogError(0, RS_RET_RELP_NO_TLS, "Could not connect, librelp does NOT "
errmsg.LogError(0, RS_RET_RELP_NO_TLS, "omrelp: Could not connect, librelp does NOT "
"does not support TLS (most probably GnuTLS lib "
"is too old)!");
ABORT_FINALIZE(RS_RET_RELP_NO_TLS);
} else if(iRet == RELP_RET_ERR_NO_TLS) {
errmsg.LogError(0, RS_RET_RELP_NO_TLS_AUTH,
"imrelp: could not activate relp TLS with "
"omrelp: could not activate relp TLS with "
"authentication, librelp does not support it "
"(most probably GnuTLS lib is too old)! "
"Note: anonymous TLS is probably supported.");
@ -617,7 +626,7 @@ INITLegCnfVars
CODEmodInit_QueryRegCFSLineHdlr
/* create our relp engine */
CHKiRet(relpEngineConstruct(&pRelpEngine));
CHKiRet(relpEngineSetDbgprint(pRelpEngine, dbgprintf));
CHKiRet(relpEngineSetDbgprint(pRelpEngine, (void (*)(char *, ...))dbgprintf));
CHKiRet(relpEngineSetOnAuthErr(pRelpEngine, onAuthErr));
CHKiRet(relpEngineSetOnGenericErr(pRelpEngine, onGenericErr));
CHKiRet(relpEngineSetOnErr(pRelpEngine, onErr));

View File

@ -4,7 +4,7 @@
* NOTE: read comments in module-template.h to understand how this file
* works!
*
* Copyright 2010-2015 Adiscon GmbH.
* Copyright 2010-2016 Adiscon GmbH.
*
* This file is part of rsyslog.
*
@ -126,7 +126,7 @@ getDfltTpl(void)
* is we do not permit this directive after the v2 config system has been used to set
* the parameter.
*/
rsRetVal
static rsRetVal
setLegacyDfltTpl(void __attribute__((unused)) *pVal, uchar* newVal)
{
DEFiRet;
@ -278,7 +278,7 @@ static rsRetVal sendMsg(instanceData *pData, char *msg, size_t len)
* call fails. Then, lsent has the error status, even though
* the sendto() succeeded. -- rgerhards, 2007-06-22
*/
lenSent = sendto(pData->sock, msg, len, 0, &pData->addr, sizeof(pData->addr));
lenSent = sendto(pData->sock, msg, len, 0, (const struct sockaddr *)&pData->addr, sizeof(pData->addr));
if(lenSent == len) {
int eno = errno;
char errStr[1024];
@ -294,7 +294,7 @@ finalize_it:
/* open socket to remote system
*/
static inline rsRetVal
static rsRetVal
openSocket(instanceData *pData)
{
DEFiRet;

View File

@ -27,6 +27,7 @@
#define BATCH_H_INCLUDED
#include <string.h>
#include <stdlib.h>
#include "msg.h"
/* enum for batch states. Actually, we violate a layer here, in that we assume that a batch is used
@ -79,17 +80,14 @@ struct batch_s {
/* get number of msgs for this batch */
static inline int
batchNumMsgs(const batch_t * const pBatch) {
return pBatch->nElem;
}
#define batchNumMsgs(pBatch) ((pBatch)->nElem)
/* set the status of the i-th batch element. Note that once the status is
* DISC, it will never be reset. So this function can NOT be used to initialize
* the state table. -- rgerhards, 2010-06-10
*/
static inline void
static inline void __attribute__((unused))
batchSetElemState(batch_t * const pBatch, const int i, const batch_state_t newState) {
if(pBatch->eltState[i] != BATCH_STATE_DISC)
pBatch->eltState[i] = newState;
@ -99,17 +97,14 @@ batchSetElemState(batch_t * const pBatch, const int i, const batch_state_t newSt
/* check if an element is a valid entry. We do NOT verify if the
* element index is valid. -- rgerhards, 2010-06-10
*/
static inline int
batchIsValidElem(const batch_t * const pBatch, const int i) {
return(pBatch->eltState[i] != BATCH_STATE_DISC);
}
#define batchIsValidElem(pBatch, i) ((pBatch)->eltState[(i)] != BATCH_STATE_DISC)
/* free members of a batch "object". Note that we can not do the usual
* destruction as the object typically is allocated on the stack and so the
* object itself cannot be freed! -- rgerhards, 2010-06-15
*/
static inline void
static inline void __attribute__((unused))
batchFree(batch_t * const pBatch) {
free(pBatch->pElem);
free(pBatch->eltState);
@ -120,8 +115,9 @@ batchFree(batch_t * const pBatch) {
* we "just" initialize it. The max number of elements must be
* provided. -- rgerhards, 2010-06-15
*/
static inline rsRetVal
batchInit(batch_t *const pBatch, const int maxElem) {
static inline rsRetVal __attribute__((unused))
batchInit(batch_t *const pBatch, const int maxElem)
{
DEFiRet;
pBatch->maxElem = maxElem;
CHKmalloc(pBatch->pElem = calloc((size_t)maxElem, sizeof(batch_obj_t)));
@ -130,22 +126,4 @@ finalize_it:
RETiRet;
}
/* primarily a helper for debug purposes, get human-readble name of state */
static inline char *
batchState2String(const batch_state_t state) {
switch(state) {
case BATCH_STATE_RDY:
return "BATCH_STATE_RDY";
case BATCH_STATE_BAD:
return "BATCH_STATE_BAD";
case BATCH_STATE_SUB:
return "BATCH_STATE_SUB";
case BATCH_STATE_COMM:
return "BATCH_STATE_COMM";
case BATCH_STATE_DISC:
return "BATCH_STATE_DISC";
}
return "ERROR, batch state not known!";
}
#endif /* #ifndef BATCH_H_INCLUDED */

View File

@ -3,7 +3,7 @@
*
* File begun on 2007-07-30 by RGerhards
*
* Copyright (C) 2007-2015 Adiscon GmbH.
* Copyright (C) 2007-2016 Adiscon GmbH.
*
* This file is part of rsyslog.
*
@ -683,7 +683,7 @@ static int cslchKeyCompare(void *pKey1, void *pKey2)
/* set data members for this object
*/
rsRetVal cslchSetEntry(cslCmdHdlr_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, int *permitted)
static rsRetVal cslchSetEntry(cslCmdHdlr_t *pThis, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, int *permitted)
{
assert(pThis != NULL);
assert(eType != eCmdHdlrInvalid);
@ -743,6 +743,13 @@ static rsRetVal cslchCallHdlr(cslCmdHdlr_t *pThis, uchar **ppConfLine)
case eCmdHdlrGoneAway:
pHdlr = doGoneAway;
break;
/* some non-legacy handler (used in v6+ solely) */
case eCmdHdlrInvalid:
case eCmdHdlrNonNegInt:
case eCmdHdlrPositiveInt:
case eCmdHdlrString:
case eCmdHdlrArray:
case eCmdHdlrQueueType:
default:
iRet = RS_RET_NOT_IMPLEMENTED;
goto finalize_it;
@ -843,7 +850,7 @@ finalize_it:
* v2 function and supplies a "don't care (NULL)" pointer as this argument.
* rgerhards, 2012-06-26
*/
rsRetVal regCfSysLineHdlr2(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, void *pOwnerCookie, int *permitted)
rsRetVal regCfSysLineHdlr2(const uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, void *pOwnerCookie, int *permitted)
{
DEFiRet;
cslCmd_t *pThis;
@ -883,7 +890,7 @@ finalize_it:
RETiRet;
}
rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, void *pOwnerCookie)
rsRetVal regCfSysLineHdlr(const uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, void *pOwnerCookie)
{
DEFiRet;
iRet = regCfSysLineHdlr2(pCmdName, bChainingPermitted, eType, pHdlr, pData, pOwnerCookie, NULL);
@ -1041,7 +1048,8 @@ void dbgPrintCfSysLineHandlers(void)
/* our init function. TODO: remove once converted to a class
*/
rsRetVal cfsyslineInit()
rsRetVal
cfsyslineInit(void)
{
DEFiRet;
CHKiRet(objGetObjInterface(&obj));

View File

@ -49,8 +49,8 @@ struct cslCmd_s { /* config file sysline parse entry */
typedef struct cslCmd_s cslCmd_t;
/* prototypes */
rsRetVal regCfSysLineHdlr(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, void *pOwnerCookie);
rsRetVal regCfSysLineHdlr2(uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, void *pOwnerCookie, int *permitted);
rsRetVal regCfSysLineHdlr(const uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, void *pOwnerCookie);
rsRetVal regCfSysLineHdlr2(const uchar *pCmdName, int bChainingPermitted, ecslCmdHdrlType eType, rsRetVal (*pHdlr)(), void *pData, void *pOwnerCookie, int *permitted);
rsRetVal unregCfSysLineHdlrs(void);
rsRetVal unregCfSysLineHdlrs4Owner(void *pOwnerCookie);
rsRetVal processCfSysLineCommand(uchar *pCmd, uchar **p);

View File

@ -96,7 +96,7 @@ cstr_t *pDfltProgNameCmp = NULL;
/* process a $ModLoad config line. */
rsRetVal
static rsRetVal
doModLoad(uchar **pp, __attribute__((unused)) void* pVal)
{
DEFiRet;
@ -154,7 +154,7 @@ ltrim(char *src)
* rgerhards 2005-06-21: previously only for templates, now
* generalized.
*/
rsRetVal
static rsRetVal
doNameLine(uchar **pp, void* pVal)
{
DEFiRet;
@ -214,7 +214,7 @@ finalize_it:
* extended configuration parameters.
* 2004-11-17 rgerhards
*/
rsRetVal
static rsRetVal
cfsysline(uchar *p)
{
DEFiRet;

View File

@ -89,7 +89,7 @@ static const time_t yearInSecs[] = {
/**
* Convert struct timeval to syslog_time
*/
void
static void
timeval2syslogTime(struct timeval *tp, struct syslogTime *t, const int inUTC)
{
struct tm *tm;
@ -116,7 +116,7 @@ timeval2syslogTime(struct timeval *tp, struct syslogTime *t, const int inUTC)
t->OffsetMode = '+';
lBias = 0;
} else {
# if __sun
# if defined(__sun)
/* Solaris uses a different method of exporting the time zone.
* It is UTC - localtime, which is the opposite sign of mins east of GMT.
*/
@ -183,7 +183,7 @@ static void getCurrTime(struct syslogTime *t, time_t *ttSeconds, const int inUTC
* this testing. So I created that function as a replacement.
* rgerhards, 2009-11-12
*/
static time_t
time_t
getTime(time_t *ttSeconds)
{
struct timeval tp;
@ -438,8 +438,8 @@ ParseTIMESTAMP3164(struct syslogTime *pTime, uchar** ppszTS, int *pLenStr,
int secfracPrecision;
char tzstring[16];
char OffsetMode = '\0'; /* UTC offset: \0 -> indicate no update */
char OffsetHour; /* UTC offset in hours */
int OffsetMinute; /* UTC offset in minutes */
char OffsetHour = 0; /* UTC offset in hours */
int OffsetMinute = 0; /* UTC offset in minutes */
/* end variables to temporarily hold time information while we parse */
int lenStr;
uchar *pszTS;
@ -782,7 +782,8 @@ applyDfltTZ(struct syslogTime *pTime, char *tz)
* returns the size of the timestamp written in bytes (without
* the string terminator). If 0 is returend, an error occured.
*/
int formatTimestampToMySQL(struct syslogTime *ts, char* pBuf)
static int
formatTimestampToMySQL(struct syslogTime *ts, char* pBuf)
{
/* currently we do not consider localtime/utc. This may later be
* added. If so, I recommend using a property replacer option
@ -812,7 +813,8 @@ int formatTimestampToMySQL(struct syslogTime *ts, char* pBuf)
}
int formatTimestampToPgSQL(struct syslogTime *ts, char *pBuf)
static int
formatTimestampToPgSQL(struct syslogTime *ts, char *pBuf)
{
/* see note in formatTimestampToMySQL, applies here as well */
assert(ts != NULL);
@ -851,7 +853,8 @@ int formatTimestampToPgSQL(struct syslogTime *ts, char *pBuf)
* The buffer must be at least 7 bytes large.
* rgerhards, 2008-06-06
*/
int formatTimestampSecFrac(struct syslogTime *ts, char* pBuf)
static int
formatTimestampSecFrac(struct syslogTime *ts, char* pBuf)
{
int iBuf;
int power;
@ -889,7 +892,8 @@ int formatTimestampSecFrac(struct syslogTime *ts, char* pBuf)
* returns the size of the timestamp written in bytes (without
* the string terminator). If 0 is returend, an error occured.
*/
int formatTimestamp3339(struct syslogTime *ts, char* pBuf)
static int
formatTimestamp3339(struct syslogTime *ts, char* pBuf)
{
int iBuf;
int power;
@ -969,9 +973,11 @@ int formatTimestamp3339(struct syslogTime *ts, char* pBuf)
* day character if day < 10. syslog-ng seems to do that, and some
* parsing scripts (in migration cases) rely on that.
*/
int formatTimestamp3164(struct syslogTime *ts, char* pBuf, int bBuggyDay)
static int
formatTimestamp3164(struct syslogTime *ts, char* pBuf, int bBuggyDay)
{
static char* monthNames[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
static const char* monthNames[12] =
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
int iDay;
assert(ts != NULL);
@ -1017,7 +1023,8 @@ int formatTimestamp3164(struct syslogTime *ts, char* pBuf, int bBuggyDay)
* In conclusion, we keep our own code for generating the unix timestamp.
* rgerhards, 2016-03-02
*/
time_t syslogTime2time_t(const struct syslogTime *ts)
static time_t
syslogTime2time_t(const struct syslogTime *ts)
{
long MonthInDays, NumberOfYears, NumberOfDays;
int utcOffset;
@ -1118,7 +1125,8 @@ done:
* Important: pBuf must point to a buffer of at least 11 bytes.
* rgerhards, 2012-03-29
*/
int formatTimestampUnix(struct syslogTime *ts, char *pBuf)
static int
formatTimestampUnix(struct syslogTime *ts, char *pBuf)
{
snprintf(pBuf, 11, "%u", (unsigned) syslogTime2time_t(ts));
return 11;

View File

@ -83,5 +83,6 @@ int getWeekdayNbr(struct syslogTime *ts);
int getOrdinal(struct syslogTime *ts);
int getWeek(struct syslogTime *ts);
void timeConvertToUTC(const struct syslogTime *const __restrict__ local, struct syslogTime *const __restrict__ utc);
time_t getTime(time_t *ttSeconds);
#endif /* #ifndef INCLUDED_DATETIME_H */

View File

@ -13,7 +13,7 @@
*
* For details, visit doc/debug.html
*
* Copyright 2008-2012 Rainer Gerhards and Adiscon GmbH.
* Copyright 2008-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -210,7 +210,8 @@ static void dbgFuncDBPrintAll(void)
/* find a mutex inside the FuncDB mutex table. Returns NULL if not found. Only mutexes from the same thread
* are found.
*/
static inline dbgFuncDBmutInfoEntry_t *dbgFuncDBGetMutexInfo(dbgFuncDB_t *pFuncDB, pthread_mutex_t *pmut)
static dbgFuncDBmutInfoEntry_t *
dbgFuncDBGetMutexInfo(dbgFuncDB_t *pFuncDB, pthread_mutex_t *pmut)
{
int i;
int iFound = -1;
@ -231,8 +232,8 @@ static inline dbgFuncDBmutInfoEntry_t *dbgFuncDBGetMutexInfo(dbgFuncDB_t *pFuncD
* "thrd" is the thread that is searched. If it is 0, mutexes for all threads
* shall be printed.
*/
static inline void
dbgFuncDBPrintActiveMutexes(dbgFuncDB_t *pFuncDB, char *pszHdrText, pthread_t thrd)
static void
dbgFuncDBPrintActiveMutexes(dbgFuncDB_t *pFuncDB, const char *pszHdrText, pthread_t thrd)
{
int i;
char pszThrdName[64];
@ -249,7 +250,8 @@ dbgFuncDBPrintActiveMutexes(dbgFuncDB_t *pFuncDB, char *pszHdrText, pthread_t th
/* find a free mutex info spot in FuncDB. NULL is returned if table is full.
*/
static inline dbgFuncDBmutInfoEntry_t *dbgFuncDBFindFreeMutexInfo(dbgFuncDB_t *pFuncDB)
static dbgFuncDBmutInfoEntry_t *
dbgFuncDBFindFreeMutexInfo(dbgFuncDB_t *pFuncDB)
{
int i;
int iFound = -1;
@ -271,7 +273,8 @@ static inline dbgFuncDBmutInfoEntry_t *dbgFuncDBFindFreeMutexInfo(dbgFuncDB_t *p
/* add a mutex lock to the FuncDB. If the size is exhausted, info is discarded.
*/
static inline void dbgFuncDBAddMutexLock(dbgFuncDB_t *pFuncDB, pthread_mutex_t *pmut, int lockLn)
static void
dbgFuncDBAddMutexLock(dbgFuncDB_t *pFuncDB, pthread_mutex_t *pmut, int lockLn)
{
dbgFuncDBmutInfoEntry_t *pMutInfo;
@ -285,7 +288,8 @@ static inline void dbgFuncDBAddMutexLock(dbgFuncDB_t *pFuncDB, pthread_mutex_t *
/* remove a locked mutex from the FuncDB (unlock case!).
*/
static inline void dbgFuncDBRemoveMutexLock(dbgFuncDB_t *pFuncDB, pthread_mutex_t *pmut)
static void
dbgFuncDBRemoveMutexLock(dbgFuncDB_t *pFuncDB, pthread_mutex_t *pmut)
{
dbgFuncDBmutInfoEntry_t *pMutInfo;
@ -322,7 +326,7 @@ dbgOutputTID(char* name)
/* constructor & add new entry to list
*/
dbgMutLog_t *dbgMutLogAddEntry(pthread_mutex_t *pmut, short mutexOp, dbgFuncDB_t *pFuncDB, int lockLn)
static dbgMutLog_t *dbgMutLogAddEntry(pthread_mutex_t *pmut, short mutexOp, dbgFuncDB_t *pFuncDB, int lockLn)
{
dbgMutLog_t *pLog;
@ -344,7 +348,7 @@ dbgMutLog_t *dbgMutLogAddEntry(pthread_mutex_t *pmut, short mutexOp, dbgFuncDB_t
/* destruct log entry
*/
void dbgMutLogDelEntry(dbgMutLog_t *pLog)
static void dbgMutLogDelEntry(dbgMutLog_t *pLog)
{
assert(pLog != NULL);
DLL_Del(MutLog, pLog);
@ -354,7 +358,7 @@ void dbgMutLogDelEntry(dbgMutLog_t *pLog)
/* print a single mutex log entry */
static void dbgMutLogPrintOne(dbgMutLog_t *pLog)
{
char *strmutop;
const char *strmutop;
char buf[64];
char pszThrdName[64];
@ -396,7 +400,7 @@ static void dbgMutLogPrintAll(void)
* The pFuncDB is optional and may be NULL to indicate no specific funciont is
* reqested (aka "it is ignored" ;)). This is important for the unlock case.
*/
dbgMutLog_t *dbgMutLogFindSpecific(pthread_mutex_t *pmut, short mutop, dbgFuncDB_t *pFuncDB)
static dbgMutLog_t *dbgMutLogFindSpecific(pthread_mutex_t *pmut, short mutop, dbgFuncDB_t *pFuncDB)
{
dbgMutLog_t *pLog;
pthread_t mythrd = pthread_self();
@ -414,7 +418,7 @@ dbgMutLog_t *dbgMutLogFindSpecific(pthread_mutex_t *pmut, short mutop, dbgFuncDB
/* find mutex object from the back of the list */
dbgMutLog_t *dbgMutLogFindFromBack(pthread_mutex_t *pmut, dbgMutLog_t *pLast)
static dbgMutLog_t *dbgMutLogFindFromBack(pthread_mutex_t *pmut, dbgMutLog_t *pLast)
{
dbgMutLog_t *pLog;
@ -435,7 +439,7 @@ dbgMutLog_t *dbgMutLogFindFromBack(pthread_mutex_t *pmut, dbgMutLog_t *pLast)
/* find lock aquire for mutex from back of list */
dbgMutLog_t *dbgMutLogFindHolder(pthread_mutex_t *pmut)
static dbgMutLog_t *dbgMutLogFindHolder(pthread_mutex_t *pmut)
{
dbgMutLog_t *pLog;
@ -450,12 +454,13 @@ dbgMutLog_t *dbgMutLogFindHolder(pthread_mutex_t *pmut)
}
/* report wait on a mutex and add it to the mutex log */
static inline void dbgMutexPreLockLog(pthread_mutex_t *pmut, dbgFuncDB_t *pFuncDB, int ln)
static void
dbgMutexPreLockLog(pthread_mutex_t *pmut, dbgFuncDB_t *pFuncDB, int ln)
{
dbgMutLog_t *pHolder;
char pszBuf[128];
char pszHolderThrdName[64];
char *pszHolder;
const char *pszHolder;
pthread_mutex_lock(&mutMutLog);
pHolder = dbgMutLogFindHolder(pmut);
@ -476,7 +481,8 @@ static inline void dbgMutexPreLockLog(pthread_mutex_t *pmut, dbgFuncDB_t *pFuncD
/* report aquired mutex */
static inline void dbgMutexLockLog(pthread_mutex_t *pmut, dbgFuncDB_t *pFuncDB, int lockLn)
static void
dbgMutexLockLog(pthread_mutex_t *pmut, dbgFuncDB_t *pFuncDB, int lockLn)
{
dbgMutLog_t *pLog;
@ -498,7 +504,8 @@ static inline void dbgMutexLockLog(pthread_mutex_t *pmut, dbgFuncDB_t *pFuncDB,
/* if we unlock, we just remove the lock aquired entry from the log list */
static inline void dbgMutexUnlockLog(pthread_mutex_t *pmut, dbgFuncDB_t *pFuncDB, int unlockLn)
static void
dbgMutexUnlockLog(pthread_mutex_t *pmut, dbgFuncDB_t *pFuncDB, int unlockLn)
{
dbgMutLog_t *pLog;
@ -663,7 +670,8 @@ static dbgThrdInfo_t *dbgGetThrdInfo(void)
/* find a specific thread ID. It must be present, else something is wrong
*/
static inline dbgThrdInfo_t *dbgFindThrd(pthread_t thrd)
static dbgThrdInfo_t *
dbgFindThrd(pthread_t thrd)
{
dbgThrdInfo_t *pThrd;
@ -754,7 +762,7 @@ static void dbgCallStackPrint(dbgThrdInfo_t *pThrd)
/* print all threads call stacks
*/
void dbgCallStackPrintAll(void)
static void dbgCallStackPrintAll(void)
{
dbgThrdInfo_t *pThrd;
/* stack info */
@ -768,10 +776,10 @@ void dbgCallStackPrintAll(void)
* more meaningful way.
* rgerhards, 2008-01-22
*/
void
void __attribute__((noreturn))
sigsegvHdlr(int signum)
{
char *signame;
const char *signame;
struct sigaction sigAct;
/* first, restore the default abort handler */
@ -810,7 +818,7 @@ sigsegvHdlr(int signum)
* interface otherwise is unsafe to use (generates compiler warnings at least).
* 2009-05-20 rgerhards
*/
static inline void
static void
do_dbgprint(uchar *pszObjName, char *pszMsg, size_t lenMsg)
{
static pthread_t ptLastThrdID = 0;
@ -888,7 +896,9 @@ do_dbgprint(uchar *pszObjName, char *pszMsg, size_t lenMsg)
bWasNL = (pszMsg[lenMsg - 1] == '\n') ? 1 : 0;
}
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wempty-body"
#pragma GCC diagnostic ignored "-Wclobbered"
/* write the debug message. This is a helper to dbgprintf and dbgoprint which
* contains common code. added 2008-09-26 rgerhards
*/
@ -915,6 +925,7 @@ dbgprint(obj_t *pObj, char *pszMsg, size_t lenMsg)
pthread_cleanup_pop(1);
}
#pragma GCC diagnostic warning "-Wempty-body"
#pragma GCC diagnostic warning "-Wclobbered"
/* print some debug output when an object is given
* This is mostly a copy of dbgprintf, but I do not know how to combine it
@ -923,7 +934,7 @@ dbgprint(obj_t *pObj, char *pszMsg, size_t lenMsg)
* time being. -- rgerhards, 2008-01-29
*/
void
dbgoprint(obj_t *pObj, char *fmt, ...)
dbgoprint(obj_t *pObj, const char *fmt, ...)
{
va_list ap;
char pszWriteBuf[32*1024];
@ -962,7 +973,7 @@ dbgoprint(obj_t *pObj, char *fmt, ...)
* WARNING: duplicate code, see dbgoprin above!
*/
void
dbgprintf(char *fmt, ...)
dbgprintf(const char *fmt, ...)
{
va_list ap;
char pszWriteBuf[32*1024];
@ -986,12 +997,6 @@ dbgprintf(char *fmt, ...)
dbgprint(NULL, pszWriteBuf, lenWriteBuf);
}
void tester(void)
{
BEGINfunc
ENDfunc
}
/* handler called when a function is entered. This function creates a new
* funcDB on the heap if the passed-in pointer is NULL.
*/

View File

@ -92,8 +92,8 @@ rsRetVal dbgClassExit(void);
void dbgSetDebugFile(uchar *fn);
void dbgSetDebugLevel(int level);
void sigsegvHdlr(int signum);
void dbgoprint(obj_t *pObj, char *fmt, ...) __attribute__((format(printf, 2, 3)));
void dbgprintf(char *fmt, ...) __attribute__((format(printf, 1, 2)));
void dbgoprint(obj_t *pObj, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
void dbgprintf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
int dbgMutexLock(pthread_mutex_t *pmut, dbgFuncDB_t *pFuncD, int ln, int iStackPtr);
int dbgMutexTryLock(pthread_mutex_t *pmut, dbgFuncDB_t *pFuncD, int ln, int iStackPtr);
int dbgMutexUnlock(pthread_mutex_t *pmut, dbgFuncDB_t *pFuncD, int ln, int iStackPtr);

View File

@ -76,7 +76,7 @@ static prop_t *staticErrValue;
/* Our hash function.
* TODO: check how well it performs on socket addresses!
*/
unsigned int
static unsigned int
hash_from_key_fn(void *k)
{
int len;

View File

@ -97,7 +97,7 @@ dynstats_destroyCounters(dynstats_bucket_t *b) {
dynstats_destroyCountersIn(b, b->table, b->ctrs);
}
void
static void
dynstats_destroyBucket(dynstats_bucket_t* b) {
dynstats_buckets_t *bkts;
@ -415,7 +415,7 @@ finalize_it:
}
void
dynstats_destroyAllBuckets() {
dynstats_destroyAllBuckets(void) {
dynstats_buckets_t *bkts;
dynstats_bucket_t *b;
bkts = &loadConf->dynstats_buckets;

View File

@ -75,8 +75,8 @@ rsRetVal dynstats_initCnf(dynstats_buckets_t *b);
rsRetVal dynstats_processCnf(struct cnfobj *o);
dynstats_bucket_t * dynstats_findBucket(const uchar* name);
rsRetVal dynstats_inc(dynstats_bucket_t *bucket, uchar* metric);
void dynstats_destroyAllBuckets();
void dynstats_resetExpired();
void dynstats_destroyAllBuckets(void);
void dynstats_resetExpired(void);
rsRetVal dynstatsClassInit(void);
#endif /* #ifndef INCLUDED_DYNSTATS_H */

View File

@ -73,9 +73,9 @@ stdlog_channel_t stdlog_hdl = NULL; /* handle to be used for stdlog */
#endif
static struct cnfobj *mainqCnfObj = NULL;/* main queue object, to be used later in startup sequence */
int bProcessInternalMessages = 1; /* Should rsyslog itself process internal messages?
int bProcessInternalMessages = 0; /* Should rsyslog itself process internal messages?
* 1 - yes
* 0 - send them to libstdlog (e.g. to push to journal)
* 0 - send them to libstdlog (e.g. to push to journal) or syslog()
*/
static uchar *pszWorkDir = NULL;
#ifdef HAVE_LIBLOGGING_STDLOG
@ -968,21 +968,12 @@ glblProcessCnf(struct cnfobj *o)
continue;
if(!strcmp(paramblk.descr[i].name, "processinternalmessages")) {
bProcessInternalMessages = (int) cnfparamvals[i].val.d.n;
#ifndef HAVE_LIBLOGGING_STDLOG
if(bProcessInternalMessages != 1) {
bProcessInternalMessages = 1;
errmsg.LogError(0, RS_RET_ERR, "rsyslog wasn't "
"compiled with liblogging-stdlog support. "
"The 'ProcessInternalMessages' parameter "
"is ignored.\n");
}
#endif
} else if(!strcmp(paramblk.descr[i].name, "stdlog.channelspec")) {
#ifndef HAVE_LIBLOGGING_STDLOG
errmsg.LogError(0, RS_RET_ERR, "rsyslog wasn't "
"compiled with liblogging-stdlog support. "
"The 'stdlog.channelspec' parameter "
"is ignored.\n");
"is ignored. Note: the syslog API is used instead.\n");
#else
stdlog_chanspec = (uchar*)
es_str2cstr(cnfparamvals[i].val.d.estr, NULL);
@ -1012,7 +1003,7 @@ glblProcessMainQCnf(struct cnfobj *o)
* also used to do some final checks.
*/
void
glblDestructMainqCnfObj()
glblDestructMainqCnfObj(void)
{
/* Only destruct if not NULL! */
if (mainqCnfObj != NULL) {

View File

@ -116,14 +116,14 @@ extern int glblSenderKeepTrack;
extern int glblUnloadModules;
extern short janitorInterval;
static inline pid_t glblGetOurPid(void) { return glbl_ourpid; }
static inline void glblSetOurPid(pid_t pid) { glbl_ourpid = pid; }
#define glblGetOurPid() glbl_ourpid
#define glblSetOurPid(pid) { glbl_ourpid = (pid); }
void glblPrepCnf(void);
void glblProcessCnf(struct cnfobj *o);
void glblProcessTimezone(struct cnfobj *o);
void glblProcessMainQCnf(struct cnfobj *o);
void glblDestructMainqCnfObj();
void glblDestructMainqCnfObj(void);
void glblDoneLoadCnf(void);
const uchar * glblGetWorkDirRaw(void);
tzinfo_t* glblFindTimezoneInfo(char *id);

View File

@ -1,13 +1,19 @@
/* Copyright (C) 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */
/* taken from http://www.cl.cam.ac.uk/~cwc22/hashtable/ */
#include "hashtable.h"
#include "hashtable_private.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
/* this code has several warnings, but we ignore them because
* this seems to work and we do not want to engage in that code body. If
* we really run into troubles, it is better to change to libfastjson, which
* we should do in the medium to long term anyhow...
*/
#pragma GCC diagnostic ignored "-Wredundant-decls"
/*
Credit for primes table: Aaron Krowne
http://br.endernet.org/~akrowne/

View File

@ -1,6 +1,5 @@
/* Copyright (C) 2002, 2004 Christopher Clark <firstname.lastname@cl.cam.ac.uk> */
#include "hashtable.h"
#include "hashtable_private.h"
#include "hashtable_itr.h"
#include <stdlib.h> /* defines NULL */

View File

@ -2,7 +2,6 @@
#ifndef __HASHTABLE_ITR_CWC22__
#define __HASHTABLE_ITR_CWC22__
#include "hashtable.h"
#include "hashtable_private.h" /* needed to enable inlining */
/*****************************************************************************/
@ -28,20 +27,12 @@ hashtable_iterator(struct hashtable *h);
/* hashtable_iterator_key
* - return the value of the (key,value) pair at the current position */
static inline void *
hashtable_iterator_key(struct hashtable_itr *i)
{
return i->e->k;
}
#define hashtable_iterator_key(i) ((i)->e->k)
/*****************************************************************************/
/* value - return the value of the (key,value) pair at the current position */
static inline void *
hashtable_iterator_value(struct hashtable_itr *i)
{
return i->e->v;
}
#define hashtable_iterator_value(i) ((i)->e->v)
/*****************************************************************************/
/* advance - advance the iterator to the next element

View File

@ -30,22 +30,11 @@ hash(struct hashtable *h, void *k);
/*****************************************************************************/
/* indexFor */
static inline unsigned int
indexFor(unsigned int tablelength, unsigned int hashvalue) {
return (hashvalue % tablelength);
};
#define indexFor(tablelength, hashvalue) ((hashvalue) % (tablelength))
/* Only works if tablelength == 2^N */
/*static inline unsigned int
indexFor(unsigned int tablelength, unsigned int hashvalue)
{
return (hashvalue & (tablelength - 1u));
}
*/
/*****************************************************************************/
#define freekey(X) free(X)
/*define freekey(X) ; */
/*****************************************************************************/

View File

@ -5,7 +5,7 @@
*
* File begun on 2011-05-04 by RGerhards
*
* Copyright 2011 Rainer Gerhards and Adiscon GmbH.
* Copyright 2011-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -60,6 +60,3 @@ finalize_it:
}
#endif /* #ifndef IM_HELPER_H_INCLUDED */
/* vim:set ai:
*/

View File

@ -50,24 +50,63 @@
#include "rsyslog.h"
#include "srUtils.h"
#include "debug.h"
#include "libgcry.h"
#define READBUF_SIZE 4096 /* size of the read buffer */
static rsRetVal rsgcryBlkBegin(gcryfile gf);
int
rsgcryAlgoname2Algo(char *const __restrict__ algoname)
{
if(!strcmp((char*)algoname, "3DES")) return GCRY_CIPHER_3DES;
if(!strcmp((char*)algoname, "CAST5")) return GCRY_CIPHER_CAST5;
if(!strcmp((char*)algoname, "BLOWFISH")) return GCRY_CIPHER_BLOWFISH;
if(!strcmp((char*)algoname, "AES128")) return GCRY_CIPHER_AES128;
if(!strcmp((char*)algoname, "AES192")) return GCRY_CIPHER_AES192;
if(!strcmp((char*)algoname, "AES256")) return GCRY_CIPHER_AES256;
if(!strcmp((char*)algoname, "TWOFISH")) return GCRY_CIPHER_TWOFISH;
if(!strcmp((char*)algoname, "TWOFISH128")) return GCRY_CIPHER_TWOFISH128;
if(!strcmp((char*)algoname, "ARCFOUR")) return GCRY_CIPHER_ARCFOUR;
if(!strcmp((char*)algoname, "DES")) return GCRY_CIPHER_DES;
if(!strcmp((char*)algoname, "SERPENT128")) return GCRY_CIPHER_SERPENT128;
if(!strcmp((char*)algoname, "SERPENT192")) return GCRY_CIPHER_SERPENT192;
if(!strcmp((char*)algoname, "SERPENT256")) return GCRY_CIPHER_SERPENT256;
if(!strcmp((char*)algoname, "RFC2268_40")) return GCRY_CIPHER_RFC2268_40;
if(!strcmp((char*)algoname, "SEED")) return GCRY_CIPHER_SEED;
if(!strcmp((char*)algoname, "CAMELLIA128")) return GCRY_CIPHER_CAMELLIA128;
if(!strcmp((char*)algoname, "CAMELLIA192")) return GCRY_CIPHER_CAMELLIA192;
if(!strcmp((char*)algoname, "CAMELLIA256")) return GCRY_CIPHER_CAMELLIA256;
return GCRY_CIPHER_NONE;
}
int
rsgcryModename2Mode(char *const __restrict__ modename)
{
if(!strcmp((char*)modename, "ECB")) return GCRY_CIPHER_MODE_ECB;
if(!strcmp((char*)modename, "CFB")) return GCRY_CIPHER_MODE_CFB;
if(!strcmp((char*)modename, "CBC")) return GCRY_CIPHER_MODE_CBC;
if(!strcmp((char*)modename, "STREAM")) return GCRY_CIPHER_MODE_STREAM;
if(!strcmp((char*)modename, "OFB")) return GCRY_CIPHER_MODE_OFB;
if(!strcmp((char*)modename, "CTR")) return GCRY_CIPHER_MODE_CTR;
# ifdef GCRY_CIPHER_MODE_AESWRAP
if(!strcmp((char*)modename, "AESWRAP")) return GCRY_CIPHER_MODE_AESWRAP;
# endif
return GCRY_CIPHER_MODE_NONE;
}
static rsRetVal
eiWriteRec(gcryfile gf, char *recHdr, size_t lenRecHdr, char *buf, size_t lenBuf)
eiWriteRec(gcryfile gf, const char *recHdr, size_t lenRecHdr, const char *buf, size_t lenBuf)
{
struct iovec iov[3];
ssize_t nwritten, towrite;
DEFiRet;
iov[0].iov_base = recHdr;
iov[0].iov_base = (void*)recHdr;
iov[0].iov_len = lenRecHdr;
iov[1].iov_base = buf;
iov[1].iov_base = (void*)buf;
iov[1].iov_len = lenBuf;
iov[2].iov_base = "\n";
iov[2].iov_base = (void*)"\n";
iov[2].iov_len = 1;
towrite = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
nwritten = writev(gf->fd, iov, sizeof(iov)/sizeof(struct iovec));
@ -515,7 +554,7 @@ finalize_it:
* (and he had good proof that I currently am not permitted to
* reproduce). -- rgerhards, 2013-03-04
*/
void
static void
seedIV(gcryfile gf, uchar **iv)
{
int fd;

View File

@ -64,6 +64,8 @@ rsRetVal rsgcryDecrypt(gcryfile pF, uchar *buf, size_t *len);
int gcryGetKeyFromProg(char *cmd, char **key, unsigned *keylen);
rsRetVal gcryfileDeleteState(uchar *fn);
rsRetVal gcryfileGetBytesLeftInBlock(gcryfile gf, ssize_t *left);
int rsgcryModename2Mode(char *const __restrict__ modename);
int rsgcryAlgoname2Algo(char *const __restrict__ algoname);
/* error states */
#define RSGCRYE_EI_OPEN 1 /* error opening .encinfo file */
@ -75,47 +77,11 @@ rsRetVal gcryfileGetBytesLeftInBlock(gcryfile gf, ssize_t *left);
#define ENCINFO_SUFFIX ".encinfo"
/* Note: gf may validly be NULL, e.g. if file has not yet been opened! */
static inline void
gcryfileSetDeleteOnClose(gcryfile gf, int val)
static inline void __attribute__((unused))
gcryfileSetDeleteOnClose(gcryfile gf, const int val)
{
if(gf != NULL)
gf->bDeleteOnClose = val;
}
static inline int
rsgcryAlgoname2Algo(char *algoname) {
if(!strcmp((char*)algoname, "3DES")) return GCRY_CIPHER_3DES;
if(!strcmp((char*)algoname, "CAST5")) return GCRY_CIPHER_CAST5;
if(!strcmp((char*)algoname, "BLOWFISH")) return GCRY_CIPHER_BLOWFISH;
if(!strcmp((char*)algoname, "AES128")) return GCRY_CIPHER_AES128;
if(!strcmp((char*)algoname, "AES192")) return GCRY_CIPHER_AES192;
if(!strcmp((char*)algoname, "AES256")) return GCRY_CIPHER_AES256;
if(!strcmp((char*)algoname, "TWOFISH")) return GCRY_CIPHER_TWOFISH;
if(!strcmp((char*)algoname, "TWOFISH128")) return GCRY_CIPHER_TWOFISH128;
if(!strcmp((char*)algoname, "ARCFOUR")) return GCRY_CIPHER_ARCFOUR;
if(!strcmp((char*)algoname, "DES")) return GCRY_CIPHER_DES;
if(!strcmp((char*)algoname, "SERPENT128")) return GCRY_CIPHER_SERPENT128;
if(!strcmp((char*)algoname, "SERPENT192")) return GCRY_CIPHER_SERPENT192;
if(!strcmp((char*)algoname, "SERPENT256")) return GCRY_CIPHER_SERPENT256;
if(!strcmp((char*)algoname, "RFC2268_40")) return GCRY_CIPHER_RFC2268_40;
if(!strcmp((char*)algoname, "SEED")) return GCRY_CIPHER_SEED;
if(!strcmp((char*)algoname, "CAMELLIA128")) return GCRY_CIPHER_CAMELLIA128;
if(!strcmp((char*)algoname, "CAMELLIA192")) return GCRY_CIPHER_CAMELLIA192;
if(!strcmp((char*)algoname, "CAMELLIA256")) return GCRY_CIPHER_CAMELLIA256;
return GCRY_CIPHER_NONE;
}
static inline int
rsgcryModename2Mode(char *modename) {
if(!strcmp((char*)modename, "ECB")) return GCRY_CIPHER_MODE_ECB;
if(!strcmp((char*)modename, "CFB")) return GCRY_CIPHER_MODE_CFB;
if(!strcmp((char*)modename, "CBC")) return GCRY_CIPHER_MODE_CBC;
if(!strcmp((char*)modename, "STREAM")) return GCRY_CIPHER_MODE_STREAM;
if(!strcmp((char*)modename, "OFB")) return GCRY_CIPHER_MODE_OFB;
if(!strcmp((char*)modename, "CTR")) return GCRY_CIPHER_MODE_CTR;
# ifdef GCRY_CIPHER_MODE_AESWRAP
if(!strcmp((char*)modename, "AESWRAP")) return GCRY_CIPHER_MODE_AESWRAP;
# endif
return GCRY_CIPHER_MODE_NONE;
}
#endif /* #ifndef INCLUDED_LIBGCRY_H */

View File

@ -63,6 +63,142 @@ typedef unsigned char uchar;
int RSGT_FLAG_TLV16_RUNTIME = RSGT_FLAG_TLV16;
int RSGT_FLAG_NONCRIT_RUNTIME = RSGT_FLAG_NONCRIT;
const char *
RSGTE2String(int err)
{
switch(err) {
case 0:
return "success";
case RSGTE_IO:
return "i/o error";
case RSGTE_FMT:
return "data format error";
case RSGTE_INVLTYP:
return "invalid/unexpected tlv record type";
case RSGTE_OOM:
return "out of memory";
case RSGTE_LEN:
return "length record problem";
case RSGTE_TS_EXTEND:
return "error extending timestamp";
case RSGTE_INVLD_RECCNT:
return "mismatch between actual record count and number in block signature record";
case RSGTE_INVLHDR:
return "invalid file header";
case RSGTE_EOF:
return "EOF";
case RSGTE_MISS_REC_HASH:
return "record hash missing";
case RSGTE_MISS_TREE_HASH:
return "tree hash missing";
case RSGTE_INVLD_REC_HASH:
return "record hash mismatch";
case RSGTE_INVLD_TREE_HASH:
return "tree hash mismatch";
case RSGTE_INVLD_REC_HASHID:
return "invalid record hash ID";
case RSGTE_INVLD_TREE_HASHID:
return "invalid tree hash ID";
case RSGTE_MISS_BLOCKSIG:
return "missing block signature record";
case RSGTE_INVLD_TIMESTAMP:
return "RFC3161 timestamp invalid";
case RSGTE_TS_DERDECODE:
return "error DER-decoding RFC3161 timestamp";
case RSGTE_TS_DERENCODE:
return "error DER-encoding RFC3161 timestamp";
case RSGTE_HASH_CREATE:
return "error creating hash";
case RSGTE_END_OF_SIG:
return "unexpected end of signature";
case RSGTE_END_OF_LOG:
return "unexpected end of log";
default:
return "unknown error";
}
}
uint16_t
hashOutputLengthOctets(uint8_t hashID)
{
switch(hashID) {
case GT_HASHALG_SHA1: /* paper: SHA1 */
return 20;
case GT_HASHALG_RIPEMD160: /* paper: RIPEMD-160 */
return 20;
case GT_HASHALG_SHA224: /* paper: SHA2-224 */
return 28;
case GT_HASHALG_SHA256: /* paper: SHA2-256 */
return 32;
case GT_HASHALG_SHA384: /* paper: SHA2-384 */
return 48;
case GT_HASHALG_SHA512: /* paper: SHA2-512 */
return 64;
default:return 32;
}
}
uint8_t
hashIdentifier(enum GTHashAlgorithm hashID)
{
switch(hashID) {
case GT_HASHALG_SHA1: /* paper: SHA1 */
return 0x00;
case GT_HASHALG_RIPEMD160: /* paper: RIPEMD-160 */
return 0x02;
case GT_HASHALG_SHA224: /* paper: SHA2-224 */
return 0x03;
case GT_HASHALG_SHA256: /* paper: SHA2-256 */
return 0x01;
case GT_HASHALG_SHA384: /* paper: SHA2-384 */
return 0x04;
case GT_HASHALG_SHA512: /* paper: SHA2-512 */
return 0x05;
default:return 0xff;
}
}
const char *
hashAlgName(uint8_t hashID)
{
switch(hashID) {
case GT_HASHALG_SHA1:
return "SHA1";
case GT_HASHALG_RIPEMD160:
return "RIPEMD-160";
case GT_HASHALG_SHA224:
return "SHA2-224";
case GT_HASHALG_SHA256:
return "SHA2-256";
case GT_HASHALG_SHA384:
return "SHA2-384";
case GT_HASHALG_SHA512:
return "SHA2-512";
default:return "[unknown]";
}
}
enum GTHashAlgorithm
hashID2Alg(uint8_t hashID)
{
switch(hashID) {
case 0x00:
return GT_HASHALG_SHA1;
case 0x02:
return GT_HASHALG_RIPEMD160;
case 0x03:
return GT_HASHALG_SHA224;
case 0x01:
return GT_HASHALG_SHA256;
case 0x04:
return GT_HASHALG_SHA384;
case 0x05:
return GT_HASHALG_SHA512;
default:
return 0xff;
}
}
static void
reportErr(gtctx ctx, char *errmsg)
{
@ -90,6 +226,7 @@ rsgtsetErrFunc(gtctx ctx, void (*func)(void*, uchar *), void *usrptr)
ctx->errFunc = func;
}
imprint_t *
rsgtImprintFromGTDataHash(GTDataHash *hash)
{
@ -143,7 +280,7 @@ rsgtExit(void)
}
static inline gtfile
static gtfile
rsgtfileConstruct(gtctx ctx)
{
gtfile gf = NULL;
@ -159,7 +296,7 @@ rsgtfileConstruct(gtctx ctx)
done: return gf;
}
static inline int
static int
tlvbufPhysWrite(gtfile gf)
{
ssize_t lenBuf;
@ -194,7 +331,7 @@ finalize_it:
return r;
}
static inline int
static int
tlvbufChkWrite(gtfile gf)
{
if(gf->tlvIdx == sizeof(gf->tlvBuf)) {
@ -207,7 +344,7 @@ tlvbufChkWrite(gtfile gf)
/* write to TLV file buffer. If buffer is full, an actual call occurs. Else
* output is written only on flush or close.
*/
static inline int
static int
tlvbufAddOctet(gtfile gf, int8_t octet)
{
int r;
@ -216,7 +353,7 @@ tlvbufAddOctet(gtfile gf, int8_t octet)
gf->tlvBuf[gf->tlvIdx++] = octet;
done: return r;
}
static inline int
static int
tlvbufAddOctetString(gtfile gf, uint8_t *octet, int size)
{
int i, r = 0;
@ -227,7 +364,7 @@ tlvbufAddOctetString(gtfile gf, uint8_t *octet, int size)
done: return r;
}
/* return the actual length in to-be-written octets of an integer */
static inline uint8_t
static uint8_t
tlvbufGetInt64OctetSize(uint64_t val)
{
if(val >> 56)
@ -246,7 +383,7 @@ tlvbufGetInt64OctetSize(uint64_t val)
return 2;
return 1;
}
static inline int
static int
tlvbufAddInt64(gtfile gf, uint64_t val)
{
uint8_t doWrite = 0;
@ -635,7 +772,7 @@ done: return;
/* concat: add IV to buffer */
static inline void
static void
bufAddIV(gtfile gf, uchar *buf, size_t *len)
{
int hashlen;
@ -648,7 +785,7 @@ bufAddIV(gtfile gf, uchar *buf, size_t *len)
/* concat: add imprint to buffer */
static inline void
static void
bufAddImprint(uchar *buf, size_t *len, imprint_t *imp)
{
buf[*len] = imp->hashID;
@ -658,7 +795,7 @@ bufAddImprint(uchar *buf, size_t *len, imprint_t *imp)
}
/* concat: add hash to buffer */
static inline void
static void
bufAddHash(gtfile gf, uchar *buf, size_t *len, GTDataHash *hash)
{
buf[*len] = hashIdentifier(gf->hashAlg);
@ -667,7 +804,7 @@ bufAddHash(gtfile gf, uchar *buf, size_t *len, GTDataHash *hash)
*len += hash->digest_length;
}
/* concat: add tree level to buffer */
static inline void
static void
bufAddLevel(uchar *buf, size_t *len, uint8_t level)
{
memcpy(buf+*len, &level, sizeof(level));

View File

@ -1,6 +1,6 @@
/* librsgt.h - rsyslog's guardtime support library
*
* Copyright 2013 Adiscon GmbH.
* Copyright 2013-2016 Adiscon GmbH.
*
* This file is part of rsyslog.
*
@ -149,140 +149,11 @@ struct rsgtstatefile {
* Note: it is thread-safe to call this function, as it returns a pointer
* into constant memory pool.
*/
static inline char *
RSGTE2String(int err)
{
switch(err) {
case 0:
return "success";
case RSGTE_IO:
return "i/o error";
case RSGTE_FMT:
return "data format error";
case RSGTE_INVLTYP:
return "invalid/unexpected tlv record type";
case RSGTE_OOM:
return "out of memory";
case RSGTE_LEN:
return "length record problem";
case RSGTE_TS_EXTEND:
return "error extending timestamp";
case RSGTE_INVLD_RECCNT:
return "mismatch between actual record count and number in block signature record";
case RSGTE_INVLHDR:
return "invalid file header";
case RSGTE_EOF:
return "EOF";
case RSGTE_MISS_REC_HASH:
return "record hash missing";
case RSGTE_MISS_TREE_HASH:
return "tree hash missing";
case RSGTE_INVLD_REC_HASH:
return "record hash mismatch";
case RSGTE_INVLD_TREE_HASH:
return "tree hash mismatch";
case RSGTE_INVLD_REC_HASHID:
return "invalid record hash ID";
case RSGTE_INVLD_TREE_HASHID:
return "invalid tree hash ID";
case RSGTE_MISS_BLOCKSIG:
return "missing block signature record";
case RSGTE_INVLD_TIMESTAMP:
return "RFC3161 timestamp invalid";
case RSGTE_TS_DERDECODE:
return "error DER-decoding RFC3161 timestamp";
case RSGTE_TS_DERENCODE:
return "error DER-encoding RFC3161 timestamp";
case RSGTE_HASH_CREATE:
return "error creating hash";
case RSGTE_END_OF_SIG:
return "unexpected end of signature";
case RSGTE_END_OF_LOG:
return "unexpected end of log";
default:
return "unknown error";
}
}
static inline uint16_t
hashOutputLengthOctets(uint8_t hashID)
{
switch(hashID) {
case GT_HASHALG_SHA1: /* paper: SHA1 */
return 20;
case GT_HASHALG_RIPEMD160: /* paper: RIPEMD-160 */
return 20;
case GT_HASHALG_SHA224: /* paper: SHA2-224 */
return 28;
case GT_HASHALG_SHA256: /* paper: SHA2-256 */
return 32;
case GT_HASHALG_SHA384: /* paper: SHA2-384 */
return 48;
case GT_HASHALG_SHA512: /* paper: SHA2-512 */
return 64;
default:return 32;
}
}
static inline uint8_t
hashIdentifier(enum GTHashAlgorithm hashID)
{
switch(hashID) {
case GT_HASHALG_SHA1: /* paper: SHA1 */
return 0x00;
case GT_HASHALG_RIPEMD160: /* paper: RIPEMD-160 */
return 0x02;
case GT_HASHALG_SHA224: /* paper: SHA2-224 */
return 0x03;
case GT_HASHALG_SHA256: /* paper: SHA2-256 */
return 0x01;
case GT_HASHALG_SHA384: /* paper: SHA2-384 */
return 0x04;
case GT_HASHALG_SHA512: /* paper: SHA2-512 */
return 0x05;
default:return 0xff;
}
}
static inline char *
hashAlgName(uint8_t hashID)
{
switch(hashID) {
case GT_HASHALG_SHA1:
return "SHA1";
case GT_HASHALG_RIPEMD160:
return "RIPEMD-160";
case GT_HASHALG_SHA224:
return "SHA2-224";
case GT_HASHALG_SHA256:
return "SHA2-256";
case GT_HASHALG_SHA384:
return "SHA2-384";
case GT_HASHALG_SHA512:
return "SHA2-512";
default:return "[unknown]";
}
}
static inline enum GTHashAlgorithm
hashID2Alg(uint8_t hashID)
{
switch(hashID) {
case 0x00:
return GT_HASHALG_SHA1;
case 0x02:
return GT_HASHALG_RIPEMD160;
case 0x03:
return GT_HASHALG_SHA224;
case 0x01:
return GT_HASHALG_SHA256;
case 0x04:
return GT_HASHALG_SHA384;
case 0x05:
return GT_HASHALG_SHA512;
default:
return 0xff;
}
}
const char * RSGTE2String(int err);
uint16_t hashOutputLengthOctets(uint8_t hashID);
uint8_t hashIdentifier(enum GTHashAlgorithm hashID);
const char * hashAlgName(uint8_t hashID);
enum GTHashAlgorithm hashID2Alg(uint8_t hashID);
static inline uint16_t
getIVLen(block_hdr_t *bh)

View File

@ -86,15 +86,7 @@ struct block_hashchain_s {
};
static inline char *
sigTypeName(uint8_t sigID)
{
switch(sigID) {
case SIGID_RFC3161:
return "RFC3161";
default:return "[unknown]";
}
}
#define sigTypeName(sigID) ( ((sigID) == SIGID_RFC3161) ? "RFC3161" : "[unknown]" )
/* Flags and record types for TLV handling */
#define RSGT_FLAG_NONCRIT 0x20
@ -107,4 +99,4 @@ sigTypeName(uint8_t sigID)
/* check return state of operation and jump to donedecode, if non-OK */
#define CHKrDecode(code) if((r = code) != 0) goto donedecode
#endif /* #ifndef INCLUDED_LIBRSGTCM_H */
#endif /* #ifndef INCLUDED_LIBRSGTCM_H */

View File

@ -17,7 +17,7 @@
* information (most importantly last block hash) and sigblkConstruct
* reads (or initilizes if not present) it.
*
* Copyright 2013-2015 Adiscon GmbH.
* Copyright 2013-2016 Adiscon GmbH.
*
* This file is part of rsyslog.
*
@ -62,8 +62,189 @@ typedef unsigned char uchar;
int RSKSI_FLAG_TLV16_RUNTIME = RSGT_FLAG_TLV16;
int RSKSI_FLAG_NONCRIT_RUNTIME = RSGT_FLAG_NONCRIT;
/* the following function maps RSGTE_* state to a string - must be updated
* whenever a new state is added.
* Note: it is thread-safe to call this function, as it returns a pointer
* into constant memory pool.
*/
const char *
RSKSIE2String(int err)
{
switch(err) {
case RSGTE_SUCCESS:
return "success";
case RSGTE_IO:
return "i/o error";
case RSGTE_FMT:
return "data format error";
case RSGTE_INVLTYP:
return "invalid/unexpected tlv record type";
case RSGTE_OOM:
return "out of memory";
case RSGTE_LEN:
return "length record problem";
case RSGTE_SIG_EXTEND:
return "error extending signature";
case RSGTE_INVLD_RECCNT:
return "mismatch between actual record count and number in block signature record";
case RSGTE_INVLHDR:
return "invalid file header";
case RSGTE_EOF:
return "EOF";
case RSGTE_MISS_REC_HASH:
return "record hash missing";
case RSGTE_MISS_TREE_HASH:
return "tree hash missing";
case RSGTE_INVLD_REC_HASH:
return "record hash mismatch";
case RSGTE_INVLD_TREE_HASH:
return "tree hash mismatch";
case RSGTE_INVLD_REC_HASHID:
return "invalid record hash ID";
case RSGTE_INVLD_TREE_HASHID:
return "invalid tree hash ID";
case RSGTE_MISS_BLOCKSIG:
return "missing block signature record";
case RSGTE_INVLD_SIGNATURE:
return "Signature invalid";
case RSGTE_TS_CREATEHASH:
return "error creating HASH";
case RSGTE_TS_DERENCODE:
return "error DER-encoding RFC3161 timestamp";
case RSGTE_HASH_CREATE:
return "error creating hash";
case RSGTE_END_OF_SIG:
return "unexpected end of signature";
case RSGTE_END_OF_LOG:
return "unexpected end of log";
case RSGTE_EXTRACT_HASH:
return "either record-hash, left-hash or right-hash was empty";
default:
return "unknown error";
}
}
uint16_t
hashOutputLengthOctetsKSI(uint8_t hashID)
{
switch(hashID) {
case KSI_HASHALG_SHA1: /** The SHA-1 algorithm. */
return 20;
case KSI_HASHALG_SHA2_256: /** The SHA-256 algorithm. */
return 32;
case KSI_HASHALG_RIPEMD160: /** The RIPEMD-160 algorithm. */
return 20;
case KSI_HASHALG_SHA2_224: /** The SHA-224 algorithm. */
return 28;
case KSI_HASHALG_SHA2_384: /** The SHA-384 algorithm. */
return 48;
case KSI_HASHALG_SHA2_512: /** The SHA-512 algorithm. */
return 64;
case KSI_HASHALG_SHA3_244: /** The SHA3-244 algorithm. */
return 28;
case KSI_HASHALG_SHA3_256: /** The SHA3-256 algorithm. */
return 32;
case KSI_HASHALG_SHA3_384: /** The SHA3-384 algorithm. */
return 48;
case KSI_HASHALG_SHA3_512: /** The SHA3-512 algorithm */
return 64;
case KSI_HASHALG_SM3: /** The SM3 algorithm.*/
return 32;
default:return 32;
}
}
uint8_t
hashIdentifierKSI(KSI_HashAlgorithm hashID)
{
switch(hashID) {
case KSI_HASHALG_SHA1: /** The SHA-1 algorithm. */
return 0x00;
case KSI_HASHALG_SHA2_256: /** The SHA-256 algorithm. */
return 0x01;
case KSI_HASHALG_RIPEMD160: /** The RIPEMD-160 algorithm. */
return 0x02;
case KSI_HASHALG_SHA2_224: /** The SHA-224 algorithm. */
return 0x03;
case KSI_HASHALG_SHA2_384: /** The SHA-384 algorithm. */
return 0x04;
case KSI_HASHALG_SHA2_512: /** The SHA-512 algorithm. */
return 0x05;
case KSI_HASHALG_SHA3_244: /** The SHA3-244 algorithm. */
return 0x07;
case KSI_HASHALG_SHA3_256: /** The SHA3-256 algorithm. */
return 0x08;
case KSI_HASHALG_SHA3_384: /** The SHA3-384 algorithm. */
return 0x09;
case KSI_HASHALG_SHA3_512: /** The SHA3-512 algorithm */
return 0x0a;
case KSI_HASHALG_SM3: /** The SM3 algorithm.*/
return 0x0b;
case KSI_NUMBER_OF_KNOWN_HASHALGS: /* TODO: what is this??? */
default:return 0xff;
}
}
const char *
hashAlgNameKSI(uint8_t hashID)
{
switch(hashID) {
case KSI_HASHALG_SHA1:
return "SHA1";
case KSI_HASHALG_SHA2_256:
return "SHA2-256";
case KSI_HASHALG_RIPEMD160:
return "RIPEMD-160";
case KSI_HASHALG_SHA2_224:
return "SHA2-224";
case KSI_HASHALG_SHA2_384:
return "SHA2-384";
case KSI_HASHALG_SHA2_512:
return "SHA2-512";
case KSI_HASHALG_SHA3_244:
return "SHA3-224";
case KSI_HASHALG_SHA3_256:
return "SHA3-256";
case KSI_HASHALG_SHA3_384:
return "SHA3-384";
case KSI_HASHALG_SHA3_512:
return "SHA3-512";
case KSI_HASHALG_SM3:
return "SM3";
default:return "[unknown]";
}
}
KSI_HashAlgorithm
hashID2AlgKSI(uint8_t hashID)
{
switch(hashID) {
case 0x00:
return KSI_HASHALG_SHA1;
case 0x01:
return KSI_HASHALG_SHA2_256;
case 0x02:
return KSI_HASHALG_RIPEMD160;
case 0x03:
return KSI_HASHALG_SHA2_224;
case 0x04:
return KSI_HASHALG_SHA2_384;
case 0x05:
return KSI_HASHALG_SHA2_512;
case 0x07:
return KSI_HASHALG_SHA3_244;
case 0x08:
return KSI_HASHALG_SHA3_256;
case 0x09:
return KSI_HASHALG_SHA3_384;
case 0x0a:
return KSI_HASHALG_SHA3_512;
case 0x0b:
return KSI_HASHALG_SM3;
default:
return 0xff;
}
}
static void
reportErr(rsksictx ctx, char *errmsg)
reportErr(rsksictx ctx, const char *const errmsg)
{
if(ctx->errFunc == NULL)
goto done;
@ -72,7 +253,7 @@ done: return;
}
void
reportKSIAPIErr(rsksictx ctx, ksifile ksi, char *apiname, int ecode)
reportKSIAPIErr(rsksictx ctx, ksifile ksi, const char *apiname, int ecode)
{
char errbuf[4096];
snprintf(errbuf, sizeof(errbuf), "%s[%s:%d]: %s",
@ -157,7 +338,7 @@ rsksiExit(void)
return;
}
static inline ksifile
static ksifile
rsksifileConstruct(rsksictx ctx)
{
ksifile ksi = NULL;
@ -173,7 +354,7 @@ rsksifileConstruct(rsksictx ctx)
done: return ksi;
}
static inline size_t
static size_t
tlvbufPhysWrite(ksifile ksi)
{
ssize_t lenBuf;
@ -208,7 +389,7 @@ finalize_it:
return r;
}
static inline size_t
static size_t
tlvbufChkWrite(ksifile ksi)
{
if(ksi->tlvIdx == sizeof(ksi->tlvBuf)) {
@ -221,7 +402,7 @@ tlvbufChkWrite(ksifile ksi)
/* write to TLV file buffer. If buffer is full, an actual call occurs. Else
* output is written only on flush or close.
*/
static inline size_t
static size_t
tlvbufAddOctet(ksifile ksi, int8_t octet)
{
size_t r;
@ -230,7 +411,7 @@ tlvbufAddOctet(ksifile ksi, int8_t octet)
ksi->tlvBuf[ksi->tlvIdx++] = octet;
done: return r;
}
static inline size_t
static size_t
tlvbufAddOctetString(ksifile ksi, uint8_t *octet, size_t size)
{
size_t i, r = 0;
@ -241,7 +422,7 @@ tlvbufAddOctetString(ksifile ksi, uint8_t *octet, size_t size)
done: return r;
}
/* return the actual length in to-be-written octets of an integer */
static inline uint8_t
static uint8_t
tlvbufGetInt64OctetSize(uint64_t val)
{
if(val >> 56)
@ -260,7 +441,7 @@ tlvbufGetInt64OctetSize(uint64_t val)
return 2;
return 1;
}
static inline int
static int
tlvbufAddInt64(ksifile ksi, uint64_t val)
{
uint8_t doWrite = 0;
@ -298,7 +479,7 @@ done: return r;
}
int
static int
tlv8WriteKSI(ksifile ksi, int flags, int tlvtype, int len)
{
int r;
@ -310,7 +491,7 @@ tlv8WriteKSI(ksifile ksi, int flags, int tlvtype, int len)
done: return r;
}
int
static int
tlv16WriteKSI(ksifile ksi, int flags, int tlvtype, uint16_t len)
{
uint16_t typ;
@ -328,13 +509,13 @@ tlv16WriteKSI(ksifile ksi, int flags, int tlvtype, uint16_t len)
done: return r;
}
int
static int
tlvFlushKSI(ksifile ksi)
{
return (ksi->tlvIdx == 0) ? 0 : tlvbufPhysWrite(ksi);
}
int
static int
tlvWriteHashKSI(ksifile ksi, uint16_t tlvtype, KSI_DataHash *rec)
{
unsigned tlvlen;
@ -355,7 +536,7 @@ tlvWriteHashKSI(ksifile ksi, uint16_t tlvtype, KSI_DataHash *rec)
done: return r;
}
int
static int
tlvWriteBlockHdrKSI(ksifile ksi) {
unsigned tlvlen;
int r;
@ -378,7 +559,7 @@ tlvWriteBlockHdrKSI(ksifile ksi) {
done: return r;
}
int
static int
tlvWriteBlockSigKSI(ksifile ksi, uchar *der, uint16_t lenDer)
{
unsigned tlvlen;
@ -482,7 +663,7 @@ done: return;
}
int
static int
tlvCloseKSI(ksifile ksi)
{
int r;
@ -497,8 +678,8 @@ tlvCloseKSI(ksifile ksi)
/* note: if file exists, the last hash for chaining must
* be read from file.
*/
int
tlvOpenKSI(ksifile ksi, char *hdr, unsigned lenHdr)
static int
tlvOpenKSI(ksifile ksi, const char *const hdr, unsigned lenHdr)
{
int r = 0;
ksi->fd = open((char*)ksi->sigfilename,
@ -531,7 +712,7 @@ done: return r;
* (and he had good proof that I currently am not permitted to
* reproduce). -- rgerhards, 2013-03-04
*/
void
static void
seedIVKSI(ksifile ksi)
{
int hashlen;
@ -670,7 +851,7 @@ done: return;
/* concat: add IV to buffer */
static inline void
static void
bufAddIV(ksifile ksi, uchar *buf, size_t *len)
{
int hashlen;
@ -683,7 +864,7 @@ bufAddIV(ksifile ksi, uchar *buf, size_t *len)
/* concat: add imprint to buffer */
static inline void
static void
bufAddImprint(uchar *buf, size_t *len, imprint_t *imp)
{
buf[*len] = imp->hashID;
@ -693,7 +874,7 @@ bufAddImprint(uchar *buf, size_t *len, imprint_t *imp)
}
/* concat: add hash to buffer */
static inline void
static void
bufAddHash(ksifile ksi, uchar *buf, size_t *len, KSI_DataHash *hash)
{
int r;

View File

@ -147,207 +147,16 @@ struct rsksistatefile {
#define RSGTE_CONFIG_ERROR 24 /* Configuration error */
#define RSGTE_NETWORK_ERROR 25 /* Network error */
/* the following function maps RSGTE_* state to a string - must be updated
* whenever a new state is added.
* Note: it is thread-safe to call this function, as it returns a pointer
* into constant memory pool.
*/
static inline char *
RSKSIE2String(int err)
{
switch(err) {
case RSGTE_SUCCESS:
return "success";
case RSGTE_IO:
return "i/o error";
case RSGTE_FMT:
return "data format error";
case RSGTE_INVLTYP:
return "invalid/unexpected tlv record type";
case RSGTE_OOM:
return "out of memory";
case RSGTE_LEN:
return "length record problem";
case RSGTE_SIG_EXTEND:
return "error extending signature";
case RSGTE_INVLD_RECCNT:
return "mismatch between actual record count and number in block signature record";
case RSGTE_INVLHDR:
return "invalid file header";
case RSGTE_EOF:
return "EOF";
case RSGTE_MISS_REC_HASH:
return "record hash missing";
case RSGTE_MISS_TREE_HASH:
return "tree hash missing";
case RSGTE_INVLD_REC_HASH:
return "record hash mismatch";
case RSGTE_INVLD_TREE_HASH:
return "tree hash mismatch";
case RSGTE_INVLD_REC_HASHID:
return "invalid record hash ID";
case RSGTE_INVLD_TREE_HASHID:
return "invalid tree hash ID";
case RSGTE_MISS_BLOCKSIG:
return "missing block signature record";
case RSGTE_INVLD_SIGNATURE:
return "Signature invalid";
case RSGTE_TS_CREATEHASH:
return "error creating HASH";
case RSGTE_TS_DERENCODE:
return "error DER-encoding RFC3161 timestamp";
case RSGTE_HASH_CREATE:
return "error creating hash";
case RSGTE_END_OF_SIG:
return "unexpected end of signature";
case RSGTE_END_OF_LOG:
return "unexpected end of log";
case RSGTE_EXTRACT_HASH:
return "either record-hash, left-hash or right-hash was empty";
default:
return "unknown error";
}
}
const char * RSKSIE2String(int err);
uint16_t hashOutputLengthOctetsKSI(uint8_t hashID);
uint8_t hashIdentifierKSI(KSI_HashAlgorithm hashID);
const char * hashAlgNameKSI(uint8_t hashID);
KSI_HashAlgorithm hashID2AlgKSI(uint8_t hashID);
static inline uint16_t
hashOutputLengthOctetsKSI(uint8_t hashID)
{
switch(hashID) {
case KSI_HASHALG_SHA1: /** The SHA-1 algorithm. */
return 20;
case KSI_HASHALG_SHA2_256: /** The SHA-256 algorithm. */
return 32;
case KSI_HASHALG_RIPEMD160: /** The RIPEMD-160 algorithm. */
return 20;
case KSI_HASHALG_SHA2_224: /** The SHA-224 algorithm. */
return 28;
case KSI_HASHALG_SHA2_384: /** The SHA-384 algorithm. */
return 48;
case KSI_HASHALG_SHA2_512: /** The SHA-512 algorithm. */
return 64;
case KSI_HASHALG_SHA3_244: /** The SHA3-244 algorithm. */
return 28;
case KSI_HASHALG_SHA3_256: /** The SHA3-256 algorithm. */
return 32;
case KSI_HASHALG_SHA3_384: /** The SHA3-384 algorithm. */
return 48;
case KSI_HASHALG_SHA3_512: /** The SHA3-512 algorithm */
return 64;
case KSI_HASHALG_SM3: /** The SM3 algorithm.*/
return 32;
default:return 32;
}
}
static inline uint8_t
hashIdentifierKSI(KSI_HashAlgorithm hashID)
{
switch(hashID) {
case KSI_HASHALG_SHA1: /** The SHA-1 algorithm. */
return 0x00;
case KSI_HASHALG_SHA2_256: /** The SHA-256 algorithm. */
return 0x01;
case KSI_HASHALG_RIPEMD160: /** The RIPEMD-160 algorithm. */
return 0x02;
case KSI_HASHALG_SHA2_224: /** The SHA-224 algorithm. */
return 0x03;
case KSI_HASHALG_SHA2_384: /** The SHA-384 algorithm. */
return 0x04;
case KSI_HASHALG_SHA2_512: /** The SHA-512 algorithm. */
return 0x05;
case KSI_HASHALG_SHA3_244: /** The SHA3-244 algorithm. */
return 0x07;
case KSI_HASHALG_SHA3_256: /** The SHA3-256 algorithm. */
return 0x08;
case KSI_HASHALG_SHA3_384: /** The SHA3-384 algorithm. */
return 0x09;
case KSI_HASHALG_SHA3_512: /** The SHA3-512 algorithm */
return 0x0a;
case KSI_HASHALG_SM3: /** The SM3 algorithm.*/
return 0x0b;
default:return 0xff;
}
}
static inline char *
hashAlgNameKSI(uint8_t hashID)
{
switch(hashID) {
case KSI_HASHALG_SHA1:
return "SHA1";
case KSI_HASHALG_SHA2_256:
return "SHA2-256";
case KSI_HASHALG_RIPEMD160:
return "RIPEMD-160";
case KSI_HASHALG_SHA2_224:
return "SHA2-224";
case KSI_HASHALG_SHA2_384:
return "SHA2-384";
case KSI_HASHALG_SHA2_512:
return "SHA2-512";
case KSI_HASHALG_SHA3_244:
return "SHA3-224";
case KSI_HASHALG_SHA3_256:
return "SHA3-256";
case KSI_HASHALG_SHA3_384:
return "SHA3-384";
case KSI_HASHALG_SHA3_512:
return "SHA3-512";
case KSI_HASHALG_SM3:
return "SM3";
default:return "[unknown]";
}
}
static inline KSI_HashAlgorithm
hashID2AlgKSI(uint8_t hashID)
{
switch(hashID) {
case 0x00:
return KSI_HASHALG_SHA1;
case 0x01:
return KSI_HASHALG_SHA2_256;
case 0x02:
return KSI_HASHALG_RIPEMD160;
case 0x03:
return KSI_HASHALG_SHA2_224;
case 0x04:
return KSI_HASHALG_SHA2_384;
case 0x05:
return KSI_HASHALG_SHA2_512;
case 0x07:
return KSI_HASHALG_SHA3_244;
case 0x08:
return KSI_HASHALG_SHA3_256;
case 0x09:
return KSI_HASHALG_SHA3_384;
case 0x0a:
return KSI_HASHALG_SHA3_512;
case 0x0b:
return KSI_HASHALG_SM3;
default:
return 0xff;
}
}
static inline uint16_t
getIVLenKSI(block_hdr_t *bh)
{
return hashOutputLengthOctetsKSI(bh->hashID);
}
static inline void
rsksiSetBlockSizeLimit(rsksictx ctx, uint64_t limit)
{
ctx->blockSizeLimit = limit;
}
static inline void
rsksiSetKeepRecordHashes(rsksictx ctx, int val)
{
ctx->bKeepRecordHashes = val;
}
static inline void
rsksiSetKeepTreeHashes(rsksictx ctx, int val)
{
ctx->bKeepTreeHashes = val;
}
#define getIVLenKSI(bh) (hashOutputLengthOctetsKSI((bh)->hashID))
#define rsksiSetBlockSizeLimit(ctx, limit) ((ctx)->blockSizeLimit = limit)
#define rsksiSetKeepRecordHashes(ctx, val) ((ctx)->bKeepRecordHashes = val)
#define rsksiSetKeepTreeHashes(ctx, val) ((ctx)->bKeepTreeHashes = val)
int rsksiSetAggregator(rsksictx ctx, char *uri, char *loginid, char *key);
int rsksiSetHashFunction(rsksictx ctx, char *algName);
@ -355,7 +164,7 @@ int rsksiInit(char *usragent);
void rsksiExit(void);
rsksictx rsksiCtxNew(void);
void rsksisetErrFunc(rsksictx ctx, void (*func)(void*, unsigned char *), void *usrptr);
void reportKSIAPIErr(rsksictx ctx, ksifile ksi, char *apiname, int ecode);
void reportKSIAPIErr(rsksictx ctx, ksifile ksi, const char *apiname, int ecode);
ksifile rsksiCtxOpenFile(rsksictx ctx, unsigned char *logfn);
int rsksifileDestruct(ksifile ksi);
void rsksiCtxDel(rsksictx ctx);
@ -397,16 +206,16 @@ int rsksi_tlvDecodeHASHCHAIN(tlvrecord_t *rec, block_hashchain_t **blhashchain);
int verifySigblkFinish(ksifile ksi, KSI_DataHash **pRoot);
int verifySigblkFinishChain(ksifile ksi, block_hashchain_t *hashchain, KSI_DataHash **pRoot, ksierrctx_t *ectx);
void outputHash(FILE *fp, const char *hdr, const uint8_t *data, const uint16_t len, const uint8_t verbose);
void outputKSIHash(FILE *fp, char *hdr, const KSI_DataHash *const __restrict__ hash, const uint8_t verbose);
void outputKSIHash(FILE *fp, const char *hdr, const KSI_DataHash *const __restrict__ hash, const uint8_t verbose);
/* TODO: replace these? */
int hash_m_ksi(ksifile ksi, KSI_DataHash **m);
int hash_r_ksi(ksifile ksi, KSI_DataHash **r, const unsigned char *rec, const size_t len);
int hash_node_ksi(ksifile ksi, KSI_DataHash **node, KSI_DataHash *m, KSI_DataHash *r, uint8_t level);
extern char *rsksi_read_puburl; /**< url of publication server */
extern char *rsksi_extend_puburl; /**< url of extension server */
extern char *rsksi_userid; /**< userid for extension server */
extern char *rsksi_userkey; /**< userkey for extension server */
extern const char *rsksi_read_puburl; /**< url of publication server */
extern const char *rsksi_extend_puburl; /**< url of extension server */
extern const char *rsksi_userid; /**< userid for extension server */
extern const char *rsksi_userkey; /**< userkey for extension server */
extern uint8_t rsksi_read_showVerified;
extern int RSKSI_FLAG_TLV16_RUNTIME;
extern int RSKSI_FLAG_NONCRIT_RUNTIME;

View File

@ -41,21 +41,20 @@
#include <fcntl.h>
#include <ksi/ksi.h>
#include "rsyslog.h"
#include "librsgt_common.h"
#include "librsksi.h"
typedef unsigned char uchar;
#ifndef VERSION
#define VERSION "no-version"
#endif
#define MAXFNAME 1024
static int rsksi_read_debug = 0;
char *rsksi_read_puburl = ""; /* old default http://verify.guardtime.com/gt-controlpublications.bin";*/
char *rsksi_extend_puburl = ""; /* old default "http://verifier.guardtime.net/gt-extendingservice";*/
char *rsksi_userid = "";
char *rsksi_userkey = "";
const char *rsksi_read_puburl = ""; /* old default http://verify.guardtime.com/gt-controlpublications.bin";*/
const char *rsksi_extend_puburl = ""; /* old default "http://verifier.guardtime.net/gt-extendingservice";*/
const char *rsksi_userid = "";
const char *rsksi_userkey = "";
uint8_t rsksi_read_showVerified = 0;
/* macro to obtain next char from file including error tracking */
@ -82,7 +81,7 @@ outputHexBlob(FILE *fp, const uint8_t *blob, const uint16_t len, const uint8_t v
}
void
outputKSIHash(FILE *fp, char *hdr, const KSI_DataHash *const __restrict__ hash, const uint8_t verbose)
outputKSIHash(FILE *fp, const char *hdr, const KSI_DataHash *const __restrict__ hash, const uint8_t verbose)
{
const unsigned char *digest;
size_t digest_len;
@ -212,7 +211,7 @@ reportVerifySuccess(ksierrctx_t *ectx) /*OLD CODE , GTVerificationInfo *vrfyInf)
}
/* return the actual length in to-be-written octets of an integer */
static inline uint8_t rsksi_tlvGetInt64OctetSize(uint64_t val)
static uint8_t rsksi_tlvGetInt64OctetSize(uint64_t val)
{
if(val >> 56)
return 8;
@ -231,7 +230,7 @@ static inline uint8_t rsksi_tlvGetInt64OctetSize(uint64_t val)
return 1;
}
static inline int rsksi_tlvfileAddOctet(FILE *newsigfp, int8_t octet)
static int rsksi_tlvfileAddOctet(FILE *newsigfp, int8_t octet)
{
/* Directory write into file */
int r = 0;
@ -239,7 +238,7 @@ static inline int rsksi_tlvfileAddOctet(FILE *newsigfp, int8_t octet)
r = RSGTE_IO;
return r;
}
static inline int rsksi_tlvfileAddOctetString(FILE *newsigfp, uint8_t *octet, int size)
static int rsksi_tlvfileAddOctetString(FILE *newsigfp, uint8_t *octet, int size)
{
int i, r = 0;
for(i = 0 ; i < size ; ++i) {
@ -248,7 +247,7 @@ static inline int rsksi_tlvfileAddOctetString(FILE *newsigfp, uint8_t *octet, in
}
done: return r;
}
static inline int rsksi_tlvfileAddInt64(FILE *newsigfp, uint64_t val)
static int rsksi_tlvfileAddInt64(FILE *newsigfp, uint64_t val)
{
uint8_t doWrite = 0;
int r;
@ -611,7 +610,7 @@ done:
}
return r;
}
int
static int
rsksi_tlvDecodeHASH_CHAIN(tlvrecord_t *rec, block_hashchain_t **blhashchain)
{
int r = 1;
@ -950,7 +949,7 @@ done:
/* return if a blob is all zero */
static inline int
static int
blobIsZero(uint8_t *blob, uint16_t len)
{
int i;
@ -961,7 +960,7 @@ blobIsZero(uint8_t *blob, uint16_t len)
}
static void
rsksi_printIMPRINT(FILE *fp, char *name, imprint_t *imp, uint8_t verbose)
rsksi_printIMPRINT(FILE *fp, const char *name, imprint_t *imp, uint8_t verbose)
{
fprintf(fp, "%s", name);
outputHexBlob(fp, imp->data, imp->len, verbose);
@ -1039,7 +1038,7 @@ rsksi_printBLOCK_SIG(FILE *fp, block_sig_t *bs, uint8_t verbose)
* @param[in] bsig ponter to block_sig_t to output
* @param[in] verbose if 0, abbreviate blob hexdump, else complete
*/
void
static void
rsksi_printHASHCHAIN(FILE *fp, block_sig_t *bs, uint8_t verbose)
{
fprintf(fp, "[0x0905]HashChain Start Record:\n");
@ -1057,7 +1056,7 @@ rsksi_printHASHCHAIN(FILE *fp, block_sig_t *bs, uint8_t verbose)
* @param[in] hashchain step ponter to block_hashstep_s to output
* @param[in] verbose if 0, abbreviate blob hexdump, else complete
*/
void
static void
rsksi_printHASHCHAINSTEP(FILE *fp, block_hashchain_t *hschain, uint8_t verbose)
{
uint8_t j;
@ -1161,7 +1160,7 @@ rsksi_objfree(uint16_t tlvtype, void *obj)
free(obj);
}
block_hashstep_t*
static block_hashstep_t*
rsksiHashstepFromKSI_DataHash(ksifile ksi, KSI_DataHash *hash)
{
int r;
@ -2023,7 +2022,7 @@ return r;
memcpy(newrec.data+iWr, subrec.data, subrec.tlvlen); \
iWr += subrec.tlvlen;
static inline int
static int
rsksi_extendSig(KSI_Signature *sig, ksifile ksi, tlvrecord_t *rec, ksierrctx_t *ectx)
{
KSI_Signature *extended = NULL;

View File

@ -42,7 +42,7 @@
/* Initialize an existing linkedList_t structure
* pKey destructor may be zero to take care of non-keyed lists.
*/
rsRetVal llInit(linkedList_t *pThis, rsRetVal (*pEltDestructor)(), rsRetVal (*pKeyDestructor)(void*), int (*pCmpOp)())
rsRetVal llInit(linkedList_t *pThis, rsRetVal (*pEltDestructor)(void*), rsRetVal (*pKeyDestructor)(void*), int (*pCmpOp)(void*,void*))
{
assert(pThis != NULL);
assert(pEltDestructor != NULL);

View File

@ -52,7 +52,7 @@ typedef struct linkedList_s linkedList_t;
typedef llElt_t* linkedListCookie_t; /* this type avoids exposing internals and keeps us flexible */
/* prototypes */
rsRetVal llInit(linkedList_t *pThis, rsRetVal (*pEltDestructor)(), rsRetVal (*pKeyDestructor)(void*), int (*pCmpOp)());
rsRetVal llInit(linkedList_t *pThis, rsRetVal (*pEltDestructor)(), rsRetVal (*pKeyDestructor)(), int (*pCmpOp)());
rsRetVal llDestroy(linkedList_t *pThis);
rsRetVal llDestroyRootElt(linkedList_t *pThis);
rsRetVal llGetNextElt(linkedList_t *pThis, linkedListCookie_t *ppElt, void **ppUsr);

View File

@ -82,7 +82,7 @@ ENDobjDestruct(lmsig_gt)
* after construction, but before the OnFileOpen() entry point.
* Defaults are expected to have been set during construction.
*/
rsRetVal
static rsRetVal
SetCnfParam(void *pT, struct nvlst *lst)
{
lmsig_gt_t *pThis = (lmsig_gt_t*) pT;
@ -202,7 +202,7 @@ BEGINObjClassInit(lmsig_gt, 1, OBJ_IS_LOADABLE_MODULE) /* class, version */
CHKiRet(objUse(errmsg, CORE_COMPONENT));
CHKiRet(objUse(glbl, CORE_COMPONENT));
if(rsgtInit("rsyslogd " VERSION) != 0) {
if(rsgtInit((char*)"rsyslogd " VERSION) != 0) {
errmsg.LogError(0, RS_RET_SIGPROV_ERR, "error initializing "
"signature provider - cannot sign");
ABORT_FINALIZE(RS_RET_SIGPROV_ERR);

View File

@ -2,7 +2,7 @@
*
* An implementation of the sigprov interface for KSI.
*
* Copyright 2013-2015 Rainer Gerhards and Adiscon GmbH.
* Copyright 2013-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -84,7 +84,7 @@ ENDobjDestruct(lmsig_ksi)
* after construction, but before the OnFileOpen() entry point.
* Defaults are expected to have been set during construction.
*/
rsRetVal
static rsRetVal
SetCnfParam(void *pT, struct nvlst *lst)
{
char *ag_uri = NULL, *ag_loginid = NULL, *ag_key = NULL;

View File

@ -77,7 +77,7 @@ lookupTableReloader(void *self);
/* create a new lookup table object AND include it in our list of
* lookup tables.
*/
rsRetVal
static rsRetVal
lookupNew(lookup_ref_t **ppThis)
{
lookup_ref_t *pThis = NULL;
@ -203,7 +203,8 @@ lookupInitCnf(lookup_tables_t *lu_tabs)
}
void
lookupDestroyCnf() {
lookupDestroyCnf(void)
{
lookup_ref_t *luref, *luref_next;
for(luref = loadConf->lu_tabs.root ; luref != NULL ; ) {
luref_next = luref->next;
@ -573,7 +574,7 @@ finalize_it:
RETiRet;
}
rsRetVal
static rsRetVal
lookupBuildTable(lookup_t *pThis, struct json_object *jroot, const uchar* name)
{
struct json_object *jversion;
@ -689,7 +690,7 @@ finalize_it:
RETiRet;
}
uint8_t
static uint8_t
lookupIsReloadPending(lookup_ref_t *pThis) {
uint8_t reload_pending;
pthread_mutex_lock(&pThis->reloader_mut);
@ -750,7 +751,7 @@ finalize_it:
RETiRet;
}
static void *
void *
lookupTableReloader(void *self)
{
lookup_ref_t *pThis = (lookup_ref_t*) self;
@ -771,7 +772,7 @@ lookupTableReloader(void *self)
/* reload all lookup tables on HUP */
void
lookupDoHUP()
lookupDoHUP(void)
{
lookup_ref_t *luref;
for(luref = loadConf->lu_tabs.root ; luref != NULL ; luref = luref->next) {
@ -782,7 +783,7 @@ lookupDoHUP()
}
uint
lookupPendingReloadCount()
lookupPendingReloadCount(void)
{
uint pending_reload_count = 0;
lookup_ref_t *luref;

View File

@ -105,11 +105,11 @@ void lookupInitCnf(lookup_tables_t *lu_tabs);
rsRetVal lookupTableDefProcessCnf(struct cnfobj *o);
lookup_ref_t *lookupFindTable(uchar *name);
es_str_t * lookupKey(lookup_ref_t *pThis, lookup_key_t key);
void lookupDestroyCnf();
void lookupDestroyCnf(void);
void lookupClassExit(void);
void lookupDoHUP();
void lookupDoHUP(void);
rsRetVal lookupReload(lookup_ref_t *pThis, const uchar *stub_value_if_reload_fails);
uint lookupPendingReloadCount();
uint lookupPendingReloadCount(void);
rsRetVal lookupClassInit(void);
#endif /* #ifndef INCLUDED_LOOKUP_H */

View File

@ -770,7 +770,8 @@ static rsRetVal queryEtryPt(uchar *name, rsRetVal (**pEtryPoint)())\
* cached, left-in-memory copy of a previous incarnation.
*/
#define BEGINmodInit(uniqName) \
rsRetVal modInit##uniqName(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)(), rsRetVal (*pHostQueryEtryPt)(uchar*, rsRetVal (**)()), modInfo_t __attribute__((unused)) *pModInfo)\
rsRetVal __attribute__((unused)) modInit##uniqName(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)(), rsRetVal (*pHostQueryEtryPt)(uchar*, rsRetVal (**)()), modInfo_t __attribute__((unused)) *pModInfo);\
rsRetVal __attribute__((unused)) modInit##uniqName(int iIFVersRequested __attribute__((unused)), int *ipIFVersProvided, rsRetVal (**pQueryEtryPt)(), rsRetVal (*pHostQueryEtryPt)(uchar*, rsRetVal (**)()), modInfo_t __attribute__((unused)) *pModInfo)\
{\
DEFiRet; \
rsRetVal (*pObjGetObjInterface)(obj_if_t *pIf);

View File

@ -94,17 +94,17 @@ static struct cnfparamblk pblk =
* if the transactional entry points exist.
*/
static rsRetVal
dummyBeginTransaction()
dummyBeginTransaction(__attribute__((unused)) void * dummy)
{
return RS_RET_OK;
}
static rsRetVal
dummyEndTransaction()
dummyEndTransaction(__attribute__((unused)) void * dummy)
{
return RS_RET_OK;
}
static rsRetVal
dummyIsCompatibleWithFeature()
dummyIsCompatibleWithFeature(__attribute__((unused)) syslogFeature eFeat)
{
return RS_RET_INCOMPATIBLE;
}
@ -125,7 +125,7 @@ dummynewActInst(uchar *modName, struct nvlst __attribute__((unused)) *dummy1,
/* add a user to the current list of users (always at the root) */
static void
modUsrAdd(modInfo_t *pThis, char *pszUsr)
modUsrAdd(modInfo_t *pThis, const char *pszUsr)
{
modUsr_t *pUsr;
@ -152,7 +152,7 @@ finalize_it:
* rgerhards, 2008-03-11
*/
static void
modUsrDel(modInfo_t *pThis, char *pszUsr)
modUsrDel(modInfo_t *pThis, const char *pszUsr)
{
modUsr_t *pUsr;
modUsr_t *pPrev = NULL;
@ -201,8 +201,7 @@ modUsrPrint(modInfo_t *pThis)
* to be called at end of run to detect "module leaks" and who is causing them.
* rgerhards, 2008-03-11
*/
//static void
void
static void
modUsrPrintAll(void)
{
modInfo_t *pMod;
@ -1322,7 +1321,7 @@ SetModDir(uchar *pszModDir)
* called by anyone interested in using a module. -- rgerhards, 20080-03-10
*/
static rsRetVal
Use(char *srcFile, modInfo_t *pThis)
Use(const char *srcFile, modInfo_t *pThis)
{
DEFiRet;
@ -1345,7 +1344,7 @@ Use(char *srcFile, modInfo_t *pThis)
* module is unloaded. -- rgerhards, 20080-03-10
*/
static rsRetVal
Release(char *srcFile, modInfo_t **ppThis)
Release(const char *srcFile, modInfo_t **ppThis)
{
DEFiRet;
modInfo_t *pThis;

View File

@ -103,7 +103,7 @@ struct modInfo_s {
unsigned uRefCnt; /* reference count for this module; 0 -> may be unloaded */
sbool bSetModCnfCalled;/* is setModCnf already called? Needed for built-in modules */
/* functions supported by all types of modules */
rsRetVal (*modInit)(int, int*, rsRetVal(**)()); /* initialize the module */
rsRetVal (*modInit)(int, int*, rsRetVal(**)(void*)); /* initialize the module */
/* be sure to support version handshake! */
rsRetVal (*modQueryEtryPt)(uchar *name, rsRetVal (**EtryPoint)()); /* query entry point addresses */
rsRetVal (*isCompatibleWithFeature)(syslogFeature);
@ -172,8 +172,8 @@ BEGINinterface(module) /* name must also be changed in ENDinterface macro! */
cfgmodules_etry_t *(*GetNxtCnfType)(rsconf_t *cnf, cfgmodules_etry_t *pThis, eModType_t rqtdType);
uchar *(*GetName)(modInfo_t *pThis);
uchar *(*GetStateName)(modInfo_t *pThis);
rsRetVal (*Use)(char *srcFile, modInfo_t *pThis); /**< must be called before a module is used (ref counting) */
rsRetVal (*Release)(char *srcFile, modInfo_t **ppThis); /**< release a module (ref counting) */
rsRetVal (*Use)(const char *srcFile, modInfo_t *pThis); /**< must be called before a module is used (ref counting) */
rsRetVal (*Release)(const char *srcFile, modInfo_t **ppThis); /**< release a module (ref counting) */
void (*PrintList)(void);
rsRetVal (*UnloadAndDestructAll)(eModLinkType_t modLinkTypesToUnload);
rsRetVal (*doModInit)(rsRetVal (*modInit)(), uchar *name, void *pModHdlr, modInfo_t **pNew);
@ -181,7 +181,7 @@ BEGINinterface(module) /* name must also be changed in ENDinterface macro! */
rsRetVal (*SetModDir)(uchar *name);
modInfo_t *(*FindWithCnfName)(rsconf_t *cnf, uchar *name, eModType_t rqtdType); /* added v3, 2011-07-19 */
ENDinterface(module)
#define moduleCURR_IF_VERSION 4 /* increment whenever you change the interface structure! */
#define moduleCURR_IF_VERSION 5 /* increment whenever you change the interface structure! */
/* Changes:
* v2
* - added param bCondLoad to Load call - 2011-04-27

View File

@ -36,13 +36,13 @@
#include <assert.h>
#include <ctype.h>
#include <sys/socket.h>
#if HAVE_SYSINFO_UPTIME
#ifdef HAVE_SYSINFO_UPTIME
#include <sys/sysinfo.h>
#endif
#include <netdb.h>
#include <libestr.h>
#include <json.h>
#if HAVE_MALLOC_H
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
#ifdef USE_LIBUUID
@ -66,6 +66,10 @@
#include "parserif.h"
#include <errno.h>
/* inlines */
extern void msgSetPRI(msg_t *const __restrict__ pMsg, syslog_pri_t pri);
/* TODO: move the global variable root to the config object - had no time to to it
* right now before vacation -- rgerhards, 2013-07-22
*/
@ -81,9 +85,9 @@ DEFobjCurrIf(prop)
DEFobjCurrIf(net)
DEFobjCurrIf(var)
static char *one_digit[10] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const char *one_digit[10] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static char *two_digits[100] = {
static const char *two_digits[100] = {
"00", "01", "02", "03", "04", "05", "06", "07", "08", "09",
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
"20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
@ -95,10 +99,10 @@ static char *two_digits[100] = {
"80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
"90", "91", "92", "93", "94", "95", "96", "97", "98", "99"};
static char *wdayNames[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
static const char *wdayNames[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
/* Table of days in a year, needed for getYearDay */
static char *daysInYear[366] = {
static const char *daysInYear[366] = {
"001", "002", "003", "004", "005", "006", "007", "008", "009",
"010", "011", "012", "013", "014", "015", "016", "017", "018", "019",
"020", "021", "022", "023", "024", "025", "026", "027", "028", "029",
@ -142,7 +146,7 @@ static char *daysInYear[366] = {
* algos need to be upgraded after the year 2099 in any case.
* Quite honestly, I don't expect that this is a real problem ;)
*/
static char *years[] = {
static const char *years[] = {
"1967", "1968", "1969", "1970", "1971", "1972", "1973", "1974",
"1975", "1976", "1977", "1978", "1979", "1980", "1981", "1982",
"1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990",
@ -371,7 +375,7 @@ static char hexdigit[16] =
'9', 'A', 'B', 'C', 'D', 'E', 'F' };
/*syslog facility names (as of RFC5424) */
static char *syslog_fac_names[LOG_NFACILITIES] = { "kern", "user", "mail", "daemon", "auth", "syslog", "lpr",
static const 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", "invld" };
@ -382,14 +386,14 @@ static short len_syslog_fac_names[LOG_NFACILITIES] = { 4, 4, 4, 6, 4, 6, 3,
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" };
static const char *syslog_severity_names[8] = { "emerg", "alert", "crit", "err", "warning", "notice", "info", "debug" };
static short len_syslog_severity_names[8] = { 5, 5, 4, 3, 7, 6, 4, 5 };
/* numerical values as string - this is the most efficient approach to convert severity
* and facility values to a numerical string... -- rgerhars, 2009-06-17
*/
static char *syslog_number_names[LOG_NFACILITIES] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
static const 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 */
@ -436,7 +440,7 @@ MsgSetRcvFromIPWithoutAddRef(msg_t *pThis, prop_t *new)
/* set RcvFrom name in msg object WITHOUT calling AddRef.
* rgerhards, 2013-01-22
*/
void MsgSetRcvFromWithoutAddRef(msg_t *pThis, prop_t *new)
static void MsgSetRcvFromWithoutAddRef(msg_t *pThis, prop_t *new)
{
assert(pThis != NULL);
@ -782,7 +786,8 @@ uchar *propIDToName(propid_t propID)
* a binary 0 on all machines [but today almost always...]).
* rgerhards, 2008-10-06
*/
static inline rsRetVal msgBaseConstruct(msg_t **ppThis)
static rsRetVal
msgBaseConstruct(msg_t **ppThis)
{
DEFiRet;
msg_t *pM;
@ -926,7 +931,7 @@ static inline void freeHOSTNAME(msg_t *pThis)
BEGINobjDestruct(msg) /* be sure to specify the object type also in END and CODESTART macros! */
int currRefCount;
# if HAVE_MALLOC_TRIM
# ifdef HAVE_MALLOC_TRIM
int currCnt;
# endif
CODESTARTobjDestruct(msg)
@ -987,7 +992,7 @@ CODESTARTobjDestruct(msg)
* 100,000 messages (which is an approximation, as we do not work with atomic
* operations on the counter. --- rgerhards, 2009-06-22.
*/
# if HAVE_MALLOC_TRIM
# ifdef HAVE_MALLOC_TRIM
{ /* standard C requires a new block for a new variable definition!
* To simplify matters, we use modulo arithmetic and live with the fact
* that we trim too often when the counter wraps.
@ -1201,7 +1206,6 @@ static rsRetVal MsgSerialize(msg_t *pThis, strm_t *pStrm)
objSerializePTR(pStrm, pszUUID, PSZ);
if(pThis->pRuleset != NULL) {
rulesetGetName(pThis->pRuleset);
CHKiRet(obj.SerializeProp(pStrm, UCHAR_CONSTANT("pszRuleset"), PROPTYPE_PSZ,
rulesetGetName(pThis->pRuleset)));
}
@ -1223,7 +1227,7 @@ finalize_it:
* But as an interim help during refactoring let's introduce this function
* here (and thus NOT as method of var object!). -- rgerhads, 2012-11-06
*/
static inline void
static void
reinitVar(var_t *pVar)
{
rsCStrDestruct(&pVar->pcsName); /* no longer needed */
@ -1485,7 +1489,7 @@ finalize_it:
* IMPORTANT: A locked message object must be provided, else a crash will occur.
* rgerhards, 2005-10-19
*/
static inline rsRetVal
static rsRetVal
aquireProgramName(msg_t * const pM)
{
int i;
@ -1527,12 +1531,21 @@ void setProtocolVersion(msg_t * const pM, int iNewVersion)
}
/* note: string is taken from constant pool, do NOT free */
char *getProtocolVersionString(msg_t * const pM)
static const char *getProtocolVersionString(msg_t * const pM)
{
assert(pM != NULL);
return(pM->iProtocolVersion ? "1" : "0");
}
void
msgSetPRI(msg_t *const __restrict__ pMsg, syslog_pri_t pri)
{
if(pri > LOG_MAXPRI)
pri = LOG_PRI_INVLD;
pMsg->iFacility = pri2fac(pri),
pMsg->iSeverity = pri2sev(pri);
}
#ifdef USE_LIBUUID
/* note: libuuid seems not to be thread-safe, so we need
* to get some safeguards in place.
@ -1565,7 +1578,7 @@ static void msgSetUUID(msg_t * const pM)
dbgprintf("[MsgSetUUID] END\n");
}
void getUUID(msg_t * const pM, uchar **pBuf, int *piLen)
static void getUUID(msg_t * const pM, uchar **pBuf, int *piLen)
{
dbgprintf("[getUUID] START\n");
if(pM == NULL) {
@ -1680,7 +1693,7 @@ static int getPRIi(msg_t * const pM)
/* Get PRI value in text form
*/
char *
const char *
getPRI(msg_t * const pM)
{
/* PRI is a number in the range 0..191. Thus, we use a simple lookup table to obtain the
@ -1696,7 +1709,7 @@ getPRI(msg_t * const pM)
}
char *
const char *
getTimeReported(msg_t * const pM, enum tplFormatTypes eFmt)
{
BEGINfunc
@ -1798,7 +1811,7 @@ getTimeReported(msg_t * const pM, enum tplFormatTypes eFmt)
static char *getTimeUTC(struct syslogTime *const __restrict__ pTmIn,
static const char *getTimeUTC(struct syslogTime *const __restrict__ pTmIn,
const enum tplFormatTypes eFmt,
unsigned short *const __restrict__ pbMustBeFreed)
{
@ -1891,7 +1904,7 @@ static char *getTimeUTC(struct syslogTime *const __restrict__ pTmIn,
}
if(retbuf == NULL) {
retbuf = "internal error: invalid eFmt option or malloc problem";
retbuf = (char*)"internal error: invalid eFmt option or malloc problem";
*pbMustBeFreed = 0;
} else {
*pbMustBeFreed = 1;
@ -1900,7 +1913,8 @@ static char *getTimeUTC(struct syslogTime *const __restrict__ pTmIn,
return retbuf;
}
static char *getTimeGenerated(msg_t *const __restrict__ pM,
static const char *
getTimeGenerated(msg_t *const __restrict__ pM,
const enum tplFormatTypes eFmt)
{
BEGINfunc
@ -2018,9 +2032,9 @@ static char *getTimeGenerated(msg_t *const __restrict__ pM,
}
static inline char *getSeverity(msg_t * const pM)
static const char *getSeverity(msg_t * const pM)
{
char *name = NULL;
const char *name = NULL;
if(pM == NULL)
return "";
@ -2035,9 +2049,9 @@ static inline char *getSeverity(msg_t * const pM)
}
static inline char *getSeverityStr(msg_t * const pM)
static const char *getSeverityStr(msg_t * const pM)
{
char *name = NULL;
const char *name = NULL;
if(pM == NULL)
return "";
@ -2051,9 +2065,9 @@ static inline char *getSeverityStr(msg_t * const pM)
return name;
}
static inline char *getFacility(msg_t * const pM)
static const char *getFacility(msg_t * const pM)
{
char *name = NULL;
const char *name = NULL;
if(pM == NULL)
return "";
@ -2067,9 +2081,9 @@ static inline char *getFacility(msg_t * const pM)
return name;
}
static inline char *getFacilityStr(msg_t * const pM)
static const char *getFacilityStr(msg_t * const pM)
{
char *name = NULL;
const char *name = NULL;
if(pM == NULL)
return "";
@ -2226,7 +2240,7 @@ finalize_it:
/* Return state of last parser. If it had success, "OK" is returned, else
* "FAIL". All from the constant pool.
*/
static inline char *getParseSuccess(msg_t * const pM)
static const char *getParseSuccess(msg_t * const pM)
{
return (pM->bParseSuccess) ? "OK" : "FAIL";
}
@ -2234,7 +2248,7 @@ static inline char *getParseSuccess(msg_t * const pM)
/* al, 2011-07-26: LockMsg to avoid race conditions
*/
static inline char *getMSGID(msg_t * const pM)
static const char *getMSGID(msg_t * const pM)
{
if (pM->pCSMSGID == NULL) {
return "-";
@ -2389,7 +2403,8 @@ void MsgSetTAG(msg_t *__restrict__ const pMsg, const uchar* pszBuf, const size_t
* if there is a TAG and, if not, if it can emulate it.
* rgerhards, 2005-11-24
*/
static inline void tryEmulateTAG(msg_t * const pM, sbool bLockMutex)
static void
tryEmulateTAG(msg_t * const pM, sbool bLockMutex)
{
size_t lenTAG;
uchar bufTAG[CONF_TAG_MAXSIZE];
@ -2456,7 +2471,7 @@ int getHOSTNAMELen(msg_t * const pM)
}
char *getHOSTNAME(msg_t * const pM)
const char *getHOSTNAME(msg_t * const pM)
{
if(pM == NULL)
return "";
@ -3240,7 +3255,7 @@ jsonEncode(uchar **ppRes, unsigned short *pbMustBeFreed, int *pBufLen, int escap
DEFiRet;
pSrc = *ppRes;
buflen = (*pBufLen == -1) ? ustrlen(pSrc) : *pBufLen;
buflen = (*pBufLen == -1) ? (int) ustrlen(pSrc) : *pBufLen;
CHKiRet(jsonAddVal(pSrc, buflen, &dst, escapeAll));
if(dst != NULL) {
@ -3278,7 +3293,7 @@ jsonField(struct templateEntry *pTpe, uchar **ppRes, unsigned short *pbMustBeFre
DEFiRet;
pSrc = *ppRes;
buflen = (*pBufLen == -1) ? ustrlen(pSrc) : *pBufLen;
buflen = (*pBufLen == -1) ? (int) ustrlen(pSrc) : *pBufLen;
/* we hope we have only few escapes... */
dst = es_newStr(buflen+pTpe->lenFieldName+15);
es_addChar(&dst, '"');
@ -3704,7 +3719,7 @@ uchar *MsgGetProp(msg_t *__restrict__ const pMsg, struct templateEntry *__restri
/* If we did not receive a template pointer, we are already done... */
if(pTpe == NULL || !pTpe->bComplexProcessing) {
*pPropLen = (bufLen == -1) ? ustrlen(pRes) : bufLen;
*pPropLen = (bufLen == -1) ? (int) ustrlen(pRes) : bufLen;
return pRes;
}
@ -4372,7 +4387,7 @@ uchar *MsgGetProp(msg_t *__restrict__ const pMsg, struct templateEntry *__restri
jsonField(pTpe, &pRes, pbMustBeFreed, &bufLen, RSFALSE);
}
*pPropLen = (bufLen == -1) ? ustrlen(pRes) : bufLen;
*pPropLen = (bufLen == -1) ? (int) ustrlen(pRes) : bufLen;
ENDfunc
return(pRes);
@ -4877,6 +4892,7 @@ jsonDeepCopy(struct json_object *src)
json_object_array_add(dst, json);
}
break;
case json_type_null:
default:DBGPRINTF("jsonDeepCopy(): error unknown type %d\n",
json_object_get_type(src));
dst = NULL;
@ -4979,7 +4995,7 @@ msgPropDescrDestruct(msgPropDescr_t *pProp)
/* dummy */
rsRetVal msgQueryInterface(void) { return RS_RET_NOT_IMPLEMENTED; }
static rsRetVal msgQueryInterface(void) { return RS_RET_NOT_IMPLEMENTED; }
/* Initialize the message class. Must be called as the very first method
* before anything else is called inside this class.
@ -4997,7 +5013,7 @@ BEGINObjClassInit(msg, 1, OBJ_IS_CORE_MODULE)
/* set our own handlers */
OBJSetMethodHandler(objMethod_SERIALIZE, MsgSerialize);
/* some more inits */
# if HAVE_MALLOC_TRIM
# ifdef HAVE_MALLOC_TRIM
INIT_ATOMIC_HELPER_MUT(mutTrimCtr);
# endif
ENDObjClassInit(msg)

View File

@ -189,8 +189,8 @@ uchar *MsgGetProp(msg_t *pMsg, struct templateEntry *pTpe, msgPropDescr_t *pProp
rs_size_t *pPropLen, unsigned short *pbMustBeFreed, struct syslogTime *ttNow);
uchar *getRcvFrom(msg_t *pM);
void getTAG(msg_t *pM, uchar **ppBuf, int *piLen);
char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt);
char *getPRI(msg_t *pMsg);
const char *getTimeReported(msg_t *pM, enum tplFormatTypes eFmt);
const char *getPRI(msg_t *pMsg);
void getRawMsg(msg_t *pM, uchar **pBuf, int *piLen);
rsRetVal msgAddJSON(msg_t *pM, uchar *name, struct json_object *json, int force_reset, int sharedReference);
rsRetVal msgAddMetadata(msg_t *msg, uchar *metaname, uchar *metaval);
@ -201,13 +201,12 @@ const uchar* msgGetJSONMESG(msg_t *__restrict__ const pMsg);
/* TODO: remove these five (so far used in action.c) */
uchar *getMSG(msg_t *pM);
char *getHOSTNAME(msg_t *pM);
const char *getHOSTNAME(msg_t *pM);
char *getPROCID(msg_t *pM, sbool bLockMutex);
char *getAPPNAME(msg_t *pM, sbool bLockMutex);
void setMSGLen(msg_t *pM, int lenMsg);
int getMSGLen(msg_t *pM);
char *getHOSTNAME(msg_t *pM);
int getHOSTNAMELen(msg_t *pM);
uchar *getProgramName(msg_t *pM, sbool bLockMutex);
uchar *getRcvFrom(msg_t *pM);
@ -222,19 +221,12 @@ rsRetVal jsonFind(struct json_object *jroot, msgPropDescr_t *pProp, struct json_
rsRetVal msgPropDescrFill(msgPropDescr_t *pProp, uchar *name, int nameLen);
void msgPropDescrDestruct(msgPropDescr_t *pProp);
void msgSetPRI(msg_t *const __restrict__ pMsg, syslog_pri_t pri);
static inline int
msgGetProtocolVersion(msg_t *pM)
{
return(pM->iProtocolVersion);
}
#define msgGetProtocolVersion(pM) ((pM)->iProtocolVersion)
/* returns non-zero if the message has structured data, 0 otherwise */
static inline sbool
MsgHasStructuredData(msg_t *pM)
{
return (pM->pszStrucData == NULL) ? 0 : 1;
}
#define MsgHasStructuredData(pM) (((pM)->pszStrucData == NULL) ? 0 : 1)
/* ------------------------------ some inline functions ------------------------------ */
@ -250,33 +242,17 @@ MsgHasStructuredData(msg_t *pM)
* be extended, only shrunk!
* rgerhards, 2009-08-26
*/
static inline void
MsgSetRawMsgSize(msg_t *pMsg, size_t newLen)
static inline void __attribute__((unused))
MsgSetRawMsgSize(msg_t *const __restrict__ pMsg, const size_t newLen)
{
assert(newLen <= (size_t) pMsg->iLenRawMsg);
pMsg->iLenRawMsg = newLen;
pMsg->pszRawMsg[newLen] = '\0';
}
static inline void
msgSetPRI(msg_t *const __restrict__ pMsg, syslog_pri_t pri)
{
if(pri > LOG_MAXPRI)
pri = LOG_PRI_INVLD;
pMsg->iFacility = pri2fac(pri),
pMsg->iSeverity = pri2sev(pri);
}
/* get the ruleset that is associated with the ruleset.
* May be NULL. -- rgerhards, 2009-10-27
*/
static inline ruleset_t*
MsgGetRuleset(msg_t *pMsg)
{
return pMsg->pRuleset;
}
#define MsgGetRuleset(pMsg) ((pMsg)->pRuleset)
#endif /* #ifndef MSG_H_INCLUDED */
/* vim:set ai:
*/

View File

@ -12,7 +12,7 @@
* long term, but it is good to have it out of syslogd.c. Maybe this here is
* an interim location ;)
*
* Copyright 2007-2014 Rainer Gerhards and Adiscon GmbH.
* Copyright 2007-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of rsyslog.
*
@ -77,6 +77,9 @@ DEFobjCurrIf(errmsg)
DEFobjCurrIf(glbl)
DEFobjCurrIf(prop)
#ifndef HAVE_STRUCT_SOCKADDR_SA_LEN
extern size_t SALEN(struct sockaddr *sa);
#endif
/* support for defining allowed TCP and UDP senders. We use the same
* structure to implement this (a linked list), but we define two different
* list roots, one for UDP and one for TCP.
@ -773,7 +776,8 @@ finalize_it:
* iListToPrint = 1 means UDP, 2 means TCP
* rgerhards, 2005-09-27
*/
void PrintAllowedSenders(int iListToPrint)
static void
PrintAllowedSenders(int iListToPrint)
{
struct AllowedSenders *pSender;
uchar szIP[64];
@ -826,7 +830,8 @@ void PrintAllowedSenders(int iListToPrint)
* (if the line is correct).
* rgerhards, 2005-09-27
*/
rsRetVal addAllowedSenderLine(char* pName, uchar** ppRestOfConfLine)
static rsRetVal
addAllowedSenderLine(char* pName, uchar** ppRestOfConfLine)
{
struct AllowedSenders **ppRoot;
struct AllowedSenders **ppLast;
@ -1077,9 +1082,10 @@ should_use_so_bsdcompat(void)
/* print out which socket we are listening on. This is only
* a debug aid. rgerhards, 2007-07-02
*/
void debugListenInfo(int fd, char *type)
static void
debugListenInfo(int fd, char *type)
{
char *szFamily;
const char *szFamily;
int port;
struct sockaddr_storage sa;
socklen_t saLen = sizeof(sa);
@ -1115,7 +1121,7 @@ void debugListenInfo(int fd, char *type)
/* Return a printable representation of a host addresses. If
* a parameter is NULL, it is not set. rgerhards, 2013-01-22
*/
rsRetVal
static rsRetVal
cvthname(struct sockaddr_storage *f, prop_t **localName, prop_t **fqdn, prop_t **ip)
{
DEFiRet;
@ -1189,7 +1195,8 @@ finalize_it:
/* closes the UDP listen sockets (if they exist) and frees
* all dynamically assigned memory.
*/
void closeUDPListenSockets(int *pSockArr)
static void
closeUDPListenSockets(int *pSockArr)
{
register int i;
@ -1208,7 +1215,8 @@ void closeUDPListenSockets(int *pSockArr)
* 1 - server, 0 - client
* param rcvbuf indicates desired rcvbuf size; 0 means OS default
*/
int *create_udp_socket(uchar *hostname, uchar *pszPort, int bIsServer, int rcvbuf, int ipfreebind)
static int *
create_udp_socket(uchar *hostname, uchar *pszPort, int bIsServer, int rcvbuf, int ipfreebind)
{
struct addrinfo hints, *res, *r;
int error, maxs, *s, *socks, on = 1;

View File

@ -1,6 +1,6 @@
/* Definitions for network-related stuff.
*
* Copyright 2007-2013 Rainer Gerhards and Adiscon GmbH.
* Copyright 2007-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -24,6 +24,7 @@
#ifndef INCLUDED_NET_H
#define INCLUDED_NET_H
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h> /* this is needed on HP UX -- rgerhards, 2008-03-04 */
@ -84,7 +85,8 @@ struct NetAddr {
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
#define SALEN(sa) ((sa)->sa_len)
#else
static inline size_t SALEN(struct sockaddr *sa) {
static inline size_t __attribute__((unused))
SALEN(struct sockaddr *sa) {
switch (sa->sa_family) {
case AF_INET: return (sizeof (struct sockaddr_in));
case AF_INET6: return (sizeof (struct sockaddr_in6));

View File

@ -70,18 +70,24 @@ DEFobjCurrIf(net)
DEFobjCurrIf(datetime)
DEFobjCurrIf(nsd_ptcp)
static int bGlblSrvrInitDone = 0; /**< 0 - server global init not yet done, 1 - already done */
static pthread_mutex_t mutGtlsStrerror; /**< a mutex protecting the potentially non-reentrant gtlStrerror() function */
/* a macro to check GnuTLS calls against unexpected errors */
#define CHKgnutls(x) \
if((gnuRet = (x)) != 0) { \
#define CHKgnutls(x) { \
gnuRet = (x); \
if(gnuRet == GNUTLS_E_FILE_ERROR) { \
errmsg.LogError(0, RS_RET_GNUTLS_ERR, "error reading file - a common cause is that the file does not exist"); \
ABORT_FINALIZE(RS_RET_GNUTLS_ERR); \
} else if(gnuRet != 0) { \
uchar *pErr = gtlsStrerror(gnuRet); \
errmsg.LogError(0, RS_RET_GNUTLS_ERR, "unexpected GnuTLS error %d in %s:%d: %s\n", gnuRet, __FILE__, __LINE__, pErr); \
free(pErr); \
ABORT_FINALIZE(RS_RET_GNUTLS_ERR); \
}
} \
}
/* ------------------------------ GnuTLS specifics ------------------------------ */
@ -605,7 +611,12 @@ gtlsGlblInit(void)
}
dbgprintf("GTLS CA file: '%s'\n", cafile);
gnuRet = gnutls_certificate_set_x509_trust_file(xcred, (char*)cafile, GNUTLS_X509_FMT_PEM);
if(gnuRet < 0) {
if(gnuRet == GNUTLS_E_FILE_ERROR) {
errmsg.LogError(0, RS_RET_GNUTLS_ERR,
"error reading certificate file '%s' - a common cause is that the "
"file does not exist", cafile);
ABORT_FINALIZE(RS_RET_GNUTLS_ERR);
} else if(gnuRet < 0) {
/* TODO; a more generic error-tracking function (this one based on CHKgnutls()) */
uchar *pErr = gtlsStrerror(gnuRet);
errmsg.LogError(0, RS_RET_GNUTLS_ERR, "unexpected GnuTLS error %d in %s:%d: %s\n", gnuRet, __FILE__, __LINE__, pErr);
@ -992,7 +1003,7 @@ static rsRetVal
gtlsChkPeerCertValidity(nsd_gtls_t *pThis)
{
DEFiRet;
char *pszErrCause;
const char *pszErrCause;
int gnuRet;
cstr_t *pStr;
unsigned stateCert;
@ -1173,6 +1184,7 @@ ENDobjConstruct(nsd_gtls)
/* destructor for the nsd_gtls object */
PROTOTYPEobjDestruct(nsd_gtls);
BEGINobjDestruct(nsd_gtls) /* be sure to specify the object type also in END and CODESTART macros! */
CODESTARTobjDestruct(nsd_gtls)
if(pThis->iMode == 1) {
@ -1673,7 +1685,7 @@ Connect(nsd_t *pNsd, int family, uchar *port, uchar *host)
nsd_gtls_t *pThis = (nsd_gtls_t*) pNsd;
int sock;
int gnuRet;
# if HAVE_GNUTLS_CERTIFICATE_TYPE_SET_PRIORITY
# ifdef HAVE_GNUTLS_CERTIFICATE_TYPE_SET_PRIORITY
static const int cert_type_priority[2] = { GNUTLS_CRT_X509, 0 };
# endif
DEFiRet;
@ -1711,7 +1723,7 @@ Connect(nsd_t *pNsd, int family, uchar *port, uchar *host)
/* Use default priorities */
CHKgnutls(gnutls_set_default_priority(pThis->sess));
# if HAVE_GNUTLS_CERTIFICATE_TYPE_SET_PRIORITY
# ifdef HAVE_GNUTLS_CERTIFICATE_TYPE_SET_PRIORITY
/* The gnutls_certificate_type_set_priority function is deprecated
* and not available in recent GnuTLS versions. However, there is no
* doc how to properly replace it with gnutls_priority_set_direct.

View File

@ -1,6 +1,6 @@
/* An implementation of the nsd interface for GnuTLS.
*
* Copyright 2008-2012 Adiscon GmbH.
* Copyright 2008-2016 Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -74,15 +74,6 @@ PROTOTYPEObj(nsd_gtls);
uchar *gtlsStrerror(int error);
rsRetVal gtlsChkPeerAuth(nsd_gtls_t *pThis);
rsRetVal gtlsRecordRecv(nsd_gtls_t *pThis);
static inline rsRetVal gtlsHasRcvInBuffer(nsd_gtls_t *pThis) {
/* we have a valid receive buffer one such is allocated and
* NOT exhausted!
*/
dbgprintf("hasRcvInBuffer on nsd %p: pszRcvBuf %p, lenRcvBuf %d\n", pThis,
pThis->pszRcvBuf, pThis->lenRcvBuf);
return(pThis->pszRcvBuf != NULL && pThis->lenRcvBuf != -1);
}
/* the name of our library binary */
#define LM_NSD_GTLS_FILENAME "lmnsd_gtls"

View File

@ -30,7 +30,7 @@
#include <assert.h>
#include <errno.h>
#include <string.h>
#if HAVE_SYS_EPOLL_H
#ifdef HAVE_SYS_EPOLL_H
# include <sys/epoll.h>
#endif

View File

@ -1,6 +1,6 @@
/* An implementation of the nsd poll interface for plain tcp sockets.
*
* Copyright 2009 Rainer Gerhards and Adiscon GmbH.
* Copyright 2009-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -25,7 +25,7 @@
#define INCLUDED_NSDPOLL_PTCP_H
#include "nsd.h"
#if HAVE_SYS_EPOLL_H
#ifdef HAVE_SYS_EPOLL_H
# include <sys/epoll.h>
#endif
typedef nsdpoll_if_t nsdpoll_ptcp_if_t; /* we just *implement* this interface */
@ -35,7 +35,7 @@ typedef nsdpoll_if_t nsdpoll_ptcp_if_t; /* we just *implement* this interface */
*/
typedef struct nsdpoll_epollevt_lst_s nsdpoll_epollevt_lst_t;
struct nsdpoll_epollevt_lst_s {
#if HAVE_SYS_EPOLL_H
#ifdef HAVE_SYS_EPOLL_H
epoll_event_t event;
#endif
int id;

View File

@ -45,6 +45,17 @@ DEFobjCurrIf(errmsg)
DEFobjCurrIf(glbl)
DEFobjCurrIf(nsdsel_ptcp)
static rsRetVal
gtlsHasRcvInBuffer(nsd_gtls_t *pThis)
{
/* we have a valid receive buffer one such is allocated and
* NOT exhausted!
*/
DBGPRINTF("hasRcvInBuffer on nsd %p: pszRcvBuf %p, lenRcvBuf %d\n", pThis,
pThis->pszRcvBuf, pThis->lenRcvBuf);
return(pThis->pszRcvBuf != NULL && pThis->lenRcvBuf != -1);
}
/* Standard-Constructor
*/
@ -152,6 +163,7 @@ doRetry(nsd_gtls_t *pNsd)
pNsd->rtryCall = gtlsRtry_None; /* we are done */
gnuRet = 0;
break;
case gtlsRtry_None:
default:
assert(0); /* this shall not happen! */
dbgprintf("ERROR: pNsd->rtryCall invalid in nsdsel_gtls.c:%d\n", __LINE__);

View File

@ -136,13 +136,6 @@ struct obj_s { /* the dummy struct that each derived class can be casted to */
}
#define PROTOTYPEpropSetMethPTR(obj, prop, dataType)\
rsRetVal obj##Set##prop(obj##_t *pThis, dataType*)
#define DEFpropSetMeth(obj, prop, dataType)\
rsRetVal obj##Set##prop(obj##_t *pThis, dataType pVal)\
{ \
/* DEV debug: dbgprintf("%sSet%s()\n", #obj, #prop); */\
pThis->prop = pVal; \
return RS_RET_OK; \
}
#define DEFpropSetMethFP(obj, prop, dataType)\
rsRetVal obj##Set##prop(obj##_t *pThis, dataType)\
{ \
@ -153,6 +146,7 @@ struct obj_s { /* the dummy struct that each derived class can be casted to */
#define PROTOTYPEpropSetMethFP(obj, prop, dataType)\
rsRetVal obj##Set##prop(obj##_t *pThis, dataType)
#define DEFpropSetMeth(obj, prop, dataType)\
rsRetVal obj##Set##prop(obj##_t *pThis, dataType pVal);\
rsRetVal obj##Set##prop(obj##_t *pThis, dataType pVal)\
{ \
/* DEV debug: dbgprintf("%sSet%s()\n", #obj, #prop); */\
@ -232,7 +226,7 @@ rsRetVal objName##ClassExit(void) \
* rgerhards, 2008-01-10
*/
#define BEGINobjConstruct(obj) \
rsRetVal obj##Initialize(obj##_t __attribute__((unused)) *pThis) \
static rsRetVal obj##Initialize(obj##_t __attribute__((unused)) *pThis) \
{ \
DEFiRet;
@ -240,6 +234,7 @@ rsRetVal objName##ClassExit(void) \
/* use finalize_it: before calling the macro (if you need it)! */ \
RETiRet; \
} \
rsRetVal obj##Construct(obj##_t **ppThis); \
rsRetVal obj##Construct(obj##_t **ppThis) \
{ \
DEFiRet; \
@ -278,7 +273,14 @@ rsRetVal objName##ClassExit(void) \
* processing.
* rgerhards, 2008-01-30
*/
#define PROTOTYPEobjDestruct(OBJ) \
rsRetVal OBJ##Destruct(OBJ##_t __attribute__((unused)) **ppThis)
/* note: we generate a prototype in any case, as this does not hurt but
* many modules otherwise seem to miss one, which generates compiler
* warnings.
*/
#define BEGINobjDestruct(OBJ) \
rsRetVal OBJ##Destruct(OBJ##_t __attribute__((unused)) **ppThis);\
rsRetVal OBJ##Destruct(OBJ##_t __attribute__((unused)) **ppThis) \
{ \
DEFiRet; \
@ -319,6 +321,7 @@ rsRetVal objName##ClassExit(void) \
#define PROTOTYPEObjDebugPrint(obj) rsRetVal obj##DebugPrint(obj##_t *pThis)
#define INTERFACEObjDebugPrint(obj) rsRetVal (*DebugPrint)(obj##_t *pThis)
#define BEGINobjDebugPrint(obj) \
rsRetVal obj##DebugPrint(obj##_t __attribute__((unused)) *pThis);\
rsRetVal obj##DebugPrint(obj##_t __attribute__((unused)) *pThis) \
{ \
DEFiRet; \
@ -353,6 +356,7 @@ rsRetVal objName##ClassExit(void) \
* present in all objects.
*/
#define BEGINobjQueryInterface(obj) \
rsRetVal obj##QueryInterface(obj##_if_t *pIf);\
rsRetVal obj##QueryInterface(obj##_if_t *pIf) \
{ \
DEFiRet; \
@ -364,6 +368,8 @@ rsRetVal objName##ClassExit(void) \
RETiRet; \
}
#define PROTOTYPEObjQueryInterface(obj) rsRetVal obj##QueryInterface(obj##_if_t *pIf)
/* the following macros should be used to define interfaces inside the
* header files.
@ -408,7 +414,8 @@ rsRetVal objName##ClassExit(void) \
*/
#define PROTOTYPEObj(obj) \
PROTOTYPEObjClassInit(obj); \
PROTOTYPEObjClassExit(obj)
PROTOTYPEObjClassExit(obj); \
PROTOTYPEObjQueryInterface(obj)
/* ------------------------------ end object loader system ------------------------------ */

View File

@ -48,7 +48,7 @@
*
* File begun on 2008-01-04 by RGerhards
*
* Copyright 2008-2012 Rainer Gerhards and Adiscon GmbH.
* Copyright 2008-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -368,6 +368,7 @@ SerializeProp(strm_t *pStrm, uchar *pszPropName, propType_t propType, void *pUsr
vType = VARTYPE_SYSLOGTIME;
pszBuf = szBuf;
break;
case PROPTYPE_NONE:
default:
dbgprintf("invalid PROPTYPE %d\n", propType);
break;
@ -651,6 +652,7 @@ rsRetVal objDeserializeProperty(var_t *pProp, strm_t *pStrm)
case VARTYPE_SYSLOGTIME:
CHKiRet(objDeserializeSyslogTime(&pProp->val.vSyslogTime, pStrm));
break;
case VARTYPE_NONE:
default:
dbgprintf("invalid VARTYPE %d\n", pProp->varType);
break;
@ -666,6 +668,7 @@ finalize_it:
strm.GetCurrOffset(pStrm, &offs);
dbgprintf("error %d deserializing property name, offset %lld, step %d\n",
iRet, offs, step);
strmDebugOutBuf(pStrm);
if(step >= 1) {
dbgprintf("error property name: '%s'\n", rsCStrGetSzStrNoNULL(pProp->pcsName));
}
@ -688,6 +691,7 @@ finalize_it:
dbgprintf("syslog time was successfully parsed (but "
"is not displayed\n");
break;
case VARTYPE_NONE:
default:
break;
}
@ -968,53 +972,6 @@ finalize_it:
}
/* De-Serialize an object, but treat it as property bag.
* rgerhards, 2008-01-11
*/
rsRetVal
objDeserializeObjAsPropBag(obj_t *pObj, strm_t *pStrm)
{
DEFiRet;
rsRetVal iRetLocal;
cstr_t *pstrID = NULL;
int oVers = 0; /* after all, it is totally useless but takes up some execution time... */
objInfo_t *pObjInfo;
ISOBJ_assert(pObj);
ISOBJ_TYPE_assert(pStrm, strm);
/* we de-serialize the header. if all goes well, we are happy. However, if
* we experience a problem, we try to recover. We do this by skipping to
* the next object header. This is defined via the line-start cookies. In
* worst case, we exhaust the queue, but then we receive EOF return state
* from objDeserializeTryRecover(), what will cause us to ultimately give up.
* rgerhards, 2008-07-08
*/
do {
iRetLocal = objDeserializeHeader((uchar*) "Obj", &pstrID, &oVers, pStrm);
if(iRetLocal != RS_RET_OK) {
dbgprintf("objDeserializeObjAsPropBag error %d during header - trying to recover\n", iRetLocal);
CHKiRet(objDeserializeTryRecover(pStrm));
}
} while(iRetLocal != RS_RET_OK);
if(rsCStrSzStrCmp(pstrID, pObj->pObjInfo->pszID, pObj->pObjInfo->lenID))
ABORT_FINALIZE(RS_RET_INVALID_OID);
CHKiRet(FindObjInfo((char*)cstrGetSzStrNoNULL(pstrID), &pObjInfo));
/* we got the object, now we need to fill the properties */
CHKiRet(objDeserializeProperties(pObj, pObjInfo->objMethods[objMethod_SETPROPERTY], pStrm));
finalize_it:
if(pstrID != NULL)
rsCStrDestruct(&pstrID);
RETiRet;
}
/* De-Serialize an object property bag. As a property bag contains only partial properties,
* it is not instanciable. Thus, the caller must provide a pointer of an already-instanciated
* object of the correct type.
@ -1248,7 +1205,7 @@ finalize_it:
* rgerhards, 2008-02-29
*/
static rsRetVal
UseObj(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf)
UseObj(const char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf)
{
DEFiRet;
objInfo_t *pObjInfo;
@ -1306,7 +1263,7 @@ finalize_it:
* rgerhards, 2008-03-10
*/
static rsRetVal
ReleaseObj(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf)
ReleaseObj(const char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf)
{
DEFiRet;
objInfo_t *pObjInfo;
@ -1341,6 +1298,7 @@ finalize_it:
/* queryInterface function
* rgerhards, 2008-02-29
*/
PROTOTYPEObjQueryInterface(obj);
BEGINobjQueryInterface(obj)
CODESTARTobjQueryInterface(obj)
if(pIf->ifVersion != objCURR_IF_VERSION) { /* check for current version, increment on each change */

View File

@ -90,8 +90,8 @@
/* interfaces */
BEGINinterface(obj) /* name must also be changed in ENDinterface macro! */
rsRetVal (*UseObj)(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf);
rsRetVal (*ReleaseObj)(char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf);
rsRetVal (*UseObj)(const char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf);
rsRetVal (*ReleaseObj)(const char *srcFile, uchar *pObjName, uchar *pObjFile, interface_t *pIf);
rsRetVal (*InfoConstruct)(objInfo_t **ppThis, uchar *pszID, int iObjVers,
rsRetVal (*pConstruct)(void *), rsRetVal (*pDestruct)(void *),
rsRetVal (*pQueryIF)(interface_t*), modInfo_t*);

View File

@ -247,7 +247,7 @@ ENDobjConstruct(parser)
* to our global list of available parsers.
* rgerhards, 2009-11-03
*/
rsRetVal parserConstructFinalize(parser_t *pThis)
static rsRetVal parserConstructFinalize(parser_t *pThis)
{
DEFiRet;
@ -376,7 +376,7 @@ finalize_it:
* NULs in the debug log.
* rgerhards, 2007-09-14
*/
static inline rsRetVal
static rsRetVal
SanitizeMsg(msg_t *pMsg)
{
DEFiRet;

View File

@ -12,7 +12,7 @@
*
* Module begun 2009-06-17 by Rainer Gerhards
*
* Copyright 2009-2012 Adiscon GmbH.
* Copyright 2009-2016 Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -46,6 +46,7 @@
/* static data */
DEFobjStaticHelpers
//extern uchar *propGetSzStr(prop_t *pThis); /* expand inline function here */
/* Standard-Constructor
*/
@ -100,7 +101,7 @@ static int GetStringLen(prop_t *pThis)
/* get string */
rsRetVal GetString(prop_t *pThis, uchar **ppsz, int *plen)
static rsRetVal GetString(prop_t *pThis, uchar **ppsz, int *plen)
{
BEGINfunc
ISOBJ_TYPE_assert(pThis, prop);
@ -170,7 +171,7 @@ finalize_it:
* existing property).
* rgerhards, 2009-07-01
*/
rsRetVal CreateOrReuseStringProp(prop_t **ppThis, const uchar *psz, const int len)
static rsRetVal CreateOrReuseStringProp(prop_t **ppThis, const uchar *psz, const int len)
{
uchar *pszPrev;
int lenPrev;

View File

@ -53,7 +53,15 @@ ENDinterface(prop)
/* get classic c-style string */
static inline uchar *
/* Note: I know that "static inline" is not the right thing from a C99
* PoV, but some environments treat, even in C99 mode, compile
* non-static inline into the source even if not defined as "extern". This
* obviously results in linker errors. Using "static inline" as below together
* with "__attribute__((unused))" works in all cases. Note also that we
* cannot work around this as we would otherwise need to evaluate
* pThis more than once.
*/
static inline uchar * __attribute__((unused))
propGetSzStr(prop_t *pThis)
{
return(pThis->len < CONF_PROP_BUFSIZE) ? pThis->szVal.sz : pThis->szVal.psz;

View File

@ -12,7 +12,7 @@
* function names - this makes it really hard to read and does not provide much
* benefit, at least I (now) think so...
*
* Copyright 2008-2015 Rainer Gerhards and Adiscon GmbH.
* Copyright 2008-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -143,6 +143,7 @@ static inline void displayBatchState(batch_t *pBatch)
}
}
#endif
static rsRetVal qqueuePersist(qqueue_t *pThis, int bIsCheckpoint);
/***********************************************************************
* we need a private data structure, the "to-delete" list. As C does
@ -178,7 +179,7 @@ static inline toDeleteLst_t *tdlPeek(qqueue_t *pQueue)
* element itself is destroyed. Must not be called when the list
* is empty.
*/
static inline rsRetVal tdlPop(qqueue_t *pQueue)
static rsRetVal tdlPop(qqueue_t *pQueue)
{
toDeleteLst_t *pRemove;
DEFiRet;
@ -198,7 +199,8 @@ static inline rsRetVal tdlPop(qqueue_t *pQueue)
* structure, populates it with the values provided and links the new
* element into the correct place inside the list.
*/
static inline rsRetVal tdlAdd(qqueue_t *pQueue, qDeqID deqID, int nElemDeq)
static rsRetVal
tdlAdd(qqueue_t *pQueue, qDeqID deqID, int nElemDeq)
{
toDeleteLst_t *pNew;
toDeleteLst_t *pPrev;
@ -233,10 +235,10 @@ finalize_it:
/* methods */
static inline char *
static const char *
getQueueTypeName(queueType_t t)
{
char *r;
const char *r;
switch(t) {
case QUEUETYPE_FIXED_ARRAY:
@ -322,7 +324,7 @@ getLogicalQueueSize(qqueue_t *pThis)
* This functions works "around" the regular deque mechanism, because it is only used to
* clean up (in cases where message loss is acceptable).
*/
static inline void queueDrain(qqueue_t *pThis)
static void queueDrain(qqueue_t *pThis)
{
msg_t *pMsg;
ASSERT(pThis != NULL);
@ -348,7 +350,7 @@ static inline void queueDrain(qqueue_t *pThis)
* this point in time. The mutex must be locked when
* ths function is called. -- rgerhards, 2008-01-25
*/
static inline rsRetVal
static rsRetVal
qqueueAdviseMaxWorkers(qqueue_t *pThis)
{
DEFiRet;
@ -705,7 +707,7 @@ static rsRetVal qDelLinkedList(qqueue_t *pThis)
* states, which can trigger different processing in the higher layers.
* rgerhards, 2011-05-03
*/
static inline rsRetVal
static rsRetVal
queueSwitchToEmergencyMode(qqueue_t *pThis, rsRetVal initiatingError)
{
pThis->iQueueSize = 0;
@ -913,8 +915,17 @@ static rsRetVal qDestructDisk(qqueue_t *pThis)
ASSERT(pThis != NULL);
free(pThis->pszQIFNam);
if(pThis->tVars.disk.pWrite != NULL)
if(pThis->tVars.disk.pWrite != NULL) {
int64 currOffs;
strm.GetCurrOffset(pThis->tVars.disk.pWrite, &currOffs);
if(currOffs == 0) {
/* if no data is present, we can (and must!) delete this
* file. Else we can leave garbagge after termination.
*/
strm.SetbDeleteOnClose(pThis->tVars.disk.pWrite, 1);
}
strm.Destruct(&pThis->tVars.disk.pWrite);
}
if(pThis->tVars.disk.pReadDeq != NULL)
strm.Destruct(&pThis->tVars.disk.pReadDeq);
if(pThis->tVars.disk.pReadDel != NULL)
@ -927,6 +938,7 @@ static rsRetVal qAddDisk(qqueue_t *pThis, msg_t* pMsg)
{
DEFiRet;
number_t nWriteCount;
const int oldfile = strmGetCurrFileNum(pThis->tVars.disk.pWrite);
ASSERT(pThis != NULL);
@ -946,6 +958,18 @@ static rsRetVal qAddDisk(qqueue_t *pThis, msg_t* pMsg)
DBGOPRINT((obj_t*) pThis, "write wrote %lld octets to disk, queue disk size now %lld octets, EnqOnly:%d\n",
nWriteCount, pThis->tVars.disk.sizeOnDisk, pThis->bEnqOnly);
/* Did we have a change in the on-disk file? If so, we
* should do a "robustness sync" of the .qi file to guard
* against the most harsh consequences of kill -9 and power off.
*/
const int newfile = strmGetCurrFileNum(pThis->tVars.disk.pWrite);
if(newfile != oldfile) {
DBGOPRINT((obj_t*) pThis, "current to-be-written-to file has changed from "
"number %d to number %d - requiring a .qi write for robustness\n",
oldfile, newfile);
pThis->tVars.disk.nForcePersist = 2;
}
finalize_it:
RETiRet;
}
@ -1089,7 +1113,7 @@ qqueueDeq(qqueue_t *pThis, msg_t **ppMsg)
* and DA queue to try complete processing.
* rgerhards, 2009-10-14
*/
static inline rsRetVal
static rsRetVal
tryShutdownWorkersWithinQueueTimeout(qqueue_t *pThis)
{
struct timespec tTimeout;
@ -1473,11 +1497,11 @@ finalize_it:
/* Finally remove n elements from the queue store.
*/
static inline rsRetVal
static rsRetVal
DoDeleteBatchFromQStore(qqueue_t *pThis, int nElem)
{
int i;
off64_t bytesDel;
off64_t bytesDel = 0; /* keep CLANG static anaylzer happy */
DEFiRet;
ISOBJ_TYPE_assert(pThis, qqueue);
@ -1520,6 +1544,10 @@ DoDeleteBatchFromQStore(qqueue_t *pThis, int nElem)
getLogicalQueueSize(pThis), getPhysicalQueueSize(pThis));
++pThis->deqIDDel; /* one more batch dequeued */
if((pThis->qType == QUEUETYPE_DISK) && (bytesDel != 0)) {
qqueuePersist(pThis, QUEUE_CHECKPOINT); /* robustness persist .qi file */
}
RETiRet;
}
@ -1527,7 +1555,7 @@ DoDeleteBatchFromQStore(qqueue_t *pThis, int nElem)
/* remove messages from the physical queue store that are fully processed. This is
* controlled via the to-delete list.
*/
static inline rsRetVal
static rsRetVal
DeleteBatchFromQStore(qqueue_t *pThis, batch_t *pBatch)
{
toDeleteLst_t *pTdl;
@ -1567,7 +1595,7 @@ finalize_it:
* processed are enqueued again. The new enqueue is necessary because we have a
* rgerhards, 2009-05-13
*/
static inline rsRetVal
static rsRetVal
DeleteProcessedBatch(qqueue_t *pThis, batch_t *pBatch)
{
int i;
@ -1614,7 +1642,7 @@ DeleteProcessedBatch(qqueue_t *pThis, batch_t *pBatch)
* This must only be called when the queue mutex is LOOKED, otherwise serious
* malfunction will happen.
*/
static inline rsRetVal
static rsRetVal
DequeueConsumableElements(qqueue_t *pThis, wti_t *pWti, int *piRemainingQueueSize, int *const pSkippedMsgs)
{
int nDequeued;
@ -1740,7 +1768,14 @@ DequeueConsumable(qqueue_t *pThis, wti_t *pWti, int *const pSkippedMsgs)
if(iRet != RS_RET_OK && iRet != RS_RET_DISCARDMSG) {
DBGOPRINT((obj_t*) pThis, "error %d dequeueing element - ignoring, but strange things "
"may happen\n", iRet);
"may happen\n", iRet);
#if 0 // This does not work when we run on the main queue
// TODO: find better work-around
errmsg.LogError(0, iRet, "problem on disk queue '%s': "
"error dequeueing element - we ignore this for now, but it "
"may cause future trouble.",
obj.GetName((obj_t*) pThis));
#endif
}
RETiRet;
@ -1851,7 +1886,7 @@ RateLimiter(qqueue_t *pThis)
* cancelled, else it will leave back an inconsistent state.
* rgerhards, 2009-05-20
*/
static inline rsRetVal
static rsRetVal
DequeueForConsumer(qqueue_t *pThis, wti_t *pWti, int *const pSkippedMsgs)
{
DEFiRet;
@ -2412,10 +2447,13 @@ finalize_it:
* and 0 otherwise.
* rgerhards, 2008-01-10
*/
static rsRetVal qqueuePersist(qqueue_t *pThis, int bIsCheckpoint)
static rsRetVal
qqueuePersist(qqueue_t *pThis, int bIsCheckpoint)
{
DEFiRet;
char *tmpQIFName = NULL;
strm_t *psQIF = NULL; /* Queue Info File */
char errStr[1024];
ASSERT(pThis != NULL);
@ -2444,11 +2482,15 @@ static rsRetVal qqueuePersist(qqueue_t *pThis, int bIsCheckpoint)
FINALIZE; /* nothing left to do, so be happy */
}
const int lentmpQIFName = asprintf((char **)&tmpQIFName, "%s.tmp", pThis->pszQIFNam);
if(tmpQIFName == NULL)
tmpQIFName = (char*)pThis->pszQIFNam;
CHKiRet(strm.Construct(&psQIF));
CHKiRet(strm.SettOperationsMode(psQIF, STREAMMODE_WRITE_TRUNC));
CHKiRet(strm.SetbSync(psQIF, pThis->bSyncQueueFiles));
CHKiRet(strm.SetsType(psQIF, STREAMTYPE_FILE_SINGLE));
CHKiRet(strm.SetFName(psQIF, pThis->pszQIFNam, pThis->lenQIFNam));
CHKiRet(strm.SetFName(psQIF, (uchar*) tmpQIFName, lentmpQIFName));
CHKiRet(strm.ConstructFinalize(psQIF));
/* first, write the property bag for ourselfs
@ -2467,6 +2509,17 @@ static rsRetVal qqueuePersist(qqueue_t *pThis, int bIsCheckpoint)
CHKiRet(strm.Serialize(pThis->tVars.disk.pWrite, psQIF));
if(pThis->tVars.disk.pReadDel != NULL)
CHKiRet(strm.Serialize(pThis->tVars.disk.pReadDel, psQIF));
strm.Destruct(&psQIF);
if(tmpQIFName != (char*)pThis->pszQIFNam) { /* pointer, not string comparison! */
if(rename(tmpQIFName, (char*)pThis->pszQIFNam) != 0) {
rs_strerror_r(errno, errStr, sizeof(errStr));
DBGOPRINT((obj_t*) pThis,
"FATAL error: renaming temporary .qi file failed: %s\n",
errStr);
ABORT_FINALIZE(RS_RET_RENAME_TMP_QI_ERROR);
}
}
/* tell the input file object that it must not delete the file on close if the queue
* is non-empty - but only if we are not during a simple checkpoint
@ -2482,6 +2535,8 @@ static rsRetVal qqueuePersist(qqueue_t *pThis, int bIsCheckpoint)
pThis->bNeedDelQIF = 1;
finalize_it:
if(tmpQIFName != (char*)pThis->pszQIFNam) /* pointer, not string comparison! */
free(tmpQIFName);
if(psQIF != NULL)
strm.Destruct(&psQIF);
@ -2523,7 +2578,7 @@ finalize_it:
* depending on the queue configuration (e.g. store on remote machine).
* rgerhards, 2009-05-26
*/
static inline rsRetVal
static rsRetVal
DoSaveOnShutdown(qqueue_t *pThis)
{
struct timespec tTimeout;
@ -2559,6 +2614,7 @@ DoSaveOnShutdown(qqueue_t *pThis)
/* destructor for the queue object */
BEGINobjDestruct(qqueue) /* be sure to specify the object type also in END and CODESTART macros! */
CODESTARTobjDestruct(qqueue)
DBGOPRINT((obj_t*) pThis, "shutdown: begin to destruct queue\n");
if(pThis->bQueueStarted) {
/* shut down all workers
* We do not need to shutdown workers when we are in enqueue-only mode or we are a
@ -2712,7 +2768,7 @@ finalize_it:
* Note that the queue mutex MUST already be locked when this function is called.
* rgerhards, 2009-06-16
*/
static inline rsRetVal
static rsRetVal
doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, msg_t *pMsg)
{
DEFiRet;
@ -2824,6 +2880,19 @@ doEnqSingleObj(qqueue_t *pThis, flowControl_t flowCtlType, msg_t *pMsg)
CHKiRet(qqueueAdd(pThis, pMsg));
STATSCOUNTER_SETMAX_NOMUT(pThis->ctrMaxqsize, pThis->iQueueSize);
/* check if we had a file rollover and need to persist
* the .qi file for robustness reasons.
* Note: the n=2 write is required for closing the old file and
* the n=1 write is required after opening and writing to the new
* file.
*/
if(pThis->tVars.disk.nForcePersist > 0) {
DBGOPRINT((obj_t*) pThis, ".qi file write required for robustness reasons (n=%d)\n",
pThis->tVars.disk.nForcePersist);
pThis->tVars.disk.nForcePersist--;
qqueuePersist(pThis, QUEUE_CHECKPOINT);
}
finalize_it:
RETiRet;
}
@ -2945,7 +3014,7 @@ queueCnfParamsSet(struct nvlst *lst)
}
static inline rsRetVal
static rsRetVal
initCryprov(qqueue_t *pThis, struct nvlst *lst)
{
uchar szDrvrName[1024];
@ -3112,10 +3181,8 @@ DEFpropSetMeth(qqueue, toEnq, long)
DEFpropSetMeth(qqueue, iHighWtrMrk, int)
DEFpropSetMeth(qqueue, iLowWtrMrk, int)
DEFpropSetMeth(qqueue, iDiscardMrk, int)
DEFpropSetMeth(qqueue, iFullDlyMrk, int)
DEFpropSetMeth(qqueue, iDiscardSeverity, int)
DEFpropSetMeth(qqueue, iLightDlyMrk, int)
DEFpropSetMeth(qqueue, bIsDA, int)
DEFpropSetMeth(qqueue, iNumWorkerThreads, int)
DEFpropSetMeth(qqueue, iMinMsgsPerWrkr, int)
DEFpropSetMeth(qqueue, bSaveOnShutdown, int)
@ -3156,7 +3223,7 @@ finalize_it:
#undef isProp
/* dummy */
rsRetVal qqueueQueryInterface(void) { return RS_RET_NOT_IMPLEMENTED; }
static rsRetVal qqueueQueryInterface(void) { return RS_RET_NOT_IMPLEMENTED; }
/* Initialize the stream class. Must be called as the very first method
* before anything else is called inside this class.

View File

@ -166,6 +166,7 @@ struct queue_s {
strm_t *pWrite; /* current file to be written */
strm_t *pReadDeq; /* current file for dequeueing */
strm_t *pReadDel; /* current file for deleting */
int nForcePersist;/* force persist of .qi file the next "n" times */
} disk;
} tVars;
sbool useCryprov; /* quicker than checkig ptr (1 vs 8 bytes!) */

View File

@ -2,7 +2,7 @@
* support for rate-limiting sources, including "last message
* repeated n times" processing.
*
* Copyright 2012 Rainer Gerhards and Adiscon GmbH.
* Copyright 2012-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -45,7 +45,7 @@ DEFobjCurrIf(parser)
/* static data */
/* generate a "repeated n times" message */
static inline msg_t *
static msg_t *
ratelimitGenRepMsg(ratelimit_t *ratelimit)
{
msg_t *repMsg;
@ -112,7 +112,7 @@ finalize_it:
/* helper: tell how many messages we lost due to linux-like ratelimiting */
static inline void
static void
tellLostCnt(ratelimit_t *ratelimit)
{
uchar msgbuf[1024];
@ -131,7 +131,7 @@ tellLostCnt(ratelimit_t *ratelimit)
* This implementation is NOT THREAD-SAFE and must not
* be called concurrently.
*/
static inline int
static int
withinRatelimit(ratelimit_t *ratelimit, time_t tt)
{
int ret;
@ -282,7 +282,7 @@ finalize_it:
* Both values should be kept brief.
*/
rsRetVal
ratelimitNew(ratelimit_t **ppThis, char *modname, char *dynname)
ratelimitNew(ratelimit_t **ppThis, const char *modname, const char *dynname)
{
ratelimit_t *pThis;
char namebuf[256];

View File

@ -1,6 +1,6 @@
/* header for ratelimit.c
*
* Copyright 2012 Adiscon GmbH.
* Copyright 2012-2016 Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -40,7 +40,7 @@ struct ratelimit_s {
};
/* prototypes */
rsRetVal ratelimitNew(ratelimit_t **ppThis, char *modname, char *dynname);
rsRetVal ratelimitNew(ratelimit_t **ppThis, const char *modname, const char *dynname);
void ratelimitSetThreadSafe(ratelimit_t *ratelimit);
void ratelimitSetLinuxLike(ratelimit_t *ratelimit, unsigned short interval, unsigned short burst);
void ratelimitSetNoTimeCache(ratelimit_t *ratelimit);

View File

@ -2,7 +2,7 @@
*
* Module begun 2011-04-19 by Rainer Gerhards
*
* Copyright 2011-2015 Adiscon GmbH.
* Copyright 2011-2016 Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -122,7 +122,12 @@ static struct cnfparamblk parserpblk =
/* forward-definitions */
void cnfDoCfsysline(char *ln);
void cnfSetDefaults(rsconf_t *pThis)
int rsconfNeedDropPriv(rsconf_t *const cnf)
{
return ((cnf->globals.gidDropPriv != 0) || (cnf->globals.uidDropPriv != 0));
}
static void cnfSetDefaults(rsconf_t *pThis)
{
pThis->globals.bAbortOnUncleanConfig = 0;
pThis->globals.bReduceRepeatMsgs = 0;
@ -177,7 +182,8 @@ ENDobjConstruct(rsconf)
/* ConstructionFinalizer
*/
rsRetVal rsconfConstructFinalize(rsconf_t __attribute__((unused)) *pThis)
static rsRetVal
rsconfConstructFinalize(rsconf_t __attribute__((unused)) *pThis)
{
DEFiRet;
ISOBJ_TYPE_assert(pThis, rsconf);
@ -206,6 +212,7 @@ freeCnf(rsconf_t *pThis)
/* destructor for the rsconf object */
PROTOTYPEobjDestruct(rsconf);
BEGINobjDestruct(rsconf) /* be sure to specify the object type also in END and CODESTART macros! */
CODESTARTobjDestruct(rsconf)
freeCnf(pThis);
@ -219,6 +226,7 @@ ENDobjDestruct(rsconf)
/* DebugPrint support for the rsconf object */
PROTOTYPEObjDebugPrint(rsconf);
BEGINobjDebugPrint(rsconf) /* be sure to specify the object type also in END and CODESTART macros! */
cfgmodules_etry_t *modNode;
@ -276,7 +284,7 @@ CODESTARTobjDebugPrint(rsconf)
ENDobjDebugPrint(rsconf)
rsRetVal
static rsRetVal
parserProcessCnf(struct cnfobj *o)
{
struct cnfparamvals *pvals;
@ -326,7 +334,7 @@ finalize_it:
/* Process input() objects */
rsRetVal
static rsRetVal
inputProcessCnf(struct cnfobj *o)
{
struct cnfparamvals *pvals;
@ -363,7 +371,7 @@ finalize_it:
extern int yylineno;
void
parser_warnmsg(char *fmt, ...)
parser_warnmsg(const char *fmt, ...)
{
va_list ap;
char errBuf[1024];
@ -378,7 +386,7 @@ parser_warnmsg(char *fmt, ...)
}
void
parser_errmsg(char *fmt, ...)
parser_errmsg(const char *fmt, ...)
{
va_list ap;
char errBuf[1024];
@ -397,8 +405,9 @@ parser_errmsg(char *fmt, ...)
va_end(ap);
}
int yyerror(const char *s); /* we need this prototype to make compiler happy */
int
yyerror(char *s)
yyerror(const char *s)
{
parser_errmsg("%s on token '%s'", s, yytext);
return 0;
@ -448,6 +457,7 @@ void cnfDoObj(struct cnfobj *o)
/* these types are processed at a later stage */
bChkUnuse = 0;
break;
case CNFOBJ_ACTION:
default:
dbgprintf("cnfDoObj program error: unexpected object type %u\n",
o->objType);
@ -778,8 +788,8 @@ startInputModules(void)
/* activate the main queue */
static inline rsRetVal
activateMainQueue()
static rsRetVal
activateMainQueue(void)
{
struct cnfobj *mainqCnfObj;
DEFiRet;
@ -825,7 +835,7 @@ setUmask(int iUmask)
* version of rsyslog does not support this. Future versions probably will.
* Begun 2011-04-20, rgerhards
*/
rsRetVal
static rsRetVal
activate(rsconf_t *cnf)
{
DEFiRet;
@ -1029,7 +1039,7 @@ finalize_it:
* very first version begun on 2007-07-23 by rgerhards
*/
static rsRetVal
loadBuildInModules()
loadBuildInModules(void)
{
DEFiRet;
@ -1277,7 +1287,7 @@ validateConf(void)
* object that holds the currently-being-loaded config ptr.
* Begun 2011-04-20, rgerhards
*/
rsRetVal
static rsRetVal
load(rsconf_t **cnf, uchar *confFile)
{
int iNbrActions = 0;
@ -1361,8 +1371,6 @@ CODESTARTobjQueryInterface(rsconf)
* work here (if we can support an older interface version - that,
* of course, also affects the "if" above).
*/
pIf->Construct = rsconfConstruct;
pIf->ConstructFinalize = rsconfConstructFinalize;
pIf->Destruct = rsconfDestruct;
pIf->DebugPrint = rsconfDebugPrint;
pIf->Load = load;

View File

@ -1,6 +1,6 @@
/* The rsconf object. It models a complete rsyslog configuration.
*
* Copyright 2011 Rainer Gerhards and Adiscon GmbH.
* Copyright 2011-2016 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@ -163,8 +163,6 @@ struct rsconf_s {
/* interfaces */
BEGINinterface(rsconf) /* name must also be changed in ENDinterface macro! */
INTERFACEObjDebugPrint(rsconf);
rsRetVal (*Construct)(rsconf_t **ppThis);
rsRetVal (*ConstructFinalize)(rsconf_t __attribute__((unused)) *pThis);
rsRetVal (*Destruct)(rsconf_t **ppThis);
rsRetVal (*Load)(rsconf_t **ppThis, uchar *confFile);
rsRetVal (*Activate)(rsconf_t *ppThis);
@ -181,9 +179,7 @@ extern rsconf_t *runConf;/* the currently running config */
extern rsconf_t *loadConf;/* the config currently being loaded (no concurrent config load supported!) */
static inline int rsconfNeedDropPriv(rsconf_t *const cnf) {
return ((cnf->globals.gidDropPriv != 0) || (cnf->globals.uidDropPriv != 0));
}
int rsconfNeedDropPriv(rsconf_t *const cnf);
/* some defaults (to be removed?) */
#define DFLT_bLogStatusMsgs 1

View File

@ -134,7 +134,7 @@ rsrtSetErrLogger(void (*errLogger)(const int, const int, const uchar*))
* rgerhards, 2008-04-16
*/
rsRetVal
rsrtInit(char **ppErrObj, obj_if_t *pObjIF)
rsrtInit(const char **ppErrObj, obj_if_t *pObjIF)
{
DEFiRet;

Some files were not shown because too many files have changed in this diff Show More