From 37dc5101883283ff2628e899449384154bcb8fcd Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 18 Feb 2008 08:03:10 +0000 Subject: - changed interface "printchopped()" so that it looks more like a generic message submission interface. Part of the ongoing modularization effort. - bugfix: invalid kernel log format -- see bug http://bugzilla.adiscon.com/show_bug.cgi?id=1 --- plugins/imklog/imklog.c | 3 +++ plugins/imtemplate/imtemplate.c | 9 +++------ plugins/imudp/imudp.c | 2 +- plugins/imuxsock/imuxsock.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/imklog/imklog.c b/plugins/imklog/imklog.c index 5bc0f068..6e6f486d 100644 --- a/plugins/imklog/imklog.c +++ b/plugins/imklog/imklog.c @@ -130,6 +130,8 @@ static rsRetVal writeSyslogV(int iPRI, const char *szFmt, va_list va) /* here we must create our message object and supply it to the message queue */ + CHKiRet(parseAndSubmitMessage(LocalHostName, msgBuf, strlen(msgBuf), MSG_DONT_PARSE_HOSTNAME)); +#if 0 CHKiRet(msgConstruct(&pMsg)); MsgSetUxTradMsg(pMsg, msgBuf); MsgSetRawMsg(pMsg, msgBuf); @@ -143,6 +145,7 @@ static rsRetVal writeSyslogV(int iPRI, const char *szFmt, va_list va) /* provide message to the queue engine */ logmsg(pMsg, INTERNAL_MSG); +#endif finalize_it: RETiRet; diff --git a/plugins/imtemplate/imtemplate.c b/plugins/imtemplate/imtemplate.c index 867f2778..e1e29ba6 100644 --- a/plugins/imtemplate/imtemplate.c +++ b/plugins/imtemplate/imtemplate.c @@ -255,10 +255,10 @@ CODESTARTrunInput * in syslogd.c (sorry, folks...). * * If you received a full syslog message that must be decoded by a message - * parser, printchopped() is the way to go. It's not just a funny name + * parser, parseAndSubmitMessage() is the way to go. It's not just a funny name * but also a quite some legacy. Consequently, its interface is, ummm, not * well designed. - * printchopped((char*)fromHost, (char*) pRcvBuf, lenRcvd, fd, bParseHost); + * parseAndSubmitMessage((char*)fromHost, (char*) pRcvBuf, lenRcvd, bParseHost); * fromHost * is the host that we received the message from (a string) * pRcvBuf @@ -268,14 +268,11 @@ CODESTARTrunInput * NOT a standard C-string. Most importantly it is NOT expected to be * \0-terminated. Thus the lenght is vitally imporant (if it is wrong, * rsyslogd will probably segfault). - * fd - * is the file descriptor that the message was received from. It is - * purely used for displaying purposes. If you don't have a file - * descriptor, simply provide the value 0. * bParseHost * is a boolean (0-no, 1-yes). It tells the parser whether or not * a hostname should be parsed from the message. This is important * for sources that are known not to provide a hostname. + * Use define MSG_PARSE_HOSTNAME and MSG_DONT_PARSE_HOSTNAME * * Another, more elaborate, way is to create the message object ourselves and * pass it to the rule engine. That way is more appropriate if the message diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c index fa9db53a..fa979039 100644 --- a/plugins/imudp/imudp.c +++ b/plugins/imudp/imudp.c @@ -190,7 +190,7 @@ CODESTARTrunInput */ if(isAllowedSender(pAllowedSenders_UDP, (struct sockaddr *)&frominet, (char*)fromHostFQDN)) { - printchopped((char*)fromHost, (char*) pRcvBuf, l, udpLstnSocks[i+1], 1); + parseAndSubmitMessage((char*)fromHost, (char*) pRcvBuf, l, MSG_PARSE_HOSTNAME); } else { dbgprintf("%s is not an allowed sender\n", (char*)fromHostFQDN); if(option_DisallowWarning) { diff --git a/plugins/imuxsock/imuxsock.c b/plugins/imuxsock/imuxsock.c index 54bbe039..819057df 100644 --- a/plugins/imuxsock/imuxsock.c +++ b/plugins/imuxsock/imuxsock.c @@ -167,7 +167,7 @@ static rsRetVal readSocket(int fd, int bParseHost) iRcvd = recv(fd, line, MAXLINE - 1, 0); dbgprintf("Message from UNIX socket: #%d\n", fd); if (iRcvd > 0) { - printchopped(LocalHostName, line, iRcvd, fd, bParseHost); + parseAndSubmitMessage(LocalHostName, line, iRcvd, bParseHost); } else if (iRcvd < 0 && errno != EINTR) { char errStr[1024]; rs_strerror_r(errno, errStr, sizeof(errStr)); -- cgit