X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fldapd%2Fmain.c;h=354214609139d198513aca0adfdd1252c0d287c4;hb=edd464ee8f98f566b94851d4d8463ae4e1a407eb;hp=0d7933d202bf53fc1600d0a0ec5bd49c8f2ee0f7;hpb=f3db3e0a8f1ddcb5af7d0de35c827048ebfa562d;p=openldap diff --git a/servers/ldapd/main.c b/servers/ldapd/main.c index 0d7933d202..3542146091 100644 --- a/servers/ldapd/main.c +++ b/servers/ldapd/main.c @@ -40,6 +40,7 @@ #include "../../libraries/liblber/lber-int.h" /* get struct sockbuf */ #include "ldap.h" #include "common.h" +#include "lutil.h" /* Get lutil_detach() */ #ifdef HAVE_TCPD #include @@ -48,12 +49,11 @@ int allow_severity = LOG_INFO; int deny_severity = LOG_NOTICE; #endif /* TCP_WRAPPERS */ -void log_and_exit(); -static set_socket(); -static do_queries(); -static RETSIGTYPE wait4child(); +static int set_socket( int port, int udp ); +static void do_queries( int clientsock, int udp ); +static RETSIGTYPE wait4child( int sig ); #ifdef LDAP_CONNECTIONLESS -static udp_init(); +static int udp_init( int port, int createsocket ); #endif #ifdef LDAP_DEBUG @@ -82,10 +82,8 @@ char *kerberos_keyfile; int dtblsize; int RunFromInetd = 0; -extern char Versionstr[]; - -static usage( name ) -char *name; +static void +usage( char *name ) { fprintf( stderr, "usage: %s [-d debuglvl] [-p port] [-l] [-c dsa] [-r referraltimeout]", name ); #ifdef LDAP_CONNECTIONLESS @@ -100,9 +98,8 @@ char *name; fprintf( stderr, "\n" ); } -main (argc, argv) -int argc; -char **argv; +int +main( int argc, char **argv ) { int tcps, ns; #ifdef LDAP_CONNECTIONLESS @@ -117,12 +114,9 @@ char **argv; int len; int dsapargc; char **dsapargv; - RETSIGTYPE wait4child(); #ifdef LDAP_PROCTITLE char title[80]; #endif - extern char *optarg; - extern int optind; #ifdef VMS /* Pick up socket from inetd-type server on VMS */ @@ -273,8 +267,8 @@ char **argv; lutil_detach( 0, 1 ); # endif #endif - (void) SIGNAL( SIGCHLD, (void *) wait4child ); - (void) SIGNAL( SIGINT, (void *) log_and_exit ); + (void) SIGNAL( SIGCHLD, wait4child ); + (void) SIGNAL( SIGINT, log_and_exit ); } /* @@ -306,7 +300,7 @@ char **argv; (void) get_syntaxes(); if (RunFromInetd) { len = sizeof( socktype ); - getsockopt( ns, SOL_SOCKET, SO_TYPE, &socktype, &len ); + getsockopt( ns, SOL_SOCKET, SO_TYPE, (char *)&socktype, &len ); if ( socktype == SOCK_DGRAM ) { #ifdef LDAP_CONNECTIONLESS Debug( LDAP_DEBUG_ARGS, @@ -448,7 +442,7 @@ char **argv; hp->h_name ); #endif gettimeofday( &conn_start_tv, (struct timezone *) NULL ); - (void) SIGNAL( SIGPIPE, (void *) log_and_exit ); + (void) SIGNAL( SIGPIPE, log_and_exit ); do_queries( ns, 0 ); /* NOT REACHED */ @@ -464,7 +458,7 @@ char **argv; setproctitle( title ); #endif gettimeofday( &conn_start_tv, (struct timezone *) NULL ); - (void) SIGNAL( SIGPIPE, (void *) log_and_exit ); + (void) SIGNAL( SIGPIPE, log_and_exit ); do_queries( ns, 0 ); break; @@ -489,14 +483,14 @@ char **argv; /* NOT REACHED */ } -static +static void do_queries( int clientsock, int udp /* is this a UDP (CLDAP) request? */ ) { fd_set readfds; - int rc, i; + int rc; struct timeval timeout; Sockbuf sb; #ifdef LDAP_CONNECTIONLESS @@ -537,7 +531,6 @@ do_queries( timeout.tv_usec = 0; for ( ;; ) { struct conn *dsaconn; - extern struct conn *conns; FD_ZERO( &readfds ); FD_SET( clientsock, &readfds ); @@ -545,6 +538,7 @@ do_queries( #ifdef LDAP_DEBUG if ( ldap_debug & LDAP_DEBUG_CONNS ) { + int i; Debug( LDAP_DEBUG_CONNS, "FDLIST:", 0, 0, 0 ); for ( i = 0; i < dtblsize; i++ ) { if ( FD_ISSET( i, &readfds ) ) { @@ -603,7 +597,8 @@ do_queries( /* NOT REACHED */ } -static set_socket( +static int +set_socket( int port, int udp /* UDP port? */ ) @@ -648,7 +643,8 @@ static set_socket( return( s ); } -static RETSIGTYPE wait4child() +static RETSIGTYPE +wait4child( int sig ) { #ifndef HAVE_WAITPID WAITSTATUSTYPE status; @@ -664,11 +660,11 @@ static RETSIGTYPE wait4child() ; /* NULL */ #endif - (void) SIGNAL( SIGCHLD, (void *) wait4child ); + (void) SIGNAL( SIGCHLD, wait4child ); } -void +RETSIGTYPE log_and_exit( int exitcode ) { struct timeval tv; @@ -696,9 +692,6 @@ udp_init( { int s, bound; char *matched; - extern char *dsa_address; - extern struct PSAPaddr *psap_cpy(); - extern struct conn *conns; if ( createsocket ) s = set_socket( port, 1 );