From c4986ca6de5da6b5bdf4263032552f19bc3e1249 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 23 Jul 2007 10:17:55 +0000 Subject: added DropTrailingLFOnReception config directive --- ChangeLog | 1 + syslogd.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index e2958999..b2c993da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ Version 1.17.2 (rgerhards), 2007-07-2? hooks, but not yet any active code - worked further on modularization - added $ModLoad MySQL (dummy) config directive +- added DropTrailingLFOnReception config directive --------------------------------------------------------------------------- Version 1.17.1 (rgerhards), 2007-07-20 - fixed a bug that caused make install to install rsyslogd and rklogd under diff --git a/syslogd.c b/syslogd.c index f2b78245..acb0d5e4 100644 --- a/syslogd.c +++ b/syslogd.c @@ -531,6 +531,7 @@ static struct code FacNames[] = { }; /* global variables for config file state */ +static int bDropTrailingLF = 1; /* drop trailing LF's on reception? */ int Debug; /* debug flag - read-only after startup */ static int bFailOnChown; /* fail if chown fails? */ static uid_t fileUID; /* UID to be used for newly created files */ @@ -1932,6 +1933,16 @@ void printchopped(char *hname, char *msg, int len, int fd, int bParseHost) dprintf("Message length: %d, File descriptor: %d.\n", len, fd); + /* we first check if we need to drop trailing LFs, which often make + * their way into syslog messages unintentionally. In order to remain + * compatible to recent IETF developments, we allow the user to + * turn on/off this handling. rgerhards, 2007-07-23 + */ + if(bDropTrailingLF && *(msg + len - 1) == '\n') { + *(msg + len - 1) = '\0'; + len--; + } + iMsg = 0; /* initialize receiving buffer index */ pMsg = tmpline; /* set receiving buffer pointer */ pData = msg; /* set source buffer pointer */ @@ -4060,6 +4071,8 @@ void cfsysline(uchar *p) doBinaryOptionLine(&p, &bDebugPrintTemplateList); } else if(!strcasecmp((char*) szCmd, "failonchownfailure")) { doBinaryOptionLine(&p, &bFailOnChown); + } else if(!strcasecmp((char*) szCmd, "droptrailinglfonreception")) { + doBinaryOptionLine(&p, &bDropTrailingLF); } else if(!strcasecmp((char*) szCmd, "resetconfigvariables")) { resetConfigVariables(); } else if(!strcasecmp((char*) szCmd, "modload")) { -- cgit v1.2.3