X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fconf.c;h=2a259eb43440d1c453190392ef890be49dfa9349;hp=b0c7fb4bf0c50a79b2da6ed158c8161894636c62;hb=aa7db2c0e9e1112591cbdb3d346342d34ca21a6a;hpb=56b7e67307c1be110eaa4e84681bca03df21bd69 diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index b0c7fb4b..2a259eb4 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors. + * Copyright (c)2001-2012 Alexander Barton (alex@barton.de) and Contributors. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -58,7 +58,7 @@ static int New_Server_Idx; static char Conf_MotdFile[FNAME_LEN]; static void Set_Defaults PARAMS(( bool InitServers )); -static bool Read_Config PARAMS(( bool ngircd_starting )); +static bool Read_Config PARAMS(( bool TestOnly, bool IsStarting )); static bool Validate_Config PARAMS(( bool TestOnly, bool Rehash )); static void Handle_GLOBAL PARAMS(( int Line, char *Var, char *Arg )); @@ -206,7 +206,7 @@ ports_parse(array *a, int Line, char *Arg) GLOBAL void Conf_Init( void ) { - Read_Config( true ); + Read_Config(false, true); Validate_Config(false, false); } @@ -218,7 +218,7 @@ Conf_Init( void ) GLOBAL bool Conf_Rehash( void ) { - if (!Read_Config(false)) + if (!Read_Config(false, false)) return false; Validate_Config(false, true); @@ -299,7 +299,7 @@ Conf_Test( void ) Use_Log = false; - if (! Read_Config(true)) + if (!Read_Config(true, true)) return 1; config_valid = Validate_Config(true, false); @@ -358,6 +358,7 @@ Conf_Test( void ) printf(" AllowRemoteOper = %s\n", yesno_to_str(Conf_AllowRemoteOper)); printf(" ChrootDir = %s\n", Conf_Chroot); printf(" CloakHost = %s\n", Conf_CloakHost); + printf(" CloakModeHost = %s\n", Conf_CloakModeHost); printf(" CloakUserToNick = %s\n", yesno_to_str(Conf_CloakUserToNick)); #ifdef WANT_IPV6 printf(" ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6)); @@ -492,6 +493,14 @@ Conf_SetServer( int ConfServer, CONN_ID Idx ) assert( ConfServer > NONE ); assert( Idx > NONE ); + if (Conf_Server[ConfServer].conn_id > NONE && + Conf_Server[ConfServer].conn_id != Idx) { + Log(LOG_ALERT, + "Trying to update connection index for already registered server \"%s\": %d/%d - ignored.", + Conf_Server[ConfServer].name, + Conf_Server[ConfServer].conn_id, Idx); + return; + } Conf_Server[ConfServer].conn_id = Idx; } @@ -676,6 +685,7 @@ Set_Defaults(bool InitServers) #endif strlcpy(Conf_Chroot, CHROOT_DIR, sizeof(Conf_Chroot)); strcpy(Conf_CloakHost, ""); + strcpy(Conf_CloakModeHost, ""); Conf_CloakUserToNick = false; Conf_ConnectIPv4 = true; #ifdef WANT_IPV6 @@ -778,7 +788,7 @@ Read_Motd(const char *filename) * successfully; false otherwise. */ static bool -Read_Config( bool ngircd_starting ) +Read_Config(bool TestOnly, bool IsStarting) { char section[LINE_LEN], str[LINE_LEN], *var, *arg, *ptr; const UINT16 defaultport = 6667; @@ -792,16 +802,19 @@ Read_Config( bool ngircd_starting ) /* No configuration file found! */ Config_Error( LOG_ALERT, "Can't read configuration \"%s\": %s", NGIRCd_ConfFile, strerror( errno )); - if (!ngircd_starting) + if (!IsStarting) return false; Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME ); exit( 1 ); } opers_free(); - Set_Defaults( ngircd_starting ); + Set_Defaults(IsStarting); - Config_Error( LOG_INFO, "Reading configuration from \"%s\" ...", NGIRCd_ConfFile ); + if (TestOnly) + Config_Error(LOG_INFO, + "Reading configuration from \"%s\" ...", + NGIRCd_ConfFile ); /* Clean up server configuration structure: mark all already * configured servers as "once" so that they are deleted @@ -854,10 +867,13 @@ Read_Config( bool ngircd_starting ) /* Is this the beginning of a new section? */ if(( str[0] == '[' ) && ( str[strlen( str ) - 1] == ']' )) { strlcpy( section, str, sizeof( section )); - if (strcasecmp(section, "[GLOBAL]") == 0 || - strcasecmp(section, "[LIMITS]") == 0 || - strcasecmp(section, "[OPTIONS]") == 0 || - strcasecmp(section, "[SSL]") == 0) + if (strcasecmp(section, "[GLOBAL]") == 0 + || strcasecmp(section, "[LIMITS]") == 0 + || strcasecmp(section, "[OPTIONS]") == 0 +#ifdef SSL_SUPPORT + || strcasecmp(section, "[SSL]") == 0 +#endif + ) continue; if( strcasecmp( section, "[SERVER]" ) == 0 ) { @@ -1308,7 +1324,9 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) else { Conf_GID = (unsigned int)atoi(Arg); if (!Conf_GID && strcmp(Arg, "0")) - Config_Error_NaN(Line, Var); + Config_Error(LOG_WARNING, + "%s, line %d: Value of \"%s\" is not a valid group name or ID!", + NGIRCd_ConfFile, Line, Var); } return; } @@ -1319,7 +1337,9 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) else { Conf_UID = (unsigned int)atoi(Arg); if (!Conf_UID && strcmp(Arg, "0")) - Config_Error_NaN(Line, Var); + Config_Error(LOG_WARNING, + "%s, line %d: Value of \"%s\" is not a valid user name or ID!", + NGIRCd_ConfFile, Line, Var); } return; } @@ -1459,6 +1479,12 @@ Handle_OPTIONS(int Line, char *Var, char *Arg) Config_Error_TooLong(Line, Var); return; } + if (strcasecmp(Var, "CloakModeHost") == 0) { + len = strlcpy(Conf_CloakModeHost, Arg, sizeof(Conf_CloakModeHost)); + if (len >= sizeof(Conf_CloakModeHost)) + Config_Error_TooLong(Line, Var); + return; + } if (strcasecmp(Var, "CloakUserToNick") == 0) { Conf_CloakUserToNick = Check_ArgIsTrue(Arg); return;