projects
/
ossec-hids.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- fortify/harden the compile
[ossec-hids.git]
/
src
/
logcollector
/
read_command.c
diff --git
a/src/logcollector/read_command.c
b/src/logcollector/read_command.c
index
9c1f7ca
..
f1de982
100755
(executable)
--- a/
src/logcollector/read_command.c
+++ b/
src/logcollector/read_command.c
@@
-1,11
+1,12
@@
-/* @(#) $Id: read_command.c,v 1.3 2009/11/05 19:55:34 dcid Exp $ */
+/* @(#) $Id: ./src/logcollector/read_command.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
- * License (version 3) as published by the FSF - Free Software
+ * License (version 2) as published by the FSF - Free Software
* Foundation
*/
* Foundation
*/
@@
-43,25
+44,42
@@
void *read_command(int pos, int *rc, int drop_it)
}
}
- snprintf(str, 256, "ossec: output: '%s': ", logff[pos].command);
+ snprintf(str, 256, "ossec: output: '%s': ",
+ (NULL != logff[pos].alias)
+ ? logff[pos].alias
+ : logff[pos].command);
cmd_size = strlen(str);
while(fgets(str + cmd_size, OS_MAXSTR - OS_LOG_HEADER - 256, cmd_output) != NULL)
{
/* Getting the last occurence of \n */
cmd_size = strlen(str);
while(fgets(str + cmd_size, OS_MAXSTR - OS_LOG_HEADER - 256, cmd_output) != NULL)
{
/* Getting the last occurence of \n */
- if ((p = strrchr(str, '\n')) != NULL)
+ if ((p = strrchr(str, '\n')) != NULL)
{
*p = '\0';
}
{
*p = '\0';
}
-
+
+ /* Removing empty lines. */
+ #ifdef WIN32
+ if(str[0] == '\r' && str[1] == '\0')
+ {
+ continue;
+ }
+ #endif
+ if(str[0] == '\0')
+ {
+ continue;
+ }
+
+
debug2("%s: DEBUG: Reading command message: '%s'", ARGV0, str);
debug2("%s: DEBUG: Reading command message: '%s'", ARGV0, str);
-
+
/* Sending message to queue */
if(drop_it == 0)
{
/* Sending message to queue */
if(drop_it == 0)
{
- if(SendMSG(logr_queue,str,logff[pos].command,
+ if(SendMSG(logr_queue,str,
+ (NULL != logff[pos].alias) ? logff[pos].alias : logff[pos].command,
LOCALFILE_MQ) < 0)
{
merror(QUEUE_SEND, ARGV0);
LOCALFILE_MQ) < 0)
{
merror(QUEUE_SEND, ARGV0);
@@
-77,7
+95,7
@@
void *read_command(int pos, int *rc, int drop_it)
pclose(cmd_output);
pclose(cmd_output);
- return(NULL);
+ return(NULL);
}
/* EOF */
}
/* EOF */