mirror of
https://github.com/osmarks/ngircd.git
synced 2024-12-13 02:10:27 +00:00
--configtest: return non-zero exit code if there are errors
This commit is contained in:
parent
951314cb79
commit
6f7b669bec
@ -56,7 +56,7 @@ static int New_Server_Idx;
|
|||||||
|
|
||||||
static void Set_Defaults PARAMS(( bool InitServers ));
|
static void Set_Defaults PARAMS(( bool InitServers ));
|
||||||
static bool Read_Config PARAMS(( bool ngircd_starting ));
|
static bool Read_Config PARAMS(( bool ngircd_starting ));
|
||||||
static void Validate_Config PARAMS(( bool TestOnly, bool Rehash ));
|
static bool Validate_Config PARAMS(( bool TestOnly, bool Rehash ));
|
||||||
|
|
||||||
static void Handle_GLOBAL PARAMS(( int Line, char *Var, char *Arg ));
|
static void Handle_GLOBAL PARAMS(( int Line, char *Var, char *Arg ));
|
||||||
static void Handle_OPERATOR PARAMS(( int Line, char *Var, char *Arg ));
|
static void Handle_OPERATOR PARAMS(( int Line, char *Var, char *Arg ));
|
||||||
@ -173,11 +173,14 @@ Conf_Test( void )
|
|||||||
struct group *grp;
|
struct group *grp;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
char *topic;
|
char *topic;
|
||||||
|
bool config_valid;
|
||||||
|
|
||||||
Use_Log = false;
|
Use_Log = false;
|
||||||
|
|
||||||
Read_Config( true );
|
if (! Read_Config(true))
|
||||||
Validate_Config(true, false);
|
return 1;
|
||||||
|
|
||||||
|
config_valid = Validate_Config(true, false);
|
||||||
|
|
||||||
/* If stdin and stdout ("you can read our nice message and we can
|
/* If stdin and stdout ("you can read our nice message and we can
|
||||||
* read in your keypress") are valid tty's, wait for a key: */
|
* read in your keypress") are valid tty's, wait for a key: */
|
||||||
@ -265,7 +268,7 @@ Conf_Test( void )
|
|||||||
printf( " Topic = %s\n\n", topic ? topic : "");
|
printf( " Topic = %s\n\n", topic ? topic : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return (config_valid ? 0 : 1);
|
||||||
} /* Conf_Test */
|
} /* Conf_Test */
|
||||||
|
|
||||||
|
|
||||||
@ -1117,7 +1120,7 @@ Handle_CHANNEL( int Line, char *Var, char *Arg )
|
|||||||
} /* Handle_CHANNEL */
|
} /* Handle_CHANNEL */
|
||||||
|
|
||||||
|
|
||||||
static void
|
static bool
|
||||||
Validate_Config(bool Configtest, bool Rehash)
|
Validate_Config(bool Configtest, bool Rehash)
|
||||||
{
|
{
|
||||||
/* Validate configuration settings. */
|
/* Validate configuration settings. */
|
||||||
@ -1125,6 +1128,7 @@ Validate_Config(bool Configtest, bool Rehash)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
int i, servers, servers_once;
|
int i, servers, servers_once;
|
||||||
#endif
|
#endif
|
||||||
|
bool config_valid = true;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
/* Validate configured server name, see RFC 2812 section 2.3.1 */
|
/* Validate configured server name, see RFC 2812 section 2.3.1 */
|
||||||
@ -1143,6 +1147,7 @@ Validate_Config(bool Configtest, bool Rehash)
|
|||||||
|
|
||||||
if (!Conf_ServerName[0]) {
|
if (!Conf_ServerName[0]) {
|
||||||
/* No server name configured! */
|
/* No server name configured! */
|
||||||
|
config_valid = false;
|
||||||
Config_Error(LOG_ALERT,
|
Config_Error(LOG_ALERT,
|
||||||
"No (valid) server name configured in \"%s\" (section 'Global': 'Name')!",
|
"No (valid) server name configured in \"%s\" (section 'Global': 'Name')!",
|
||||||
NGIRCd_ConfFile);
|
NGIRCd_ConfFile);
|
||||||
@ -1156,6 +1161,7 @@ Validate_Config(bool Configtest, bool Rehash)
|
|||||||
|
|
||||||
if (Conf_ServerName[0] && !strchr(Conf_ServerName, '.')) {
|
if (Conf_ServerName[0] && !strchr(Conf_ServerName, '.')) {
|
||||||
/* No dot in server name! */
|
/* No dot in server name! */
|
||||||
|
config_valid = false;
|
||||||
Config_Error(LOG_ALERT,
|
Config_Error(LOG_ALERT,
|
||||||
"Invalid server name configured in \"%s\" (section 'Global': 'Name'): Dot missing!",
|
"Invalid server name configured in \"%s\" (section 'Global': 'Name'): Dot missing!",
|
||||||
NGIRCd_ConfFile);
|
NGIRCd_ConfFile);
|
||||||
@ -1170,6 +1176,7 @@ Validate_Config(bool Configtest, bool Rehash)
|
|||||||
#ifdef STRICT_RFC
|
#ifdef STRICT_RFC
|
||||||
if (!Conf_ServerAdminMail[0]) {
|
if (!Conf_ServerAdminMail[0]) {
|
||||||
/* No administrative contact configured! */
|
/* No administrative contact configured! */
|
||||||
|
config_valid = false;
|
||||||
Config_Error(LOG_ALERT,
|
Config_Error(LOG_ALERT,
|
||||||
"No administrator email address configured in \"%s\" ('AdminEMail')!",
|
"No administrator email address configured in \"%s\" ('AdminEMail')!",
|
||||||
NGIRCd_ConfFile);
|
NGIRCd_ConfFile);
|
||||||
@ -1202,6 +1209,8 @@ Validate_Config(bool Configtest, bool Rehash)
|
|||||||
"Configuration: Operators=%d, Servers=%d[%d], Channels=%d",
|
"Configuration: Operators=%d, Servers=%d[%d], Channels=%d",
|
||||||
Conf_Oper_Count, servers, servers_once, Conf_Channel_Count);
|
Conf_Oper_Count, servers, servers_once, Conf_Channel_Count);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return config_valid;
|
||||||
} /* Validate_Config */
|
} /* Validate_Config */
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user