summaryrefslogtreecommitdiffstats
path: root/syslogd.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-12-21 16:15:20 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-12-21 16:15:20 +0000
commitfe6b6de3035b6bcea07f302ec0ef2895ac6f2285 (patch)
treea436b76a6f02453bb88c5ba6c3c5c1e2ffc56a6e /syslogd.c
parent17a2d137b6134e02301eda68e6c1bfe94901e2d5 (diff)
downloadrsyslog-fe6b6de3035b6bcea07f302ec0ef2895ac6f2285.tar.gz
rsyslog-fe6b6de3035b6bcea07f302ec0ef2895ac6f2285.tar.xz
rsyslog-fe6b6de3035b6bcea07f302ec0ef2895ac6f2285.zip
- created an initial version of imudp.c. The majority of UDP reception code
is now in that module and it is dynamically loadable. HOWEVER, that doesn't mean it is a proper module. There are still many, many dependencies on global variables, cross-module calls and such. However, havin the code base separated allows me to carry out some other cleanup before I return to create a really clean implementation of these modules. So it is kind of a stage work. Just don't mistake it with "the real thing"...
Diffstat (limited to 'syslogd.c')
-rw-r--r--syslogd.c72
1 files changed, 2 insertions, 70 deletions
diff --git a/syslogd.c b/syslogd.c
index a6fc28bb..317a5d6c 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -193,9 +193,7 @@
#include <arpa/inet.h>
#include <resolv.h>
#include "pidfile.h"
-
#include <assert.h>
-
#include <pthread.h>
#if HAVE_PATHS_H
@@ -464,7 +462,7 @@ static int MarkInterval = 20 * 60; /* interval between marks in seconds - read-o
int family = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both), set via cmdline */
int send_to_all = 0; /* send message to all IPv4/IPv6 addresses */
static int NoFork = 0; /* don't fork - don't run in daemon mode - read-only after startup */
-static int AcceptRemote = 0;/* receive messages that come via UDP - read-only after startup */
+int AcceptRemote = 0;/* receive messages that come via UDP - read-only after startup */
int ACLAddHostnameOnFail = 0; /* add hostname to acl when DNS resolving has failed */
int ACLDontResolve = 0; /* add hostname to acl instead of resolving it to IP(s) */
int DisableDNS = 0; /* don't look up IP addresses of remote messages */
@@ -590,7 +588,7 @@ static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __a
*/
#ifdef SYSLOG_INET
/* All of the five below are read-only after startup */
-static struct AllowedSenders *pAllowedSenders_UDP = NULL; /* the roots of the allowed sender */
+struct AllowedSenders *pAllowedSenders_UDP = NULL; /* the roots of the allowed sender */
struct AllowedSenders *pAllowedSenders_TCP = NULL; /* lists. If NULL, all senders are ok! */
static struct AllowedSenders *pLastAllowedSenders_UDP = NULL; /* and now the pointers to the last */
static struct AllowedSenders *pLastAllowedSenders_TCP = NULL; /* element in the respective list */
@@ -5378,14 +5376,6 @@ static rsRetVal processSelectAfter(int maxfds, int nfds, fd_set *pReadfds)
{
DEFiRet;
int i;
- char line[MAXLINE +1];
-#ifdef SYSLOG_INET
- struct sockaddr_storage frominet;
- socklen_t socklen;
- uchar fromHost[NI_MAXHOST];
- uchar fromHostFQDN[NI_MAXHOST];
- ssize_t l;
-#endif /* #ifdef SYSLOG_INET */
/* the following macro is used to decrement the number of to-be-probed
* fds and abort this function when we are done with all.
@@ -5406,49 +5396,6 @@ static rsRetVal processSelectAfter(int maxfds, int nfds, fd_set *pReadfds)
dbgprintf("%d ", i);
dbgprintf(("\n"));
}
-
-#ifdef SYSLOG_INET
- if (finet != NULL && AcceptRemote) {
- for (i = 0; i < *finet; i++) {
- if (FD_ISSET(finet[i+1], pReadfds)) {
- socklen = sizeof(frominet);
- memset(line, 0xff, sizeof(line)); // TODO: I think we need this for debug only - remove after bug hunt
- l = recvfrom(finet[i+1], line, MAXLINE - 1, 0,
- (struct sockaddr *)&frominet, &socklen);
- if (l > 0) {
- if(cvthname(&frominet, fromHost, fromHostFQDN) == RS_RET_OK) {
- dbgprintf("Message from inetd socket: #%d, host: %s\n",
- finet[i+1], fromHost);
- /* Here we check if a host is permitted to send us
- * syslog messages. If it isn't, we do not further
- * process the message but log a warning (if we are
- * configured to do this).
- * rgerhards, 2005-09-26
- */
- if(isAllowedSender(pAllowedSenders_UDP,
- (struct sockaddr *)&frominet, (char*)fromHostFQDN)) {
- printchopped((char*)fromHost, line, l, finet[i+1], 1);
- } else {
- dbgprintf("%s is not an allowed sender\n", (char*)fromHostFQDN);
- if(option_DisallowWarning) {
- logerrorSz("UDP message from disallowed sender %s discarded",
- (char*)fromHost);
- }
- }
- }
- } else if (l < 0 && errno != EINTR && errno != EAGAIN) {
- char errStr[1024];
- strerror_r(errno, errStr, sizeof(errStr));
- dbgprintf("INET socket error: %d = %s.\n", errno, errStr);
- logerror("recvfrom inet");
- /* should be harmless */
- sleep(1);
- }
- FDPROCESSED();
- }
- }
- }
-#endif
finalize_it:
return iRet;
}
@@ -5472,21 +5419,6 @@ static void mainloop(void)
/* first check if we have any internal messages queued and spit them out */
processImInternal();
-#ifdef SYSLOG_INET
- /* Add the UDP listen sockets to the list of read descriptors.
- */
- if(finet != NULL && AcceptRemote) {
- for (i = 0; i < *finet; i++) {
- if (finet[i+1] != -1) {
- if(Debug)
- debugListenInfo(finet[i+1], "UDP");
- FD_SET(finet[i+1], &readfds);
- if(finet[i+1]>maxfds) maxfds=finet[i+1];
- }
- }
- }
-#endif
-
if ( debugging_on ) {
dbgprintf("----------------------------------------\n");
dbgprintf("Calling select, active file descriptors (max %d): ", maxfds);