From 5fccf771f37973a2cea543fbdf1ed94ed9706faf Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 11 Mar 2014 19:04:23 +0100 Subject: Imported Upstream version 7.4.8 --- tools/omfile.c | 34 ++--- tools/recover_qi.pl | 414 ++++++++++++++++++++++++++-------------------------- tools/rsgtutil.c | 11 +- tools/syslogd.c | 24 ++- 4 files changed, 254 insertions(+), 229 deletions(-) (limited to 'tools') diff --git a/tools/omfile.c b/tools/omfile.c index ba9f7f7..3dca347 100644 --- a/tools/omfile.c +++ b/tools/omfile.c @@ -133,7 +133,7 @@ typedef struct s_dynaFileCacheEntry dynaFileCacheEntry; typedef struct _instanceData { - uchar *f_fname; /* file or template name (display only) */ + uchar *fname; /* file or template name (display only) */ uchar *tplName; /* name of assigned template */ strm_t *pStrm; /* our output stream */ char bDynamicName; /* 0 - static name, 1 - dynamic name (with properties) */ @@ -287,11 +287,11 @@ CODESTARTdbgPrintInstInfo if(pData->bDynamicName) { dbgprintf("[dynamic]\n"); } else { /* regular file */ - dbgprintf("%s%s\n", pData->f_fname, + dbgprintf("%s%s\n", pData->fname, (pData->pStrm == NULL) ? " (closed)" : ""); } - dbgprintf("\ttemplate='%s'\n", pData->f_fname); + dbgprintf("\ttemplate='%s'\n", pData->fname); dbgprintf("\tuse async writer=%d\n", pData->bUseAsyncWriter); dbgprintf("\tflush on TX end=%d\n", pData->bFlushOnTXEnd); dbgprintf("\tflush interval=%d\n", pData->iFlushInterval); @@ -411,7 +411,7 @@ static rsRetVal cflineParseOutchannel(instanceData *pData, uchar* p, omodStringR } /* OK, we finally got a correct template. So let's use it... */ - pData->f_fname = ustrdup(pOch->pszFileTemplate); + pData->fname = ustrdup(pOch->pszFileTemplate); pData->iSizeLimit = pOch->uSizeLimit; /* WARNING: It is dangerous "just" to pass the pointer. As we * never rebuild the output channel description, this is acceptable here. @@ -796,9 +796,9 @@ writeFile(uchar **ppString, unsigned iMsgOpts, instanceData *pData) CHKiRet(prepareDynFile(pData, ppString[1], iMsgOpts)); } else { /* "regular", non-dynafile */ if(pData->pStrm == NULL) { - CHKiRet(prepareFile(pData, pData->f_fname)); + CHKiRet(prepareFile(pData, pData->fname)); if(pData->pStrm == NULL) { - errmsg.LogError(0, RS_RET_NO_FILE_ACCESS, "Could no open output file '%s'", pData->f_fname); + errmsg.LogError(0, RS_RET_NO_FILE_ACCESS, "Could no open output file '%s'", pData->fname); } } } @@ -885,7 +885,7 @@ ENDcreateInstance BEGINfreeInstance CODESTARTfreeInstance free(pData->tplName); - free(pData->f_fname); + free(pData->fname); if(pData->bDynamicName) { dynaFileFreeCache(pData); } else if(pData->pStrm != NULL) @@ -935,7 +935,7 @@ ENDendTransaction BEGINdoAction CODESTARTdoAction DBGPRINTF("file to log to: %s\n", - (pData->bDynamicName) ? ppString[1] : pData->f_fname); + (pData->bDynamicName) ? ppString[1] : pData->fname); DBGPRINTF("omfile: start of data: '%.128s'\n", ppString[0]); STATSCOUNTER_INC(pData->ctrRequests, pData->mutCtrRequests); CHKiRet(writeFile(ppString, iMsgOpts, pData)); @@ -951,7 +951,7 @@ ENDdoAction static inline void setInstParamDefaults(instanceData *pData) { - pData->f_fname = NULL; + pData->fname = NULL; pData->tplName = NULL; pData->fileUID = -1; pData->fileGID = -1; @@ -987,7 +987,7 @@ setupInstStatsCtrs(instanceData *pData) } /* support statistics gathering */ - snprintf((char*)ctrName, sizeof(ctrName), "dynafile cache %s", pData->f_fname); + snprintf((char*)ctrName, sizeof(ctrName), "dynafile cache %s", pData->fname); ctrName[sizeof(ctrName)-1] = '\0'; /* be on the save side */ CHKiRet(statsobj.Construct(&(pData->stats))); CHKiRet(statsobj.SetName(pData->stats, ctrName)); @@ -1156,11 +1156,11 @@ CODESTARTnewActInst } else if(!strcmp(actpblk.descr[i].name, "createdirs")) { pData->bCreateDirs = (int) pvals[i].val.d.n; } else if(!strcmp(actpblk.descr[i].name, "file")) { - pData->f_fname = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); + pData->fname = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); CODE_STD_STRING_REQUESTnewActInst(1) pData->bDynamicName = 0; } else if(!strcmp(actpblk.descr[i].name, "dynafile")) { - pData->f_fname = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); + pData->fname = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL); CODE_STD_STRING_REQUESTnewActInst(2) pData->bDynamicName = 1; } else if(!strcmp(actpblk.descr[i].name, "template")) { @@ -1175,7 +1175,7 @@ CODESTARTnewActInst } } - if(pData->f_fname == NULL) { + if(pData->fname == NULL) { errmsg.LogError(0, RS_RET_MISSING_CNFPARAMS, "omfile: either the \"file\" or " "\"dynfile\" parameter must be given"); ABORT_FINALIZE(RS_RET_MISSING_CNFPARAMS); @@ -1196,7 +1196,7 @@ CODESTARTnewActInst /* "filename" is actually a template name, we need this as string 1. So let's add it * to the pOMSR. -- rgerhards, 2007-07-27 */ - CHKiRet(OMSRsetEntry(*ppOMSR, 1, ustrdup(pData->f_fname), OMSR_NO_RQD_TPL_OPTS)); + CHKiRet(OMSRsetEntry(*ppOMSR, 1, ustrdup(pData->fname), OMSR_NO_RQD_TPL_OPTS)); // TODO: create unified code for this (legacy+v6 system) /* we now allocate the cache table */ CHKmalloc(pData->dynCache = (dynaFileCacheEntry**) @@ -1255,13 +1255,13 @@ CODESTARTparseSelectorAct CODE_STD_STRING_REQUESTparseSelectorAct(2) ++p; /* eat '?' */ CHKiRet(cflineParseFileName(p, fname, *ppOMSR, 0, OMSR_NO_RQD_TPL_OPTS, getDfltTpl())); - pData->f_fname = ustrdup(fname); + pData->fname = ustrdup(fname); pData->bDynamicName = 1; pData->iCurrElt = -1; /* no current element */ /* "filename" is actually a template name, we need this as string 1. So let's add it * to the pOMSR. -- rgerhards, 2007-07-27 */ - CHKiRet(OMSRsetEntry(*ppOMSR, 1, ustrdup(pData->f_fname), OMSR_NO_RQD_TPL_OPTS)); + CHKiRet(OMSRsetEntry(*ppOMSR, 1, ustrdup(pData->fname), OMSR_NO_RQD_TPL_OPTS)); /* we now allocate the cache table */ CHKmalloc(pData->dynCache = (dynaFileCacheEntry**) calloc(cs.iDynaFileCacheSize, sizeof(dynaFileCacheEntry*))); @@ -1271,7 +1271,7 @@ CODESTARTparseSelectorAct case '.': CODE_STD_STRING_REQUESTparseSelectorAct(1) CHKiRet(cflineParseFileName(p, fname, *ppOMSR, 0, OMSR_NO_RQD_TPL_OPTS, getDfltTpl())); - pData->f_fname = ustrdup(fname); + pData->fname = ustrdup(fname); pData->bDynamicName = 0; break; default: diff --git a/tools/recover_qi.pl b/tools/recover_qi.pl index 4e2cf9d..eb8de55 100755 --- a/tools/recover_qi.pl +++ b/tools/recover_qi.pl @@ -1,207 +1,207 @@ -#!/usr/bin/perl -w -# recover rsyslog disk queue index (.qi) from queue files (.nnnnnnnn). -# -# See: -# runtime/queue.c: qqueuePersist() -# runtime/queue.c: qqueueTryLoadPersistedInfo() -# -# kaiwang.chen@gmail.com 2012-03-14 -# -use strict; -use Getopt::Long; - -my %opt = (); -GetOptions(\%opt,"spool|w=s","basename|f=s","digits|d=i","help!"); -if ($opt{help}) { - print "Usage: -\t$0 -w WorkDirectory -f QueueFileName -d 8 > QueueFileName.qi -"; - exit; -} - -# runtime/queue.c: qConstructDisk() -my $iMaxFiles = 10000000; # 0+"1".( "0"x($opt{digits} - 1)); - -# get the list of queue files, spool directory excluded -my $re = qr/^\Q$opt{basename}\E\.\d{$opt{digits}}$/; -opendir(DIR, $opt{spool}) or die "can’t open spool: $!"; -my @qf = grep { /$re/ && -f "$opt{spool}/$_" } readdir(DIR); -closedir DIR; - -# ensure order and continuity -@qf = sort @qf; -my ($head) = ($qf[0] =~ /(\d+)$/); -my ($tail) = ($qf[-1] =~ /(\d+)$/); -$head += 0; -$tail += 0; -if ($tail-$head+1 != @qf || $tail > $iMaxFiles) { - die "broken queue: missing file(s) or wrong tail\n"; -} - -# collect some counters about the queue, assuming all are unprocessed entries. -my $sizeOnDisk = 0; -my $iQueueSize = 0; -chdir($opt{spool}) or die "can't chdir to spool: $!"; -print STDERR "traversing ". @qf ." files, please wait...\n"; -for (@qf) { - open FH, "<", $_ or die "can't read queue file $_\n"; - $sizeOnDisk += (stat FH)[7]; - while () { - $iQueueSize++ if /^new("qqueue",1); -$qqueue->property("iQueueSize", "INT", $iQueueSize); -$qqueue->property("tVars.disk.sizeOnDisk", "INT64", $sizeOnDisk); -$qqueue->property("tVars.disk.bytesRead", "INT64", 0); - -# runtime/stream.h: strmType_t -my $STREAMTYPE_FILE_CIRCULAR = 1; -# runtime/stream.h: strmMode_t -my $STREAMMODE_READ = 1; -my $STREAMMODE_WRITE_APPEND = 4; - -# runtime/stream.c: strmSerialize() -# write to end -my $strm_Write = Rsyslog::Obj->new("strm",1); -$strm_Write->property( "iCurrFNum", "INT", $tail); -$strm_Write->property( "pszFName", "PSZ", $opt{basename}); -$strm_Write->property( "iMaxFiles", "INT", $iMaxFiles); -$strm_Write->property( "bDeleteOnClose", "INT", 0); -$strm_Write->property( "sType", "INT", $STREAMTYPE_FILE_CIRCULAR); -$strm_Write->property("tOperationsMode", "INT", $STREAMMODE_WRITE_APPEND); -$strm_Write->property( "tOpenMode", "INT", 0600); -$strm_Write->property( "iCurrOffs","INT64", $iCurrOffs_Write); -# read from head -my $strm_ReadDel = Rsyslog::Obj->new("strm",1); -$strm_ReadDel->property( "iCurrFNum", "INT", $head); -$strm_ReadDel->property( "pszFName", "PSZ", $opt{basename}); -$strm_ReadDel->property( "iMaxFiles", "INT", $iMaxFiles); -$strm_ReadDel->property( "bDeleteOnClose", "INT", 1); -$strm_ReadDel->property( "sType", "INT", $STREAMTYPE_FILE_CIRCULAR); -$strm_ReadDel->property("tOperationsMode", "INT", $STREAMMODE_READ); -$strm_ReadDel->property( "tOpenMode", "INT", 0600); -$strm_ReadDel->property( "iCurrOffs","INT64", 0); - -# .qi -print $qqueue->serialize(); -print $strm_Write->serialize(); -print $strm_ReadDel->serialize(); - -exit; -#----------------------------------------------------------------------------- - -package Rsyslog::Serializable; -# runtime/obj.c -sub COOKIE_OBJLINE { '<' } -sub COOKIE_PROPLINE { '+' } -sub COOKIE_ENDLINE { '>' } -sub COOKIE_BLANKLINE { '.' } -# VARTYPE(short_ptype) -sub VARTYPE { - my ($t) = @_; - # runtime/obj-types.h: propType_t - my $ptype = "PROPTYPE_".$t; - # runtime/var.h: varType_t - my %vm = ( - VARTYPE_NONE => 0, - VARTYPE_STR => 1, - VARTYPE_NUMBER => 2, - VARTYPE_SYSLOGTIME => 3, - ); - # runtime/obj.c: SerializeProp() - my %p2v = ( - #PROPTYPE_NONE => "", - PROPTYPE_PSZ => "VARTYPE_STR", - PROPTYPE_SHORT => "VARTYPE_NUMBER", - PROPTYPE_INT => "VARTYPE_NUMBER", - PROPTYPE_LONG => "VARTYPE_NUMBER", - PROPTYPE_INT64 => "VARTYPE_NUMBER", - PROPTYPE_CSTR => "VARTYPE_STR", - #PROPTYPE_SYSLOGTIME => "VARTYPE_SYSLOGTIME", - ); - my $vtype = $p2v{$ptype}; - unless ($vtype) { - die "property type $t is not supported!\n"; - } - return $vm{$vtype}; -} -sub serialize { - my $self = shift; - # runtime/obj.c: objSerializeHeader() - my $x = COOKIE_OBJLINE(); - $x .= join(":", $self->type(), $self->cver(), $self->id(), $self->version()); - $x .= ":\n"; - for ( values %{$self->{props}} ) { - # runtime/obj.c: SerializeProp() - $x .= COOKIE_PROPLINE(); - $x .= join(":", - $_->{name}, - VARTYPE($_->{type}), - length($_->{value}), - $_->{value}); - $x .= ":\n"; - } - # runtime/obj.c: EndSerialize() - $x .= COOKIE_ENDLINE() . "End\n"; - $x .= COOKIE_BLANKLINE() . "\n"; -} -# constructor: new(id,version) -sub new { - my ($class, $id, $version) = @_; - $class = ref $class if ref $class; - bless { - id => $id, - version => $version, - props => {}, - }, $class; -} -sub id { - my $self = shift; - if (@_) { - my $x = $self->{id}; - $self->{id} = shift; - return $x; - } - return $self->{id}; -} -sub version { - my $self = shift; - if (@_) { - my $x = $self->{version}; - $self->{version} = shift; - return $x; - } - return $self->{version}; -} -# property(name, type, value) -sub property { - my $self = shift; - my $name = shift; - if (@_) { - my $x = $self->{props}{$name}; - $self->{props}{$name}{name} = $name; - $self->{props}{$name}{type} = shift; - $self->{props}{$name}{value} = shift; - return $x; - } - return $self->{props}{$name}; -} -1; -package Rsyslog::OPB; -use base qw(Rsyslog::Serializable); -sub type { 'OPB' } -sub cver { 1 } -sub new { shift->SUPER::new(@_) } -1; -package Rsyslog::Obj; -use base qw(Rsyslog::Serializable); -sub type { 'Obj' } -sub cver { 1 } -sub new { shift->SUPER::new(@_) } -1; +#!/usr/bin/perl -w +# recover rsyslog disk queue index (.qi) from queue files (.nnnnnnnn). +# +# See: +# runtime/queue.c: qqueuePersist() +# runtime/queue.c: qqueueTryLoadPersistedInfo() +# +# kaiwang.chen@gmail.com 2012-03-14 +# +use strict; +use Getopt::Long; + +my %opt = (); +GetOptions(\%opt,"spool|w=s","basename|f=s","digits|d=i","help!"); +if ($opt{help}) { + print "Usage: +\t$0 -w WorkDirectory -f QueueFileName -d 8 > QueueFileName.qi +"; + exit; +} + +# runtime/queue.c: qConstructDisk() +my $iMaxFiles = 10000000; # 0+"1".( "0"x($opt{digits} - 1)); + +# get the list of queue files, spool directory excluded +my $re = qr/^\Q$opt{basename}\E\.\d{$opt{digits}}$/; +opendir(DIR, $opt{spool}) or die "can’t open spool: $!"; +my @qf = grep { /$re/ && -f "$opt{spool}/$_" } readdir(DIR); +closedir DIR; + +# ensure order and continuity +@qf = sort @qf; +my ($head) = ($qf[0] =~ /(\d+)$/); +my ($tail) = ($qf[-1] =~ /(\d+)$/); +$head += 0; +$tail += 0; +if ($tail-$head+1 != @qf || $tail > $iMaxFiles) { + die "broken queue: missing file(s) or wrong tail\n"; +} + +# collect some counters about the queue, assuming all are unprocessed entries. +my $sizeOnDisk = 0; +my $iQueueSize = 0; +chdir($opt{spool}) or die "can't chdir to spool: $!"; +print STDERR "traversing ". @qf ." files, please wait...\n"; +for (@qf) { + open FH, "<", $_ or die "can't read queue file $_\n"; + $sizeOnDisk += (stat FH)[7]; + while () { + $iQueueSize++ if /^new("qqueue",1); +$qqueue->property("iQueueSize", "INT", $iQueueSize); +$qqueue->property("tVars.disk.sizeOnDisk", "INT64", $sizeOnDisk); +$qqueue->property("tVars.disk.bytesRead", "INT64", 0); + +# runtime/stream.h: strmType_t +my $STREAMTYPE_FILE_CIRCULAR = 1; +# runtime/stream.h: strmMode_t +my $STREAMMODE_READ = 1; +my $STREAMMODE_WRITE_APPEND = 4; + +# runtime/stream.c: strmSerialize() +# write to end +my $strm_Write = Rsyslog::Obj->new("strm",1); +$strm_Write->property( "iCurrFNum", "INT", $tail); +$strm_Write->property( "pszFName", "PSZ", $opt{basename}); +$strm_Write->property( "iMaxFiles", "INT", $iMaxFiles); +$strm_Write->property( "bDeleteOnClose", "INT", 0); +$strm_Write->property( "sType", "INT", $STREAMTYPE_FILE_CIRCULAR); +$strm_Write->property("tOperationsMode", "INT", $STREAMMODE_WRITE_APPEND); +$strm_Write->property( "tOpenMode", "INT", 0600); +$strm_Write->property( "iCurrOffs","INT64", $iCurrOffs_Write); +# read from head +my $strm_ReadDel = Rsyslog::Obj->new("strm",1); +$strm_ReadDel->property( "iCurrFNum", "INT", $head); +$strm_ReadDel->property( "pszFName", "PSZ", $opt{basename}); +$strm_ReadDel->property( "iMaxFiles", "INT", $iMaxFiles); +$strm_ReadDel->property( "bDeleteOnClose", "INT", 1); +$strm_ReadDel->property( "sType", "INT", $STREAMTYPE_FILE_CIRCULAR); +$strm_ReadDel->property("tOperationsMode", "INT", $STREAMMODE_READ); +$strm_ReadDel->property( "tOpenMode", "INT", 0600); +$strm_ReadDel->property( "iCurrOffs","INT64", 0); + +# .qi +print $qqueue->serialize(); +print $strm_Write->serialize(); +print $strm_ReadDel->serialize(); + +exit; +#----------------------------------------------------------------------------- + +package Rsyslog::Serializable; +# runtime/obj.c +sub COOKIE_OBJLINE { '<' } +sub COOKIE_PROPLINE { '+' } +sub COOKIE_ENDLINE { '>' } +sub COOKIE_BLANKLINE { '.' } +# VARTYPE(short_ptype) +sub VARTYPE { + my ($t) = @_; + # runtime/obj-types.h: propType_t + my $ptype = "PROPTYPE_".$t; + # runtime/var.h: varType_t + my %vm = ( + VARTYPE_NONE => 0, + VARTYPE_STR => 1, + VARTYPE_NUMBER => 2, + VARTYPE_SYSLOGTIME => 3, + ); + # runtime/obj.c: SerializeProp() + my %p2v = ( + #PROPTYPE_NONE => "", + PROPTYPE_PSZ => "VARTYPE_STR", + PROPTYPE_SHORT => "VARTYPE_NUMBER", + PROPTYPE_INT => "VARTYPE_NUMBER", + PROPTYPE_LONG => "VARTYPE_NUMBER", + PROPTYPE_INT64 => "VARTYPE_NUMBER", + PROPTYPE_CSTR => "VARTYPE_STR", + #PROPTYPE_SYSLOGTIME => "VARTYPE_SYSLOGTIME", + ); + my $vtype = $p2v{$ptype}; + unless ($vtype) { + die "property type $t is not supported!\n"; + } + return $vm{$vtype}; +} +sub serialize { + my $self = shift; + # runtime/obj.c: objSerializeHeader() + my $x = COOKIE_OBJLINE(); + $x .= join(":", $self->type(), $self->cver(), $self->id(), $self->version()); + $x .= ":\n"; + for ( values %{$self->{props}} ) { + # runtime/obj.c: SerializeProp() + $x .= COOKIE_PROPLINE(); + $x .= join(":", + $_->{name}, + VARTYPE($_->{type}), + length($_->{value}), + $_->{value}); + $x .= ":\n"; + } + # runtime/obj.c: EndSerialize() + $x .= COOKIE_ENDLINE() . "End\n"; + $x .= COOKIE_BLANKLINE() . "\n"; +} +# constructor: new(id,version) +sub new { + my ($class, $id, $version) = @_; + $class = ref $class if ref $class; + bless { + id => $id, + version => $version, + props => {}, + }, $class; +} +sub id { + my $self = shift; + if (@_) { + my $x = $self->{id}; + $self->{id} = shift; + return $x; + } + return $self->{id}; +} +sub version { + my $self = shift; + if (@_) { + my $x = $self->{version}; + $self->{version} = shift; + return $x; + } + return $self->{version}; +} +# property(name, type, value) +sub property { + my $self = shift; + my $name = shift; + if (@_) { + my $x = $self->{props}{$name}; + $self->{props}{$name}{name} = $name; + $self->{props}{$name}{type} = shift; + $self->{props}{$name}{value} = shift; + return $x; + } + return $self->{props}{$name}; +} +1; +package Rsyslog::OPB; +use base qw(Rsyslog::Serializable); +sub type { 'OPB' } +sub cver { 1 } +sub new { shift->SUPER::new(@_) } +1; +package Rsyslog::Obj; +use base qw(Rsyslog::Serializable); +sub type { 'Obj' } +sub cver { 1 } +sub new { shift->SUPER::new(@_) } +1; diff --git a/tools/rsgtutil.c b/tools/rsgtutil.c index 567dcf4..62c33ed 100644 --- a/tools/rsgtutil.c +++ b/tools/rsgtutil.c @@ -259,8 +259,17 @@ verify(char *name) if(bs != NULL) rsgt_objfree(0x0902, bs); if((r = rsgt_getBlockParams(sigfp, 1, &bs, &bHasRecHashes, - &bHasIntermedHashes)) != 0) + &bHasIntermedHashes)) != 0) { + if(ectx.blkNum == 0) { + fprintf(stderr, "EOF before finding any signature block - " + "is the file still open and being written to?\n"); + } else { + if(verbose) + fprintf(stderr, "EOF after signature block %lld\n", + ectx.blkNum); + } goto done; + } rsgt_vrfyBlkInit(gf, bs, bHasRecHashes, bHasIntermedHashes); ectx.recNum = 0; ++ectx.blkNum; diff --git a/tools/syslogd.c b/tools/syslogd.c index a8a733d..f14e8d5 100644 --- a/tools/syslogd.c +++ b/tools/syslogd.c @@ -436,15 +436,31 @@ submitMsgWithDfltRatelimiter(msg_t *pMsg) * to log a message orginating from the syslogd itself. */ rsRetVal -logmsgInternal(int iErr, int pri, uchar *msg, int flags) +logmsgInternal(int iErr, int pri, const uchar *const msg, int flags) { uchar pszTag[33]; + size_t lenMsg; + unsigned i; + char *bufModMsg = NULL; /* buffer for modified message, should we need to modify */ msg_t *pMsg; DEFiRet; + /* we first do a path the remove control characters that may have accidently + * introduced (program error!). This costs performance, but we do not expect + * to be called very frequently in any case ;) -- rgerhards, 2013-12-19. + */ + lenMsg = ustrlen(msg); + for(i = 0 ; i < lenMsg ; ++i) { + if(msg[i] < 0x20 || msg[i] == 0x7f) { + if(bufModMsg == NULL) { + CHKmalloc(bufModMsg = strdup((char*) msg)); + } + bufModMsg[i] = ' '; + } + } CHKiRet(msgConstruct(&pMsg)); MsgSetInputName(pMsg, pInternalInputName); - MsgSetRawMsgWOSize(pMsg, (char*)msg); + MsgSetRawMsg(pMsg, (bufModMsg == NULL) ? (char*)msg : bufModMsg, lenMsg); MsgSetHOSTNAME(pMsg, glbl.GetLocalHostName(), ustrlen(glbl.GetLocalHostName())); MsgSetRcvFrom(pMsg, glbl.GetLocalHostNameProp()); MsgSetRcvFromIP(pMsg, glbl.GetLocalHostIP()); @@ -474,7 +490,7 @@ logmsgInternal(int iErr, int pri, uchar *msg, int flags) */ if(((Debug == DEBUG_FULL || !doFork) && ourConf->globals.bErrMsgToStderr) || iConfigVerify) { if(LOG_PRI(pri) == LOG_ERR) - fprintf(stderr, "rsyslogd: %s\n", msg); + fprintf(stderr, "rsyslogd: %s\n", (bufModMsg == NULL) ? (char*)msg : bufModMsg); } if(bHaveMainQueue == 0) { /* not yet in queued mode */ @@ -484,9 +500,9 @@ logmsgInternal(int iErr, int pri, uchar *msg, int flags) * message to the queue engine. */ ratelimitAddMsg(internalMsg_ratelimiter, NULL, pMsg); - //submitMsgWithDfltRatelimiter(pMsg); } finalize_it: + free(bufModMsg); RETiRet; } -- cgit v1.2.3