X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fconf.c;h=65e51a96b92a880fb2c7fdcf4c55f31230957603;hp=2ff503612cd31575116941c9267ffc7f742408f1;hb=3a811ef5639346f6151a01f4b1bd0f85e0bb5c80;hpb=8b7b23cf8f36e51bbe89a1a586bd238357183e83 diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 2ff50361..65e51a96 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -14,7 +14,7 @@ #include "portab.h" -static char UNUSED id[] = "$Id: conf.c,v 1.43 2002/12/13 17:32:33 alex Exp $"; +static char UNUSED id[] = "$Id: conf.c,v 1.47 2002/12/18 02:53:36 alex Exp $"; #include "imp.h" #include @@ -27,6 +27,7 @@ static char UNUSED id[] = "$Id: conf.c,v 1.43 2002/12/13 17:32:33 alex Exp $"; #include #include #include +#include #ifdef HAVE_CTYPE_H # include @@ -49,7 +50,7 @@ LOCAL BOOLEAN Use_Log = TRUE; LOCAL VOID Set_Defaults PARAMS(( VOID )); LOCAL VOID Read_Config PARAMS(( VOID )); -LOCAL VOID Validate_Config PARAMS(( VOID )); +LOCAL VOID Validate_Config PARAMS(( BOOLEAN TestOnly )); LOCAL VOID Handle_GLOBAL PARAMS(( INT Line, CHAR *Var, CHAR *Arg )); LOCAL VOID Handle_OPERATOR PARAMS(( INT Line, CHAR *Var, CHAR *Arg )); @@ -64,7 +65,7 @@ Conf_Init( VOID ) { Set_Defaults( ); Read_Config( ); - Validate_Config( ); + Validate_Config( FALSE ); } /* Config_Init */ @@ -81,6 +82,7 @@ Conf_Test( VOID ) Set_Defaults( ); Read_Config( ); + Validate_Config( TRUE ); /* If stdin is a valid tty wait for a key: */ if( isatty( fileno( stdout ))) @@ -119,8 +121,6 @@ Conf_Test( VOID ) else printf( " MaxConnections = -1\n" ); if( Conf_MaxJoins > 0 ) printf( " MaxJoins = %d\n", Conf_MaxJoins ); else printf( " MaxJoins = -1\n" ); - if( Conf_MaxPChannels > 0 ) printf( " MaxPChannels = %d\n", Conf_MaxPChannels ); - else printf( " MaxPChannels = -1\n" ); puts( "" ); for( i = 0; i < Conf_Oper_Count; i++ ) @@ -197,7 +197,6 @@ Set_Defaults( VOID ) Conf_MaxConnections = -1; Conf_MaxJoins = 10; - Conf_MaxPChannels = -1; } /* Set_Defaults */ @@ -494,16 +493,6 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg ) Conf_MaxJoins = atoi( Arg ); return; } - if( strcasecmp( Var, "MaxPChannels" ) == 0 ) - { - /* Maximum number of persistent channels in the network. Values <= 0 are equal to "no limit". */ -#ifdef HAVE_ISDIGIT - if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxPChannels\" is not a number!", NGIRCd_ConfFile, Line ); - else -#endif - Conf_MaxPChannels = atoi( Arg ); - return; - } Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var ); } /* Handle_GLOBAL */ @@ -639,7 +628,7 @@ Handle_CHANNEL( INT Line, CHAR *Var, CHAR *Arg ) LOCAL VOID -Validate_Config( VOID ) +Validate_Config( BOOLEAN Configtest ) { /* Validate configuration settings. */ @@ -647,8 +636,11 @@ Validate_Config( VOID ) { /* No server name configured! */ Config_Error( LOG_ALERT, "No server name configured in \"%s\" ('ServerName')!", NGIRCd_ConfFile ); - Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE ); - exit( 1 ); + if( ! Configtest ) + { + Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE ); + exit( 1 ); + } } #ifdef STRICT_RFC @@ -656,16 +648,28 @@ Validate_Config( VOID ) { /* No administrative contact configured! */ Config_Error( LOG_ALERT, "No administrator email address configured in \"%s\" ('AdminEMail')!", NGIRCd_ConfFile ); - Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE ); - exit( 1 ); + if( ! Configtest ) + { + Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE ); + exit( 1 ); + } } #endif if( ! Conf_ServerAdmin1[0] && ! Conf_ServerAdmin2[0] && ! Conf_ServerAdminMail[0] ) { /* No administrative information configured! */ - Log( LOG_WARNING, "No administrative information configured but required by RFC!" ); + Config_Error( LOG_WARNING, "No administrative information configured but required by RFC!" ); } +#ifdef FD_SETSIZE + if(( Conf_MaxConnections > (LONG)FD_SETSIZE ) || ( Conf_MaxConnections < 1 )) + { + Conf_MaxConnections = (LONG)FD_SETSIZE; + Config_Error( LOG_ERR, "Setting MaxConnections to %ld, select() can't handle more file descriptors!", Conf_MaxConnections ); + } +#else + Config_Error( LOG_WARN, "Don't know how many file descriptors select() can handle on this system, don't set MaxConnections too high!" ); +#endif } /* Validate_Config */