Added support for TCP Wrappers.

This commit is contained in:
Alexander Barton 2003-03-07 14:35:52 +00:00
parent 93146b5718
commit 439c945d56
2 changed files with 35 additions and 7 deletions

View File

@ -16,7 +16,7 @@
#include "portab.h" #include "portab.h"
static char UNUSED id[] = "$Id: conn.c,v 1.117 2003/02/23 12:04:05 alex Exp $"; static char UNUSED id[] = "$Id: conn.c,v 1.118 2003/03/07 14:35:52 alex Exp $";
#include "imp.h" #include "imp.h"
#include <assert.h> #include <assert.h>
@ -40,7 +40,11 @@ static char UNUSED id[] = "$Id: conn.c,v 1.117 2003/02/23 12:04:05 alex Exp $";
#endif #endif
#ifdef HAVE_STDINT_H #ifdef HAVE_STDINT_H
#include <stdint.h> /* u.a. fuer Mac OS X */ #include <stdint.h> /* e.g. for Mac OS X */
#endif
#ifdef USE_TCPWRAP
#include <tcpd.h> /* for TCP Wrappers */
#endif #endif
#include "defines.h" #include "defines.h"
@ -87,6 +91,11 @@ LOCAL fd_set My_Listeners;
LOCAL fd_set My_Sockets; LOCAL fd_set My_Sockets;
LOCAL fd_set My_Connects; LOCAL fd_set My_Connects;
#ifdef USE_TCPWRAP
INT allow_severity = LOG_INFO;
INT deny_severity = LOG_ERR;
#endif
GLOBAL VOID GLOBAL VOID
Conn_Init( VOID ) Conn_Init( VOID )
@ -836,6 +845,9 @@ New_Connection( INT Sock )
/* Neue Client-Verbindung von Listen-Socket annehmen und /* Neue Client-Verbindung von Listen-Socket annehmen und
* CLIENT-Struktur anlegen. */ * CLIENT-Struktur anlegen. */
#ifdef USE_TCPWRAP
struct request_info req;
#endif
struct sockaddr_in new_addr; struct sockaddr_in new_addr;
INT new_sock, new_sock_len; INT new_sock, new_sock_len;
RES_STAT *s; RES_STAT *s;
@ -855,6 +867,18 @@ New_Connection( INT Sock )
return; return;
} }
#ifdef USE_TCPWRAP
/* Validate socket using TCP Wrappers */
request_init( &req, RQ_DAEMON, PACKAGE, RQ_FILE, new_sock, RQ_CLIENT_SIN, &new_addr, NULL );
if( ! hosts_access( &req ))
{
/* Access denied! */
Log( deny_severity, "Refused connection from %s (by TCP Wrappers)!", inet_ntoa( new_addr.sin_addr ));
close( new_sock );
return;
}
#endif
/* Socket initialisieren */ /* Socket initialisieren */
Init_Socket( new_sock ); Init_Socket( new_sock );

View File

@ -14,7 +14,7 @@
#include "portab.h" #include "portab.h"
static char UNUSED id[] = "$Id: ngircd.c,v 1.72 2003/02/23 12:04:05 alex Exp $"; static char UNUSED id[] = "$Id: ngircd.c,v 1.73 2003/03/07 14:35:52 alex Exp $";
#include "imp.h" #include "imp.h"
#include <assert.h> #include <assert.h>
@ -369,6 +369,14 @@ NGIRCd_VersionAddition( VOID )
if( txt[0] ) strcat( txt, "+" ); if( txt[0] ) strcat( txt, "+" );
strcat( txt, "ZLIB" ); strcat( txt, "ZLIB" );
#endif #endif
#ifdef USE_TCPWRAP
if( txt[0] ) strcat( txt, "+" );
strcat( txt, "TCPWRAP" );
#endif
#ifdef RENDEZVOUS
if( txt[0] ) strcat( txt, "+" );
strcat( txt, "RENDEZVOUS" );
#endif
#ifdef DEBUG #ifdef DEBUG
if( txt[0] ) strcat( txt, "+" ); if( txt[0] ) strcat( txt, "+" );
strcat( txt, "DEBUG" ); strcat( txt, "DEBUG" );
@ -385,10 +393,6 @@ NGIRCd_VersionAddition( VOID )
if( txt[0] ) strcat( txt, "+" ); if( txt[0] ) strcat( txt, "+" );
strcat( txt, "IRCPLUS" ); strcat( txt, "IRCPLUS" );
#endif #endif
#ifdef RENDEZVOUS
if( txt[0] ) strcat( txt, "+" );
strcat( txt, "RENDEZVOUS" );
#endif
if( txt[0] ) strlcat( txt, "-", sizeof( txt )); if( txt[0] ) strlcat( txt, "-", sizeof( txt ));
strlcat( txt, TARGET_CPU, sizeof( txt )); strlcat( txt, TARGET_CPU, sizeof( txt ));