X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fngircd%2Fconf.c;h=597ac065881d605d42fb559759120f9434eedfbf;hb=7bbdfb3d847034d7ee1881027164a087b9480300;hp=a1f8fdc37e35576f8de938c49a19b5bf4874141c;hpb=7e1b3b9157b9946d18d252b908fb28a85a0fa0e7;p=ngircd-alex.git diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index a1f8fdc3..597ac065 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.28 2002/09/02 14:59:17 alex Exp $ + * $Id: conf.c,v 1.37 2002/11/18 18:47:42 alex Exp $ * * conf.h: Konfiguration des ngircd */ @@ -25,6 +25,9 @@ #include #include #include +#include +#include +#include #include "ngircd.h" #include "conn.h" @@ -67,7 +70,9 @@ Conf_Test( VOID ) { /* Konfiguration einlesen, ueberpruefen und ausgeben. */ - UINT i; + struct passwd *pwd; + struct group *grp; + INT i; Use_Log = FALSE; Set_Defaults( ); @@ -87,20 +92,29 @@ Conf_Test( VOID ) printf( " ServerName = %s\n", Conf_ServerName ); printf( " ServerInfo = %s\n", Conf_ServerInfo ); printf( " ServerPwd = %s\n", Conf_ServerPwd ); + printf( " AdminInfo1 = %s\n", Conf_ServerAdmin1 ); + 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++ ) @@ -154,6 +168,10 @@ Set_Defaults( VOID ) sprintf( Conf_ServerInfo, "%s %s", PACKAGE, VERSION ); strcpy( Conf_ServerPwd, "" ); + strcpy( Conf_ServerAdmin1, "" ); + strcpy( Conf_ServerAdmin2, "" ); + strcpy( Conf_ServerAdminMail, "" ); + strcpy( Conf_MotdFile, MOTD_FILE ); Conf_ListenPorts_Count = 0; @@ -170,6 +188,8 @@ Set_Defaults( VOID ) Conf_Channel_Count = 0; Conf_OperCanMode = FALSE; + + Conf_MaxConnections = 0; } /* Set_Defaults */ @@ -287,8 +307,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 ); @@ -315,6 +337,27 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg ) Conf_ServerPwd[CLIENT_PASS_LEN - 1] = '\0'; return; } + if( strcasecmp( Var, "AdminInfo1" ) == 0 ) + { + /* Server-Info-Text */ + strncpy( Conf_ServerAdmin1, Arg, CLIENT_INFO_LEN - 1 ); + Conf_ServerAdmin1[CLIENT_INFO_LEN - 1] = '\0'; + return; + } + if( strcasecmp( Var, "AdminInfo2" ) == 0 ) + { + /* Server-Info-Text */ + strncpy( Conf_ServerAdmin2, Arg, CLIENT_INFO_LEN - 1 ); + Conf_ServerAdmin2[CLIENT_INFO_LEN - 1] = '\0'; + return; + } + if( strcasecmp( Var, "AdminEMail" ) == 0 ) + { + /* Server-Info-Text */ + strncpy( Conf_ServerAdminMail, Arg, CLIENT_INFO_LEN - 1 ); + Conf_ServerAdminMail[CLIENT_INFO_LEN - 1] = '\0'; + return; + } if( strcasecmp( Var, "Ports" ) == 0 ) { /* Ports, durch "," getrennt, auf denen der Server @@ -344,13 +387,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 ) @@ -383,6 +430,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 */ @@ -399,8 +453,8 @@ Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg ) if( strcasecmp( Var, "Name" ) == 0 ) { /* Name des IRC Operator */ - strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_ID_LEN - 1 ); - Conf_Oper[Conf_Oper_Count - 1].name[CLIENT_ID_LEN - 1] = '\0'; + strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_PASS_LEN - 1 ); + Conf_Oper[Conf_Oper_Count - 1].name[CLIENT_PASS_LEN - 1] = '\0'; return; } if( strcasecmp( Var, "Password" ) == 0 ) @@ -418,7 +472,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 ); @@ -505,10 +559,26 @@ Validate_Config( VOID ) if( ! Conf_ServerName[0] ) { /* Kein Servername konfiguriert */ - Config_Error( LOG_ALERT, "No server name configured in \"%s\"!", NGIRCd_ConfFile ); + 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 ); } + +#ifdef STRICT_RFC + if( ! Conf_ServerAdminMail[0] ) + { + /* Keine Server-Information konfiguriert */ + 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 ); + } +#endif + + 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!" ); + } } /* Validate_Config */ @@ -540,7 +610,7 @@ va_dcl /* Im "normalen Betrieb" soll der Log-Mechanismus des ngIRCd verwendet * werden, beim Testen der Konfiguration jedoch nicht, hier sollen alle * Meldungen direkt auf die Konsole ausgegeben werden: */ - if( Use_Log ) Log( Level, msg ); + if( Use_Log ) Log( Level, "%s", msg ); else puts( msg ); } /* Config_Error */