X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fconf.c;h=7799da19f37be714e763e7d8030b6a178df54afa;hb=7a6f99a607176e9172877fe3de68c3cf8f700166;hp=54506a0754fe810f9e77506259e436e3b057e9f2;hpb=ec474a4bd2c3b97e2df0532e4810be18c4fbcc94;p=ngircd-alex.git diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 54506a07..7799da19 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -9,7 +9,7 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: conf.c,v 1.32 2002/10/04 11:21:46 alex Exp $ + * $Id: conf.c,v 1.40 2002/11/25 01:01:59 alex Exp $ * * conf.h: Konfiguration des ngircd */ @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include "ngircd.h" #include "conn.h" @@ -67,12 +70,13 @@ Conf_Test( VOID ) { /* Konfiguration einlesen, ueberpruefen und ausgeben. */ + struct passwd *pwd; + struct group *grp; INT i; Use_Log = FALSE; Set_Defaults( ); - printf( "Using \"%s\" as configuration file ...\n", NGIRCd_ConfFile ); Read_Config( ); /* Wenn stdin ein ein TTY ist: auf Taste warten */ @@ -91,19 +95,25 @@ Conf_Test( VOID ) printf( " AdminInfo2 = %s\n", Conf_ServerAdmin2 ); printf( " AdminEMail = %s\n", Conf_ServerAdminMail ); printf( " MotdFile = %s\n", Conf_MotdFile ); - printf( " ListenPorts = " ); + printf( " Ports = " ); for( i = 0; i < Conf_ListenPorts_Count; i++ ) { if( i != 0 ) printf( ", " ); printf( "%u", Conf_ListenPorts[i] ); } puts( "" ); - printf( " ServerUID = %ld\n", (INT32)Conf_UID ); - printf( " ServerGID = %ld\n", (INT32)Conf_GID ); + pwd = getpwuid( Conf_UID ); + if( pwd ) printf( " ServerUID = %s\n", pwd->pw_name ); + else printf( " ServerUID = %ld\n", (LONG)Conf_UID ); + grp = getgrgid( Conf_GID ); + if( grp ) printf( " ServerGID = %s\n", grp->gr_name ); + else printf( " ServerGID = %ld\n", (LONG)Conf_GID ); printf( " PingTimeout = %d\n", Conf_PingTimeout ); printf( " PongTimeout = %d\n", Conf_PongTimeout ); printf( " ConnectRetry = %d\n", Conf_ConnectRetry ); printf( " OperCanUseMode = %s\n", Conf_OperCanMode == TRUE ? "yes" : "no" ); + if( Conf_MaxConnections > 0 ) printf( " MaxConnections = %ld\n", Conf_MaxConnections ); + else printf( " MaxConnections = -1\n" ); puts( "" ); for( i = 0; i < Conf_Oper_Count; i++ ) @@ -127,7 +137,8 @@ Conf_Test( VOID ) printf( " Name = %s\n", Conf_Server[i].name ); printf( " Host = %s\n", Conf_Server[i].host ); printf( " Port = %d\n", Conf_Server[i].port ); - printf( " Password = %s\n", Conf_Server[i].pwd ); + printf( " MyPassword = %s\n", Conf_Server[i].pwd_in ); + printf( " PeerPassword = %s\n", Conf_Server[i].pwd_out ); printf( " Group = %d\n", Conf_Server[i].group ); puts( "" ); } @@ -177,6 +188,8 @@ Set_Defaults( VOID ) Conf_Channel_Count = 0; Conf_OperCanMode = FALSE; + + Conf_MaxConnections = 0; } /* Set_Defaults */ @@ -198,6 +211,8 @@ Read_Config( VOID ) exit( 1 ); } + Config_Error( LOG_INFO, "Reading configuration from \"%s\" ...", NGIRCd_ConfFile ); + line = 0; strcpy( section, "" ); while( TRUE ) @@ -235,7 +250,8 @@ Read_Config( VOID ) strcpy( Conf_Server[Conf_Server_Count].host, "" ); strcpy( Conf_Server[Conf_Server_Count].ip, "" ); strcpy( Conf_Server[Conf_Server_Count].name, "" ); - strcpy( Conf_Server[Conf_Server_Count].pwd, "" ); + strcpy( Conf_Server[Conf_Server_Count].pwd_in, "" ); + strcpy( Conf_Server[Conf_Server_Count].pwd_out, "" ); Conf_Server[Conf_Server_Count].port = 0; Conf_Server[Conf_Server_Count].group = -1; Conf_Server[Conf_Server_Count].lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY; @@ -294,8 +310,10 @@ Read_Config( VOID ) LOCAL VOID Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg ) { + struct passwd *pwd; + struct group *grp; CHAR *ptr; - INT32 port; + LONG port; assert( Line > 0 ); assert( Var != NULL ); @@ -372,13 +390,17 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg ) if( strcasecmp( Var, "ServerUID" ) == 0 ) { /* UID, mit der der Daemon laufen soll */ - Conf_UID = (UINT)atoi( Arg ); + pwd = getpwnam( Arg ); + if( pwd ) Conf_UID = pwd->pw_uid; + else Conf_UID = (UINT)atoi( Arg ); return; } if( strcasecmp( Var, "ServerGID" ) == 0 ) { /* GID, mit der der Daemon laufen soll */ - Conf_GID = (UINT)atoi( Arg ); + grp = getgrnam( Arg ); + if( grp ) Conf_GID = grp->gr_gid; + else Conf_GID = (UINT)atoi( Arg ); return; } if( strcasecmp( Var, "PingTimeout" ) == 0 ) @@ -411,6 +433,13 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg ) else Conf_OperCanMode = FALSE; return; } + if( strcasecmp( Var, "MaxConnections" ) == 0 ) + { + /* Maximale Anzahl von Verbindungen. Werte <= 0 stehen + * fuer "kein Limit". */ + Conf_MaxConnections = atol( Arg ); + return; + } Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var ); } /* Handle_GLOBAL */ @@ -446,7 +475,7 @@ Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg ) LOCAL VOID Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg ) { - INT32 port; + LONG port; assert( Line > 0 ); assert( Var != NULL ); @@ -466,11 +495,18 @@ Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg ) Conf_Server[Conf_Server_Count - 1].name[CLIENT_ID_LEN - 1] = '\0'; return; } - if( strcasecmp( Var, "Password" ) == 0 ) + if( strcasecmp( Var, "MyPassword" ) == 0 ) { - /* Passwort des Servers */ - strncpy( Conf_Server[Conf_Server_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 ); - Conf_Server[Conf_Server_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0'; + /* Passwort dieses Servers, welches empfangen werden muss */ + strncpy( Conf_Server[Conf_Server_Count - 1].pwd_in, Arg, CLIENT_PASS_LEN - 1 ); + Conf_Server[Conf_Server_Count - 1].pwd_in[CLIENT_PASS_LEN - 1] = '\0'; + return; + } + if( strcasecmp( Var, "PeerPassword" ) == 0 ) + { + /* Passwort des anderen Servers, welches gesendet werden muss */ + strncpy( Conf_Server[Conf_Server_Count - 1].pwd_out, Arg, CLIENT_PASS_LEN - 1 ); + Conf_Server[Conf_Server_Count - 1].pwd_out[CLIENT_PASS_LEN - 1] = '\0'; return; } if( strcasecmp( Var, "Port" ) == 0 ) @@ -539,7 +575,7 @@ Validate_Config( VOID ) } #ifdef STRICT_RFC - if( ! ConfAdminMail[0] ) + if( ! Conf_ServerAdminMail[0] ) { /* Keine Server-Information konfiguriert */ Config_Error( LOG_ALERT, "No administrator email address configured in \"%s\" ('AdminEMail')!", NGIRCd_ConfFile ); @@ -551,7 +587,7 @@ Validate_Config( VOID ) if( ! Conf_ServerAdmin1[0] && ! Conf_ServerAdmin2[0] && ! Conf_ServerAdminMail[0] ) { /* Keine Server-Information konfiguriert */ - Log( LOG_WARNING, "No server information configured but required by RFC!" ); + Log( LOG_WARNING, "No administrative information configured but required by RFC!" ); } } /* Validate_Config */