~ubuntu-branches/ubuntu/trusty/rsyslog/trusty

« back to all changes in this revision

Viewing changes to runtime/rule.c

  • Committer: Dave Walker (Daviey)
  • Author(s): Scott Moser
  • Date: 2011-06-17 20:59:38 UTC
  • mfrom: (36.1.8 oneiric.merge)
  • Revision ID: davewalker@ubuntu.com-20110617205938-pfkizxz2wsgzi2ot
Tags: 5.8.1-1ubuntu1
* Resynchronise with Debian (LP: #794230).  Remaining changes:
  - Run as rsyslog:rsyslog, set $FileOwner to syslog
  - Replace init script with debian/rsyslog.upstart.
  - debian/rsyslog.logrotate: Use reload command to restart rsyslog
  - debian/rsyslog.conf: enable $RepeatedMsgReduction 
    to avoid bloating the syslog file (LP #453444)
  - Add debian/rsyslog.dmesg.upstart to save initial dmesg into a file.
    Install it in debian/rules.
  - debian/50-default.conf: set of default rules for syslog (forwarded to
    Debian #603160). remove file in postrm on purge. manage with ucf.
  - debian/rules: build with LDFLAGS=""
* Dropped:
  - debian/control: Bump build-dependency on debhelper
    debian now depends on dh >= 8
* New upstream release.
* Bump Standards-Version to 3.9.2. No further changes.
* Enable and install impstats module. (Closes: #620114)
* Update logcheck rule. (Closes: #616659)
* debian/rsyslog.init: Set correct compat level (5).
* The way rsyslog processes SIGHUP has changed. It no longer does a reload
  of its configuration, but simply closes all open files. To apply a changed
  configuration, rsyslogd needs to be restarted now.
  - Drop "reload" action from debian/rsyslog.init, map "force-reload" to
    "restart". (Closes: #580897)
  - Add "rotate" action to debian/rsyslog.init which sends SIGHUP to
    rsyslogd. Use that in debian/rsyslog.logrotate. (Closes: #626365)
  - Update debian/rsyslog-mysql.postinst and rsyslog-pgsql.postinst to use
    restart instead of reload.
  - Add a NEWS file explaining the changed SIGHUP handling.
* New upstream stable release.
* New upstream release.
  - Properly handle ANSI SQL strings in ompgsql. (Closes: #600479)
* New upstream release.
* debian/patches/02-pmaixforwardedfrom_type_nokeep.patch
  - Remove, merged upstream.
* debian/patches/03-epoll_create1-fallback.patch
  - Remove, merged upstream.
* debian/patches/03-epoll_create1-fallback.patch
  - If epoll_create1() is not available during runtime, fall back to
    epoll_create(). This fixes remote syslog when runnig rsyslog on a
    lenny kernel. (Closes: #617996)
* New upstream release.
* debian/rsyslog.links
  - Create symlink for rsyslog.service in multi-user.target.wants so rsyslog
    is enabled by default when using systemd.
* debian/patches/02-pmaixforwardedfrom_type_nokeep.patch
  - Fix build failure in aixforwardedfrom parser module by setting the
    module type to NOKEEP.
* debian/rsyslog.preinst
  - Remove old rsyslog.socket symlink from sockets.target.wants on upgrades
    as rsyslog uses syslog.socket now which is provided by systemd.
* debian/rsyslog.install
  - Stop installing rsyslog.socket.
* New upstream release.
* New upstream release.
  - Fix regression in imuxsock plugin which did no longer sanitize received
    messages. This makes 02-cleanup-trailing-lf.patch obsolete and also
    fixes the SQL syntax errors in the mysql output if the input contained
    NUL bytes. Closes: #614061
* Enable and install omprog output plugin. Closes: #552095
* Improve package description. Closes: #612948
  Thanks to Justin B Rye for the patch.
* debian/patches/02-cleanup-trailing-lf.patch
  - Fix regression in imuxsock plugin which did not remove a trailing LF
    anymore. Patch cherry-picked from upstream Git. Closes: #612829
* New upstream release.
* Enable and install parser modules.
* New upstream release.
* Upload to unstable.
* debian/patches/02-typo_fix_equation_sign.patch
  - Removed, merged upstream.
* debian/patches/03-atomic_operations.patch
  - Removed, merged upstream.
* debian/patches/03-atomic_operations.patch
  - Fix build failures on platforms which don't have 64 bit atomic
    operations. Patch cherry-picked from upstream Git. Closes: #600930
* New upstream development release.
* Remove patches, merged upstream
  - debian/patches/02-install_also_rsyslog_socket.patch
  - debian/patches/02-tls_loop_fix.patch
* debian/patches/02-typo_fix_equation_sign.patch
  - Fix small typo ("equation sign"). Closes: #575589
* debian/rsyslog.postinst
  - Remove pre-lenny migration code to rotate old log files from sysklogd.
* New upstream development release.
* debian/rsyslog.install
  - Install omruleset.so plugin: http://www.rsyslog.com/doc/omruleset.html
* debian/rsyslog.default
  - Start rsyslogd with native -c5 mode.
* Install systemd unit files which allow to run rsyslog in socket activation
  mode when systemd is used.
* debian/patches/02-install_also_rsyslog_socket.patch
  - When enabling rsyslog.service also enable rsyslog.socket. Patch
    cherry-picked from upstream Git.
* Bump debhelper compatibility level to 8. Update Build-Depends accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include "vm.h"
40
40
#include "var.h"
41
41
#include "srUtils.h"
 
42
#include "batch.h"
42
43
#include "unicode-helper.h"
43
 
#include "dirty.h" /* for getFIOPName */
44
44
 
45
45
/* static data */
46
46
DEFobjStaticHelpers
49
49
DEFobjCurrIf(var)
50
50
DEFobjCurrIf(vm)
51
51
 
 
52
 
 
53
/* support for simple textual representation of FIOP names
 
54
 * rgerhards, 2005-09-27
 
55
 */
 
56
static char*
 
57
getFIOPName(unsigned iFIOP)
 
58
{
 
59
        char *pRet;
 
60
        switch(iFIOP) {
 
61
                case FIOP_CONTAINS:
 
62
                        pRet = "contains";
 
63
                        break;
 
64
                case FIOP_ISEQUAL:
 
65
                        pRet = "isequal";
 
66
                        break;
 
67
                case FIOP_STARTSWITH:
 
68
                        pRet = "startswith";
 
69
                        break;
 
70
                case FIOP_REGEX:
 
71
                        pRet = "regex";
 
72
                        break;
 
73
                default:
 
74
                        pRet = "NOP";
 
75
                        break;
 
76
        }
 
77
        return pRet;
 
78
}
 
79
 
 
80
 
52
81
/* iterate over all actions, this is often needed, for example when HUP processing 
53
82
 * must be done or a shutdown is pending.
54
83
 */
59
88
}
60
89
 
61
90
 
62
 
 
63
91
/* helper to processMsg(), used to call the configured actions. It is
64
92
 * executed from within llExecFunc() of the action list.
65
93
 * rgerhards, 2007-08-02
66
94
 */
67
 
typedef struct processMsgDoActions_s {
68
 
        int bPrevWasSuspended; /* was the previous action suspended? */
69
 
        msg_t *pMsg;
70
 
} processMsgDoActions_t;
71
 
DEFFUNC_llExecFunc(processMsgDoActions)
 
95
DEFFUNC_llExecFunc(processBatchDoActions)
72
96
{
73
97
        DEFiRet;
74
98
        rsRetVal iRetMod;       /* return value of module - we do not always pass that back */
75
99
        action_t *pAction = (action_t*) pData;
76
 
        processMsgDoActions_t *pDoActData = (processMsgDoActions_t*) pParam;
77
 
 
78
 
        assert(pAction != NULL);
79
 
 
80
 
        if((pAction->bExecWhenPrevSusp  == 1) && (pDoActData->bPrevWasSuspended == 0)) {
81
 
                dbgprintf("not calling action because the previous one is not suspended\n");
82
 
                ABORT_FINALIZE(RS_RET_OK);
83
 
        }
84
 
 
85
 
        iRetMod = actionCallAction(pAction, pDoActData->pMsg);
86
 
        if(iRetMod == RS_RET_DISCARDMSG) {
87
 
                ABORT_FINALIZE(RS_RET_DISCARDMSG);
88
 
        } else if(iRetMod == RS_RET_SUSPENDED) {
89
 
                /* indicate suspension for next module to be called */
90
 
                pDoActData->bPrevWasSuspended = 1;
91
 
        } else {
92
 
                pDoActData->bPrevWasSuspended = 0;
93
 
        }
94
 
 
95
 
finalize_it:
 
100
        batch_t *pBatch = (batch_t*) pParam;
 
101
 
 
102
        DBGPRINTF("Processing next action\n");
 
103
        iRetMod = pAction->submitToActQ(pAction, pBatch);
 
104
 
96
105
        RETiRet;
97
106
}
98
107
 
101
110
 * provided filter condition.
102
111
 */
103
112
static rsRetVal
104
 
shouldProcessThisMessage(rule_t *pRule, msg_t *pMsg, int *bProcessMsg)
 
113
shouldProcessThisMessage(rule_t *pRule, msg_t *pMsg, sbool *bProcessMsg)
105
114
{
106
115
        DEFiRet;
107
116
        unsigned short pbMustBeFreed;
164
173
 
165
174
        if(pRule->f_filter_type == FILTER_PRI) {
166
175
                /* skip messages that are incorrect priority */
167
 
dbgprintf("testing filter, f_pmask %d\n", pRule->f_filterData.f_pmask[pMsg->iFacility]);
 
176
                dbgprintf("testing filter, f_pmask %d\n", pRule->f_filterData.f_pmask[pMsg->iFacility]);
168
177
                if ( (pRule->f_filterData.f_pmask[pMsg->iFacility] == TABLE_NOPRI) || \
169
178
                    ((pRule->f_filterData.f_pmask[pMsg->iFacility] & (1<<pMsg->iSeverity)) == 0) )
170
179
                        bRet = 0;
176
185
                CHKiRet(vm.SetMsg(pVM, pMsg));
177
186
                CHKiRet(vm.ExecProg(pVM, pRule->f_filterData.f_expr->pVmprg));
178
187
                CHKiRet(vm.PopBoolFromStack(pVM, &pResult));
179
 
                dbgprintf("result of expression evaluation: %lld\n", pResult->val.num);
 
188
                dbgprintf("result of rainerscript filter evaluation: %lld\n", pResult->val.num);
180
189
                /* VM is destructed on function exit */
181
190
                bRet = (pResult->val.num) ? 1 : 0;
182
191
        } else {
250
259
 
251
260
 
252
261
 
253
 
/* Process (consume) a received message. Calls the actions configured.
 
262
/* Process (consume) a batch of messages. Calls the actions configured.
254
263
 * rgerhards, 2005-10-13
255
264
 */
256
265
static rsRetVal
257
 
processMsg(rule_t *pThis, msg_t *pMsg)
 
266
processBatch(rule_t *pThis, batch_t *pBatch)
258
267
{
259
 
        int bProcessMsg;
260
 
        processMsgDoActions_t DoActData;
 
268
        int i;
261
269
        DEFiRet;
262
270
 
263
271
        ISOBJ_TYPE_assert(pThis, rule);
264
 
        assert(pMsg != NULL);
 
272
        assert(pBatch != NULL);
265
273
 
266
 
        /* first check the filters... */
267
 
        CHKiRet(shouldProcessThisMessage(pThis, pMsg, &bProcessMsg));
268
 
        if(bProcessMsg) {
269
 
                DoActData.pMsg = pMsg;
270
 
                DoActData.bPrevWasSuspended = 0;
271
 
                CHKiRet(llExecFunc(&pThis->llActList, processMsgDoActions, (void*)&DoActData));
 
274
        /* first check the filters and reset status variables */
 
275
        for(i = 0 ; i < batchNumMsgs(pBatch) && !*(pBatch->pbShutdownImmediate) ; ++i) {
 
276
                CHKiRet(shouldProcessThisMessage(pThis, (msg_t*)(pBatch->pElem[i].pUsrp),
 
277
                                                 &(pBatch->pElem[i].bFilterOK)));
 
278
                // TODO: really abort on error? 2010-06-10
 
279
                if(pBatch->pElem[i].bFilterOK) {
 
280
                        /* re-init only when actually needed (cache write cost!) */
 
281
                        pBatch->pElem[i].bPrevWasSuspended = 0;
 
282
                }
272
283
        }
 
284
        CHKiRet(llExecFunc(&pThis->llActList, processBatchDoActions, pBatch));
273
285
 
274
286
finalize_it:
275
287
        RETiRet;
412
424
        pIf->DebugPrint = ruleDebugPrint;
413
425
 
414
426
        pIf->IterateAllActions = iterateAllActions;
415
 
        pIf->ProcessMsg = processMsg;
 
427
        pIf->ProcessBatch = processBatch;
416
428
        pIf->SetAssRuleset = setAssRuleset;
417
429
        pIf->GetAssRuleset = getAssRuleset;
418
430
finalize_it: