~ubuntu-branches/ubuntu/oneiric/rsyslog/oneiric

« back to all changes in this revision

Viewing changes to tools/smfile.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:
 
1
/* smfile.c
 
2
 * This is a strgen module for the traditional file format.
 
3
 *
 
4
 * Format generated:
 
5
 * "%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
 
6
 * Note that this is the same as smtradfile.c, except that we do have a RFC3339 timestamp. However,
 
7
 * we have copied over the code from there, it is too simple to go through all the hassle
 
8
 * of having a single code base.
 
9
 *
 
10
 * NOTE: read comments in module-template.h to understand how this file
 
11
 *       works!
 
12
 *
 
13
 * File begun on 2010-06-01 by RGerhards
 
14
 *
 
15
 * Copyright 2010 Rainer Gerhards and Adiscon GmbH.
 
16
 *
 
17
 * This file is part of rsyslog.
 
18
 *
 
19
 * Rsyslog is free software: you can redistribute it and/or modify
 
20
 * it under the terms of the GNU General Public License as published by
 
21
 * the Free Software Foundation, either version 3 of the License, or
 
22
 * (at your option) any later version.
 
23
 *
 
24
 * Rsyslog is distributed in the hope that it will be useful,
 
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
27
 * GNU General Public License for more details.
 
28
 *
 
29
 * You should have received a copy of the GNU General Public License
 
30
 * along with Rsyslog.  If not, see <http://www.gnu.org/licenses/>.
 
31
 *
 
32
 * A copy of the GPL can be found in the file "COPYING" in this distribution.
 
33
 */
 
34
#include "config.h"
 
35
#include "rsyslog.h"
 
36
#include <stdlib.h>
 
37
#include <string.h>
 
38
#include <assert.h>
 
39
#include <errno.h>
 
40
#include "syslogd.h"
 
41
#include "conf.h"
 
42
#include "syslogd-types.h"
 
43
#include "template.h"
 
44
#include "msg.h"
 
45
#include "module-template.h"
 
46
#include "unicode-helper.h"
 
47
 
 
48
MODULE_TYPE_STRGEN
 
49
MODULE_TYPE_NOKEEP
 
50
STRGEN_NAME("RSYSLOG_FileFormat")
 
51
 
 
52
/* internal structures
 
53
 */
 
54
DEF_SMOD_STATIC_DATA
 
55
 
 
56
 
 
57
/* config data */
 
58
 
 
59
 
 
60
/* This strgen tries to minimize the amount of reallocs be first obtaining pointers to all strings
 
61
 * needed (including their length) and then calculating the actual space required. So when we 
 
62
 * finally copy, we know exactly what we need. So we do at most one alloc.
 
63
 */
 
64
BEGINstrgen
 
65
        register int iBuf;
 
66
        uchar *pTimeStamp;
 
67
        size_t lenTimeStamp;
 
68
        uchar *pHOSTNAME;
 
69
        size_t lenHOSTNAME;
 
70
        uchar *pTAG;
 
71
        int lenTAG;
 
72
        uchar *pMSG;
 
73
        size_t lenMSG;
 
74
        size_t lenTotal;
 
75
CODESTARTstrgen
 
76
        /* first obtain all strings and their length (if not fixed) */
 
77
        pTimeStamp = (uchar*) getTimeReported(pMsg, tplFmtRFC3339Date);
 
78
        lenTimeStamp = ustrlen(pTimeStamp);
 
79
        pHOSTNAME = (uchar*) getHOSTNAME(pMsg);
 
80
        lenHOSTNAME = getHOSTNAMELen(pMsg);
 
81
        getTAG(pMsg, &pTAG, &lenTAG);
 
82
        pMSG = getMSG(pMsg);
 
83
        lenMSG = getMSGLen(pMsg);
 
84
 
 
85
        /* calculate len, constants for spaces and similar fixed strings */
 
86
        lenTotal = lenTimeStamp + 1 + lenHOSTNAME + 1 + lenTAG + lenMSG + 2;
 
87
        if(pMSG[0] != ' ')
 
88
                ++lenTotal; /* then we need to introduce one additional space */
 
89
 
 
90
        /* now make sure buffer is large enough */
 
91
        if(lenTotal  >= *pLenBuf)
 
92
                CHKiRet(ExtendBuf(ppBuf, pLenBuf, lenTotal));
 
93
 
 
94
        /* and concatenate the resulting string */
 
95
        memcpy(*ppBuf, pTimeStamp, lenTimeStamp);
 
96
        iBuf = lenTimeStamp;
 
97
        *(*ppBuf + iBuf++) = ' ';
 
98
 
 
99
        memcpy(*ppBuf + iBuf, pHOSTNAME, lenHOSTNAME);
 
100
        iBuf += lenHOSTNAME;
 
101
        *(*ppBuf + iBuf++) = ' ';
 
102
 
 
103
        memcpy(*ppBuf + iBuf, pTAG, lenTAG);
 
104
        iBuf += lenTAG;
 
105
 
 
106
        if(pMSG[0] != ' ')
 
107
                *(*ppBuf + iBuf++) = ' ';
 
108
        memcpy(*ppBuf + iBuf, pMSG, lenMSG);
 
109
        iBuf += lenMSG;
 
110
 
 
111
        /* trailer */
 
112
        *(*ppBuf + iBuf++) = '\n';
 
113
        *(*ppBuf + iBuf) = '\0';
 
114
 
 
115
finalize_it:
 
116
ENDstrgen
 
117
 
 
118
 
 
119
BEGINmodExit
 
120
CODESTARTmodExit
 
121
ENDmodExit
 
122
 
 
123
 
 
124
BEGINqueryEtryPt
 
125
CODESTARTqueryEtryPt
 
126
CODEqueryEtryPt_STD_SMOD_QUERIES
 
127
ENDqueryEtryPt
 
128
 
 
129
 
 
130
BEGINmodInit(smfile)
 
131
CODESTARTmodInit
 
132
        *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
 
133
CODEmodInit_QueryRegCFSLineHdlr
 
134
 
 
135
        dbgprintf("rsyslog standard file format strgen init called, compiled with version %s\n", VERSION);
 
136
ENDmodInit