]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conf.c
- neue Funktionen Conn_InitListeners() und Conn_ExitListeners().
[ngircd-alex.git] / src / ngircd / conf.c
index cf8b2684fb5b518ef310906b1ad6ec976f6e0349..12a84d696a24ad06f3a6059078a1590c6b969395 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.35 2002/11/02 22:59:01 alex Exp $
+ * $Id: conf.c,v 1.39 2002/11/22 17:57:40 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;
@@ -91,15 +96,19 @@ 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", (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 );
@@ -129,7 +138,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( "" );
        }
@@ -202,6 +212,8 @@ Read_Config( VOID )
                exit( 1 );
        }
 
+       Config_Error( LOG_INFO, "Reading configuration from \"%s\" ...", NGIRCd_ConfFile );
+
        line = 0;
        strcpy( section, "" );
        while( TRUE )
@@ -239,7 +251,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;
@@ -298,6 +311,8 @@ Read_Config( VOID )
 LOCAL VOID
 Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
 {
+       struct passwd *pwd;
+       struct group *grp;
        CHAR *ptr;
        LONG port;
        
@@ -376,13 +391,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 )
@@ -477,11 +496,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 )
@@ -562,7 +588,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 */