]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Do not exit unconditionally if config file cannot be opened
authorFlorian Westphal <fw@strlen.de>
Tue, 18 Mar 2008 20:12:47 +0000 (20:12 +0000)
committerFlorian Westphal <fw@strlen.de>
Wed, 26 Mar 2008 20:31:13 +0000 (21:31 +0100)
ngircd will exit if the config file cannot be opened. While
thats okay if ngircd starts up for the first time, it isn't
when we are re-reading the config file after a /REHASH or SIGHUP.

ChangeLog
src/ngircd/conf.c
src/ngircd/conf.h
src/ngircd/ngircd.c

index b562638204152e42f39ed2fc61cfbb8daafb81a3..736ef7c18ecab160716c5a377f742a5c73fd2ec6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@
 
 ngIRCd HEAD
 
+  - Do not exit on SIGHUP or /REHASH if the config file cannot opened.
   - Add IPv6 support.
   - Install a LaunchDaemon script to start/stop ngIRCd on Mac OS X.
   - Implemented IRC commands INFO, SUMMON (dummy), and USERS (dummy) and
@@ -759,4 +760,4 @@ ngIRCd 0.0.1, 31.12.2001
 
 
 -- 
-$Id: ChangeLog,v 1.344 2008/02/26 22:05:42 fw Exp $
+$Id: ChangeLog,v 1.345 2008/03/18 20:12:47 fw Exp $
index 3239dd140d70692acb90a6528a1b170d642d15a6..0f6686221696f463eccd11097aa488fd8121bcbc 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: conf.c,v 1.104 2008/02/26 22:04:17 fw Exp $";
+static char UNUSED id[] = "$Id: conf.c,v 1.105 2008/03/18 20:12:47 fw Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -57,7 +57,7 @@ static int New_Server_Idx;
 
 
 static void Set_Defaults PARAMS(( bool InitServers ));
-static void Read_Config PARAMS(( void ));
+static bool Read_Config PARAMS(( bool ngircd_starting ));
 static void Validate_Config PARAMS(( bool TestOnly, bool Rehash ));
 
 static void Handle_GLOBAL PARAMS(( int Line, char *Var, char *Arg ));
@@ -134,21 +134,21 @@ ports_parse(array *a, int Line, char *Arg)
 GLOBAL void
 Conf_Init( void )
 {
-       Set_Defaults( true );
-       Read_Config( );
+       Read_Config( true );
        Validate_Config(false, false);
 } /* Config_Init */
 
 
-GLOBAL void
+GLOBAL bool
 Conf_Rehash( void )
 {
-       Set_Defaults( false );
-       Read_Config( );
+       if (!Read_Config(false))
+               return false;
        Validate_Config(false, true);
 
        /* Update CLIENT structure of local server */
        Client_SetInfo(Client_ThisServer(), Conf_ServerInfo);
+       return true;
 } /* Config_Rehash */
 
 
@@ -163,9 +163,8 @@ Conf_Test( void )
        char *topic;
 
        Use_Log = false;
-       Set_Defaults( true );
 
-       Read_Config( );
+       Read_Config( true );
        Validate_Config(true, false);
 
        /* If stdin and stdout ("you can read our nice message and we can
@@ -460,8 +459,8 @@ Set_Defaults( bool InitServers )
 } /* Set_Defaults */
 
 
-static void
-Read_Config( void )
+static bool
+Read_Config( bool ngircd_starting )
 {
        /* Read configuration file. */
 
@@ -476,10 +475,14 @@ Read_Config( void )
                /* No configuration file found! */
                Config_Error( LOG_ALERT, "Can't read configuration \"%s\": %s",
                                        NGIRCd_ConfFile, strerror( errno ));
+               if (!ngircd_starting)
+                       return false;
                Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
                exit( 1 );
        }
 
+       Set_Defaults( ngircd_starting );
+
        Config_Error( LOG_INFO, "Reading configuration from \"%s\" ...", NGIRCd_ConfFile );
 
        /* Clean up server configuration structure: mark all already
@@ -626,6 +629,7 @@ Read_Config( void )
                        exit( 1 );
                }
        }
+       return true;
 } /* Read_Config */
 
 
index b6a5a2acf87766d85fb0265141ad4dd82c3623be..d505f3390db01625f259d565bf7c9dffc4cc26dd 100644 (file)
@@ -8,7 +8,7 @@
  * (at your option) any later version.
  * Please read the file COPYING, README and AUTHORS for more information.
  *
- * $Id: conf.h,v 1.48 2008/02/26 22:04:17 fw Exp $
+ * $Id: conf.h,v 1.49 2008/03/18 20:12:47 fw Exp $
  *
  * Configuration management (header)
  */
@@ -148,7 +148,7 @@ GLOBAL int Conf_MaxConnectionsIP;
 GLOBAL unsigned int Conf_MaxNickLength;
 
 GLOBAL void Conf_Init PARAMS((void));
-GLOBAL void Conf_Rehash PARAMS((void));
+GLOBAL bool Conf_Rehash PARAMS((void));
 GLOBAL int Conf_Test PARAMS((void));
 
 GLOBAL void Conf_UnsetServer PARAMS(( CONN_ID Idx ));
index 73c9a15138f7b6e198b0a166c976d767216a846f..bb88b3b97fca68641c04c6095822fa828863346d 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: ngircd.c,v 1.118 2008/02/26 22:04:17 fw Exp $";
+static char UNUSED id[] = "$Id: ngircd.c,v 1.119 2008/03/18 20:12:47 fw Exp $";
 
 /**
  * @file
@@ -432,15 +432,16 @@ NGIRCd_Rehash( void )
        Log( LOG_NOTICE|LOG_snotice, "Re-reading configuration NOW!" );
        NGIRCd_SignalRehash = false;
 
-       /* Close down all listening sockets */
-       Conn_ExitListeners( );
-
        /* Remember old server name and nick name length */
        strlcpy( old_name, Conf_ServerName, sizeof old_name );
        old_nicklen = Conf_MaxNickLength;
 
        /* Re-read configuration ... */
-       Conf_Rehash( );
+       if (!Conf_Rehash( ))
+               return;
+
+       /* Close down all listening sockets */
+       Conn_ExitListeners( );
 
        /* Recover old server name and nick name length: these values can't
         * be changed during run-time */