projects
/
ossec-hids.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
novi upstream verzije 2.8.3
[ossec-hids.git]
/
src
/
remoted
/
syslogtcp.c
diff --git
a/src/remoted/syslogtcp.c
b/src/remoted/syslogtcp.c
index
46b2ead
..
d4944c0
100755
(executable)
--- a/
src/remoted/syslogtcp.c
+++ b/
src/remoted/syslogtcp.c
@@
-1,4
+1,5
@@
-/* @(#) $Id$ */
+/* @(#) $Id: ./src/remoted/syslogtcp.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
@@
-18,7
+19,7
@@
-/* OS_IPNotAllowed, v0.1, 2005/02/11
+/* OS_IPNotAllowed, v0.1, 2005/02/11
* Checks if an IP is not allowed.
*/
static int OS_IPNotAllowed(char *srcip)
* Checks if an IP is not allowed.
*/
static int OS_IPNotAllowed(char *srcip)
@@
-50,14
+51,19
@@
static void HandleClient(int client_socket, char *srcip)
{
int sb_size = OS_MAXSTR;
int r_sz = 0;
{
int sb_size = OS_MAXSTR;
int r_sz = 0;
-
+
char buffer[OS_MAXSTR +2];
char storage_buffer[OS_MAXSTR +2];
char tmp_buffer[OS_MAXSTR +2];
char *buffer_pt = NULL;
char buffer[OS_MAXSTR +2];
char storage_buffer[OS_MAXSTR +2];
char tmp_buffer[OS_MAXSTR +2];
char *buffer_pt = NULL;
-
+ /* Create PID file */
+ if(CreatePID(ARGV0, getpid()) < 0)
+ {
+ ErrorExit(PID_ERROR,ARGV0);
+ }
+
/* Initializing some variables */
memset(buffer, '\0', OS_MAXSTR +2);
memset(storage_buffer, '\0', OS_MAXSTR +2);
/* Initializing some variables */
memset(buffer, '\0', OS_MAXSTR +2);
memset(storage_buffer, '\0', OS_MAXSTR +2);
@@
-70,6
+76,7
@@
static void HandleClient(int client_socket, char *srcip)
if((r_sz = OS_RecvTCPBuffer(client_socket, buffer, OS_MAXSTR -2)) < 0)
{
close(client_socket);
if((r_sz = OS_RecvTCPBuffer(client_socket, buffer, OS_MAXSTR -2)) < 0)
{
close(client_socket);
+ DeletePID(ARGV0);
return;
}
return;
}
@@
-85,12
+92,12
@@
static void HandleClient(int client_socket, char *srcip)
storage_buffer[0] = '\0';
continue;
}
storage_buffer[0] = '\0';
continue;
}
-
+
strncat(storage_buffer, buffer, sb_size);
sb_size -= r_sz;
strncat(storage_buffer, buffer, sb_size);
sb_size -= r_sz;
- continue;
+ continue;
}
}
-
+
/* Seeing if we received more then just one message */
if(*(buffer_pt +1) != '\0')
{
/* Seeing if we received more then just one message */
if(*(buffer_pt +1) != '\0')
{
@@
-111,14
+118,14
@@
static void HandleClient(int client_socket, char *srcip)
}
strncat(storage_buffer, buffer, sb_size);
}
strncat(storage_buffer, buffer, sb_size);
-
+
/* Removing carriage returns too */
buffer_pt = strchr(storage_buffer, '\r');
if(buffer_pt)
*buffer_pt = '\0';
/* Removing carriage returns too */
buffer_pt = strchr(storage_buffer, '\r');
if(buffer_pt)
*buffer_pt = '\0';
-
+
/* Removing syslog header */
if(storage_buffer[0] == '<')
{
/* Removing syslog header */
if(storage_buffer[0] == '<')
{
@@
-142,7
+149,7
@@
static void HandleClient(int client_socket, char *srcip)
if(SendMSG(logr.m_queue, buffer_pt, srcip,SYSLOG_MQ) < 0)
{
merror(QUEUE_ERROR,ARGV0,DEFAULTQUEUE, strerror(errno));
if(SendMSG(logr.m_queue, buffer_pt, srcip,SYSLOG_MQ) < 0)
{
merror(QUEUE_ERROR,ARGV0,DEFAULTQUEUE, strerror(errno));
- if((logr.m_queue = StartMQ(DEFAULTQUEUE,READ)) < 0)
+ if((logr.m_queue = StartMQ(DEFAULTQUEUE,WRITE)) < 0)
{
ErrorExit(QUEUE_FATAL,ARGV0,DEFAULTQUEUE);
}
{
ErrorExit(QUEUE_FATAL,ARGV0,DEFAULTQUEUE);
}
@@
-172,13
+179,13
@@
void HandleSyslogTCP()
int client_socket = 0;
int st_errors = 0;
int childcount = 0;
int client_socket = 0;
int st_errors = 0;
int childcount = 0;
-
+
char srcip[IPSIZE +1];
/* Initializing some variables */
memset(srcip, '\0', IPSIZE + 1);
char srcip[IPSIZE +1];
/* Initializing some variables */
memset(srcip, '\0', IPSIZE + 1);
-
+
/* Connecting to the message queue
* Exit if it fails.
*/
/* Connecting to the message queue
* Exit if it fails.
*/
@@
-186,7
+193,7
@@
void HandleSyslogTCP()
{
ErrorExit(QUEUE_FATAL,ARGV0, DEFAULTQUEUE);
}
{
ErrorExit(QUEUE_FATAL,ARGV0, DEFAULTQUEUE);
}
-
+
/* Infinit loop in here */
while(1)
/* Infinit loop in here */
while(1)
@@
-222,7
+229,7
@@
void HandleSyslogTCP()
}
}
- /* Forking to deal with new client */
+ /* Forking to deal with new client */
if(fork() == 0)
{
HandleClient(client_socket, srcip);
if(fork() == 0)
{
HandleClient(client_socket, srcip);