]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/conf.c
New "chroot" feature (from Benjamin Pineau), introducing new configuration
[ngircd-alex.git] / src / ngircd / conf.c
index 81e0a916fe4c5c833dcd0848babbcb9265307661..1ea1fe741ef3397c35a6d151c1bac575c4c1eec7 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.62 2003/12/19 14:32:59 alex Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.64 2004/05/07 11:19:21 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -23,6 +23,7 @@ static char UNUSED id[] = "$Id: conf.c,v 1.62 2003/12/19 14:32:59 alex Exp $";
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 #include <unistd.h>
 #include <pwd.h>
 #include <grp.h>
@@ -113,6 +114,8 @@ Conf_Test( VOID )
        printf( "  AdminInfo2 = %s\n", Conf_ServerAdmin2 );
        printf( "  AdminEMail = %s\n", Conf_ServerAdminMail );
        printf( "  MotdFile = %s\n", Conf_MotdFile );
+       printf( "  MotdPhrase = %s\n", Conf_MotdPhrase );
+       printf( "  ChrootDir= %s\n", Conf_Chroot );
        printf( "  Ports = " );
        for( i = 0; i < Conf_ListenPorts_Count; i++ )
        {
@@ -342,6 +345,10 @@ Set_Defaults( BOOLEAN InitServers )
        strlcpy( Conf_MotdFile, SYSCONFDIR, sizeof( Conf_MotdFile ));
        strlcat( Conf_MotdFile, MOTD_FILE, sizeof( Conf_MotdFile ));
 
+       strlcpy( Conf_MotdPhrase, MOTD_PHRASE, sizeof( Conf_MotdPhrase ));
+
+       strlcpy( Conf_Chroot, CHROOT_DIR, sizeof( Conf_Chroot ));
+
        Conf_ListenPorts_Count = 0;
        strcpy( Conf_ListenAddress, "" );
 
@@ -612,6 +619,18 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
                if( strlcpy( Conf_MotdFile, Arg, sizeof( Conf_MotdFile )) >= sizeof( Conf_MotdFile )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MotdFile\" too long!", NGIRCd_ConfFile, Line );
                return;
        }
+       if( strcasecmp( Var, "MotdPhrase" ) == 0 )
+       {
+               /* "Message of the day" phrase (instead of file) */
+               if( strlcpy( Conf_MotdPhrase, Arg, sizeof( Conf_MotdPhrase )) >= sizeof( Conf_MotdPhrase )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MotdPhrase\" too long!", NGIRCd_ConfFile, Line );
+               return;
+       }
+       if( strcasecmp( Var, "ChrootDir" ) == 0 )
+       {
+               /* directory for chroot() */
+               if( strlcpy( Conf_Chroot, Arg, sizeof( Conf_Chroot )) >= sizeof( Conf_Chroot )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"ChrootDir\" too long!", NGIRCd_ConfFile, Line );
+               return;
+       }
        if( strcasecmp( Var, "ServerUID" ) == 0 )
        {
                /* UID the daemon should switch to */
@@ -620,7 +639,7 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
                else
                {
 #ifdef HAVE_ISDIGIT
-                       if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"ServerUID\" is not a number!", NGIRCd_ConfFile, Line );
+                       if( ! isdigit( (INT)*Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"ServerUID\" is not a number!", NGIRCd_ConfFile, Line );
                        else
 #endif
                        Conf_UID = (UINT)atoi( Arg );
@@ -635,7 +654,7 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
                else
                {
 #ifdef HAVE_ISDIGIT
-                       if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"ServerGID\" is not a number!", NGIRCd_ConfFile, Line );
+                       if( ! isdigit( (INT)*Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"ServerGID\" is not a number!", NGIRCd_ConfFile, Line );
                        else
 #endif
                        Conf_GID = (UINT)atoi( Arg );
@@ -688,7 +707,7 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
        {
                /* Maximum number of connections. Values <= 0 are equal to "no limit". */
 #ifdef HAVE_ISDIGIT
-               if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxConnections\" is not a number!", NGIRCd_ConfFile, Line );
+               if( ! isdigit( (INT)*Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxConnections\" is not a number!", NGIRCd_ConfFile, Line );
                else
 #endif
                Conf_MaxConnections = atol( Arg );
@@ -698,7 +717,7 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
        {
                /* Maximum number of simoultanous connections from one IP. Values <= 0 are equal to "no limit". */
 #ifdef HAVE_ISDIGIT
-               if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxConnectionsIP\" is not a number!", NGIRCd_ConfFile, Line );
+               if( ! isdigit( (INT)*Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxConnectionsIP\" is not a number!", NGIRCd_ConfFile, Line );
                else
 #endif
                Conf_MaxConnectionsIP = atoi( Arg );
@@ -708,7 +727,7 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
        {
                /* Maximum number of channels a user can join. Values <= 0 are equal to "no limit". */
 #ifdef HAVE_ISDIGIT
-               if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxJoins\" is not a number!", NGIRCd_ConfFile, Line );
+               if( ! isdigit( (INT)*Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxJoins\" is not a number!", NGIRCd_ConfFile, Line );
                else
 #endif
                Conf_MaxJoins = atoi( Arg );
@@ -801,7 +820,7 @@ Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
        {
                /* Server group */
 #ifdef HAVE_ISDIGIT
-               if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Group\" is not a number!", NGIRCd_ConfFile, Line );
+               if( ! isdigit( (INT)*Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Group\" is not a number!", NGIRCd_ConfFile, Line );
                else
 #endif
                New_Server.group = atoi( Arg );