1 /* @(#) $Id: ./src/remoted/remoted.c, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
12 * License details at the LICENSE file included with OSSEC or
13 * online at: http://www.ossec.net/en/licensing.html
19 * Listen to remote packets and forward them to the analysis
25 #include "os_net/os_net.h"
31 /** void HandleRemote(int position, int uid) v0.2 2005/11/09
32 * Handle remote connections
36 void HandleRemote(int position, int uid)
38 /* If syslog connection and allowips is not defined, exit */
39 if(logr.conn[position] == SYSLOG_CONN)
41 if(logr.allowips == NULL)
43 ErrorExit(NO_SYSLOG, ARGV0);
49 tmp_ips = logr.allowips;
52 verbose("%s: Remote syslog allowed from: '%s'",
53 ARGV0, (*tmp_ips)->ip);
61 if(logr.proto[position] == TCP_PROTO)
64 OS_Bindporttcp(logr.port[position],logr.lip[position], logr.ipv6[position])) < 0)
66 ErrorExit(BIND_ERROR, ARGV0, logr.port[position]);
71 /* Using UDP. Fast, unreliable.. perfect */
73 OS_Bindportudp(logr.port[position], logr.lip[position], logr.ipv6[position])) < 0)
75 ErrorExit(BIND_ERROR, ARGV0, logr.port[position]);
81 /* Revoking the privileges */
82 if(Privsep_SetUser(uid) < 0)
84 ErrorExit(SETUID_ERROR,ARGV0, REMUSER);
89 if(CreatePID(ARGV0, getpid()) < 0)
91 ErrorExit(PID_ERROR,ARGV0);
95 /* Start up message */
96 verbose(STARTUP_MSG, ARGV0, (int)getpid());
99 /* If Secure connection, deal with it */
100 if(logr.conn[position] == SECURE_CONN)
105 else if(logr.proto[position] == TCP_PROTO)
110 /* If not, deal with syslog */