diff --git a/Changes b/Changes index 3b9582003..21b84b26f 100644 --- a/Changes +++ b/Changes @@ -1533,3 +1533,4 @@ to check again, suggested by vonitsanet (#0003136). - Fixed a typo in help.conf, reported by Sakkath (#0003196). - Added extended ban ~j, reported by Shining Phoenix (#0003192). +- Made ./unreal configtest to test config file, suggested by djGrrr (#0003164). diff --git a/include/h.h b/include/h.h index e9e81f4b5..3bb366c40 100644 --- a/include/h.h +++ b/include/h.h @@ -566,6 +566,7 @@ extern void flag_del(char ch); extern void init_dynconf(void); extern char *pretty_time_val(long); extern int init_conf(char *filename, int rehash); +extern int global_test(); extern void validate_configuration(void); extern void run_configuration(void); extern void rehash_motdrules(); diff --git a/src/ircd.c b/src/ircd.c index f72a28890..9634ece6a 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -95,6 +95,7 @@ extern MODVAR aMotd *motd; extern MODVAR aMotd *rules; extern MODVAR aMotd *botmotd; extern MODVAR aMotd *smotd; +extern MODVAR ConfigFile *conf; MODVAR MemoryInfo StatsZ; int R_do_dns, R_fin_dns, R_fin_dnsc, R_fail_dns, R_do_id, R_fin_id, R_fail_id; @@ -1282,6 +1283,33 @@ int InitwIRCD(int argc, char *argv[]) # endif exit(0); #endif + case 'e': + if (load_conf(configfile) > 0) + { + if (!global_test()) + { + config_error("IRCd configuration failed to pass testing"); +#ifdef _WIN32 + win_error(); +#endif + } + else + config_status("Configuration tested without any problems .."); +#ifndef STATIC_LINKING + Unload_all_testing_modules(); +#endif + unload_notloaded_includes(); + config_free(conf); + conf = NULL; + } + else + { + config_error("IRCd configuration failed to load"); +#ifdef _WIN32 + win_error(); +#endif + } + exit(0); default: bad_command(); break; diff --git a/src/s_conf.c b/src/s_conf.c index 300462bf8..030eefedc 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -1432,7 +1432,13 @@ void applymeblock(void) } } } - +int global_test() +{ + charsys_reset_pretest(); + if ((config_test() < 0) || (callbacks_check() < 0) || (efunctions_check() < 0) || (charsys_postconftest() < 0)) + return 0; + return 1; +} int init_conf(char *rootconf, int rehash) { config_status("Loading IRCd configuration .."); @@ -1447,9 +1453,7 @@ int init_conf(char *rootconf, int rehash) config_setdefaultsettings(&tempiConf); if (load_conf(rootconf) > 0) { - charsys_reset_pretest(); - if ((config_test() < 0) || (callbacks_check() < 0) || (efunctions_check() < 0) || - (charsys_postconftest() < 0)) + if (!global_test()) { config_error("IRCd configuration failed to pass testing"); #ifdef _WIN32 diff --git a/unreal.in b/unreal.in index 423549b0d..2d15a8b08 100644 --- a/unreal.in +++ b/unreal.in @@ -37,6 +37,8 @@ elif [ "$1" = "mkpasswd" ] ; then @BINDIR@ -P $2 $3 elif [ "$1" = "version" ] ; then @BINDIR@ -v +elif [ "$1" = "configtest" ] ; then + @BINDIR@ -e elif [ "$1" = "backtrace" ] ; then cd @IRCDDIR@