summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--omfwd.c1
-rw-r--r--plugins/imudp/imudp.c31
-rw-r--r--syslogd.c28
-rw-r--r--syslogd.h2
4 files changed, 21 insertions, 41 deletions
diff --git a/omfwd.c b/omfwd.c
index e24bc969..4c9b75f8 100644
--- a/omfwd.c
+++ b/omfwd.c
@@ -1,3 +1,4 @@
+// TODO: we currently leak the send socket!!! -- rgerhards, 2007-12-26
/* omfwd.c
* This is the implementation of the build-in forwarding output module.
*
diff --git a/plugins/imudp/imudp.c b/plugins/imudp/imudp.c
index 367258ca..5aebc9b5 100644
--- a/plugins/imudp/imudp.c
+++ b/plugins/imudp/imudp.c
@@ -44,6 +44,8 @@ TERM_SYNC_TYPE(eTermSync_NONE)
/* Module static data */
DEF_IMOD_STATIC_DATA
+static int *udpLstnSocks = NULL; /* Internet datagram sockets, first element is nbr of elements
+ * read-only after init(), but beware of restart! */
typedef struct _instanceData {
} instanceData;
@@ -81,13 +83,13 @@ CODESTARTrunInput
/* 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(udpLstnSocks != NULL && AcceptRemote) {
+ for (i = 0; i < *udpLstnSocks; i++) {
+ if (udpLstnSocks[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];
+ debugListenInfo(udpLstnSocks[i+1], "UDP");
+ FD_SET(udpLstnSocks[i+1], &readfds);
+ if(udpLstnSocks[i+1]>maxfds) maxfds=udpLstnSocks[i+1];
}
}
}
@@ -102,16 +104,16 @@ CODESTARTrunInput
/* wait for io to become ready */
nfds = select(maxfds+1, (fd_set *) &readfds, NULL, NULL, NULL);
- if (finet != NULL && AcceptRemote) {
- for (i = 0; nfds && i < *finet; i++) {
- if (FD_ISSET(finet[i+1], &readfds)) {
+ if (udpLstnSocks != NULL && AcceptRemote) {
+ for (i = 0; nfds && i < *udpLstnSocks; i++) {
+ if (FD_ISSET(udpLstnSocks[i+1], &readfds)) {
socklen = sizeof(frominet);
- l = recvfrom(finet[i+1], line, MAXLINE - 1, 0,
+ l = recvfrom(udpLstnSocks[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);
+ udpLstnSocks[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
@@ -120,7 +122,7 @@ CODESTARTrunInput
*/
if(isAllowedSender(pAllowedSenders_UDP,
(struct sockaddr *)&frominet, (char*)fromHostFQDN)) {
- printchopped((char*)fromHost, line, l, finet[i+1], 1);
+ printchopped((char*)fromHost, line, l, udpLstnSocks[i+1], 1);
} else {
dbgprintf("%s is not an allowed sender\n", (char*)fromHostFQDN);
if(option_DisallowWarning) {
@@ -150,7 +152,9 @@ ENDrunInput
/* initialize and return if will run or not */
BEGINwillRun
CODESTARTwillRun
- /* first apply some config settings */
+ if((udpLstnSocks = create_udp_socket(NULL, (uchar*)LogPort, 1)) != NULL)
+ dbgprintf("Opened %d syslog UDP port(s).\n", *udpLstnSocks);
+
ENDwillRun
@@ -162,6 +166,7 @@ dbgprintf("call clearAllowedSenders(0x%lx)\n", (unsigned long) pAllowedSenders_U
clearAllowedSenders (pAllowedSenders_UDP);
pAllowedSenders_UDP = NULL;
}
+ closeUDPListenSockets(udpLstnSocks);
ENDafterRun
diff --git a/syslogd.c b/syslogd.c
index e51841ae..e1179720 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -422,9 +422,7 @@ static int logEveryMsg = 0;/* no repeat message processing - read-only after st
static unsigned int Forwarding = 0;
char LocalHostName[MAXHOSTNAMELEN+1];/* our hostname - read-only after startup */
char *LocalDomain; /* our local domain name - read-only after startup */
-int *finet = NULL; /* Internet datagram sockets, first element is nbr of elements
- * read-only after init(), but beware of restart! */
-static char *LogPort = "514"; /* port number for INET connections */
+char *LogPort = "514"; /* port number for INET connections */
static int MarkInterval = 20 * 60; /* interval between marks in seconds - read-only after startup */
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 */
@@ -2772,12 +2770,6 @@ die(int sig)
queueDelete(pMsgQueue); /* delete fifo here! */
pMsgQueue = NULL;
- /* now clean up the listener part */
-#ifdef SYSLOG_INET
- /* Close the UDP inet socket. */
- closeUDPListenSockets(finet);
-#endif
-
/* rger 2005-02-22
* now clean up the in-memory structures. OK, the OS
* would also take care of that, but if we do it
@@ -3571,24 +3563,6 @@ init(void)
pDfltProgNameCmp = NULL;
}
-#ifdef SYSLOG_INET
- /* I have moved initializing UDP sockets before the TCP sockets. This ensures
- * they are as soon ready for reception as possible. Of course, it is only a
- * very small window of exposure, but it doesn't hurt to limit the message
- * loss risk to as low as possible - especially if it costs nothing...
- * rgerhards, 2007-06-28
- */
- if(Forwarding || AcceptRemote) {
- if (finet == NULL) {
- if((finet = create_udp_socket(NULL, (uchar*)LogPort, 1)) != NULL)
- dbgprintf("Opened %d syslog UDP port(s).\n", *finet);
- }
- } else {
- /* this case can happen during HUP processing. */
- closeUDPListenSockets(finet);
- }
-#endif
-
/* create message queue */
pMsgQueue = queueInit();
if(pMsgQueue == NULL) {
diff --git a/syslogd.h b/syslogd.h
index df3629c7..80fd8243 100644
--- a/syslogd.h
+++ b/syslogd.h
@@ -77,7 +77,7 @@ extern int glblHadMemShortage; /* indicates if we had memory shortage some time
extern char LocalHostName[];
extern int family;
extern int NoHops;
-extern int *finet;
+extern char *LogPort; /* port number for INET connections */
extern int send_to_all;
extern int option_DisallowWarning;
extern int Debug;