projects
/
ossec-hids.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git]
/
src
/
remoted
/
remoted.c
diff --git
a/src/remoted/remoted.c
b/src/remoted/remoted.c
old mode 100755
(executable)
new mode 100644
(file)
index
0800f1c
..
dd6cd1a
--- a/
src/remoted/remoted.c
+++ b/
src/remoted/remoted.c
@@
-1,6
+1,3
@@
-/* @(#) $Id: ./src/remoted/remoted.c, 2011/09/08 dcid Exp $
- */
-
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
@@
-8,47
+5,33
@@
* and/or modify it under the terms of the GNU General Public
* License (version 2) as published by the FSF - Free Software
* Foundation.
* and/or modify it under the terms of the GNU General Public
* License (version 2) as published by the FSF - Free Software
* Foundation.
- *
- * License details at the LICENSE file included with OSSEC or
- * online at: http://www.ossec.net/en/licensing.html
*/
*/
-
-
-/* remote daemon.
- * Listen to remote packets and forward them to the analysis
- * system
+/* remote daemon
+ * Listen to remote packets and forward them to the analysis system
*/
*/
-
#include "shared.h"
#include "os_net/os_net.h"
#include "shared.h"
#include "os_net/os_net.h"
-
#include "remoted.h"
#include "remoted.h"
+/* Global variables */
+keystore keys;
+remoted logr;
-/** void HandleRemote(int position, int uid) v0.2 2005/11/09
- * Handle remote connections
- * v0.2, 2005/11/09
- * v0.1, 2004/7/30
- */
+/* Handle remote connections */
void HandleRemote(int position, int uid)
{
/* If syslog connection and allowips is not defined, exit */
void HandleRemote(int position, int uid)
{
/* If syslog connection and allowips is not defined, exit */
- if(logr.conn[position] == SYSLOG_CONN)
- {
- if(logr.allowips == NULL)
- {
+ if (logr.conn[position] == SYSLOG_CONN) {
+ if (logr.allowips == NULL) {
ErrorExit(NO_SYSLOG, ARGV0);
ErrorExit(NO_SYSLOG, ARGV0);
- }
- else
- {
+ } else {
os_ip **tmp_ips;
tmp_ips = logr.allowips;
os_ip **tmp_ips;
tmp_ips = logr.allowips;
- while(*tmp_ips)
- {
+ while (*tmp_ips) {
verbose("%s: Remote syslog allowed from: '%s'",
ARGV0, (*tmp_ips)->ip);
tmp_ips++;
verbose("%s: Remote syslog allowed from: '%s'",
ARGV0, (*tmp_ips)->ip);
tmp_ips++;
@@
-56,65
+39,48
@@
void HandleRemote(int position, int uid)
}
}
}
}
-
/* Bind TCP */
/* Bind TCP */
- if(logr.proto[position] == TCP_PROTO)
- {
- if((logr.sock =
- OS_Bindporttcp(logr.port[position],logr.lip[position], logr.ipv6[position])) < 0)
- {
+ if (logr.proto[position] == IPPROTO_TCP) {
+ logr.sock = 0;
+ logr.netinfo = OS_Bindporttcp(logr.port[position], logr.lip[position]);
+ if (logr.netinfo->status < 0) {
ErrorExit(BIND_ERROR, ARGV0, logr.port[position]);
}
ErrorExit(BIND_ERROR, ARGV0, logr.port[position]);
}
- }
- else
- {
- /* Using UDP. Fast, unreliable.. perfect */
- if((logr.sock =
- OS_Bindportudp(logr.port[position], logr.lip[position], logr.ipv6[position])) < 0)
- {
+ } else {
+ /* Using UDP. Fast, unreliable... perfect */
+ logr.sock = 0;
+ logr.netinfo = OS_Bindportudp(logr.port[position], logr.lip[position]);
+ if (logr.netinfo->status < 0) {
ErrorExit(BIND_ERROR, ARGV0, logr.port[position]);
}
}
ErrorExit(BIND_ERROR, ARGV0, logr.port[position]);
}
}
-
-
- /* Revoking the privileges */
- if(Privsep_SetUser(uid) < 0)
- {
- ErrorExit(SETUID_ERROR,ARGV0, REMUSER);
+ /* Revoke privileges */
+ if (Privsep_SetUser(uid) < 0) {
+ ErrorExit(SETUID_ERROR, ARGV0, REMUSER, errno, strerror(errno));
}
}
-
- /* Creating PID */
- if(CreatePID(ARGV0, getpid()) < 0)
- {
- ErrorExit(PID_ERROR,ARGV0);
+ /* Create PID */
+ if (CreatePID(ARGV0, getpid()) < 0) {
+ ErrorExit(PID_ERROR, ARGV0);
}
}
-
/* Start up message */
verbose(STARTUP_MSG, ARGV0, (int)getpid());
/* Start up message */
verbose(STARTUP_MSG, ARGV0, (int)getpid());
-
- /* If Secure connection, deal with it */
- if(logr.conn[position] == SECURE_CONN)
- {
+ /* If secure connection, deal with it */
+ if (logr.conn[position] == SECURE_CONN) {
HandleSecure();
}
HandleSecure();
}
- else if(logr.proto[position] == TCP_PROTO)
+ else if (logr.proto[position] == IPPROTO_TCP)
{
HandleSyslogTCP();
}
/* If not, deal with syslog */
{
HandleSyslogTCP();
}
/* If not, deal with syslog */
- else
- {
+ else {
HandleSyslog();
}
HandleSyslog();
}
-
- return;
}
}
-
-/* EOF */