]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conf.c
- Dokumentation aktualisiert.
[ngircd-alex.git] / src / ngircd / conf.c
index 81ddb252a5e1f55a67655135e4bfcfa851e59d18..d87db500355933ccb7e3b8749a0be442c4b80cc1 100644 (file)
@@ -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.34 2002/10/21 13:45:07 alex Exp $
+ * $Id: conf.c,v 1.36 2002/11/08 23:09:26 alex Exp $
  *
  * conf.h: Konfiguration des ngircd
  */
@@ -25,6 +25,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <pwd.h>
+#include <grp.h>
+#include <sys/types.h>
 
 #include "ngircd.h"
 #include "conn.h"
@@ -67,6 +70,8 @@ Conf_Test( VOID )
 {
        /* Konfiguration einlesen, ueberpruefen und ausgeben. */
 
+       struct passwd *pwd;
+       struct group *grp;
        INT i;
 
        Use_Log = FALSE;
@@ -98,12 +103,18 @@ Conf_Test( VOID )
                printf( "%u", Conf_ListenPorts[i] );
        }
        puts( "" );
-       printf( "  ServerUID = %ld\n", (LONG)Conf_UID );
-       printf( "  ServerGID = %ld\n", (LONG)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++ )
@@ -177,6 +188,8 @@ Set_Defaults( VOID )
        Conf_Channel_Count = 0;
 
        Conf_OperCanMode = FALSE;
+       
+       Conf_MaxConnections = 0;
 } /* Set_Defaults */
 
 
@@ -294,6 +307,8 @@ Read_Config( VOID )
 LOCAL VOID
 Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
 {
+       struct passwd *pwd;
+       struct group *grp;
        CHAR *ptr;
        LONG port;
        
@@ -372,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 )
@@ -411,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 */