+ if (strcasecmp(Var, "Name") == 0) {
+ if (!Handle_Channelname(chan, Arg))
+ Config_Error_TooLong(Line, Var);
+ return;
+ }
+ if (strcasecmp(Var, "Modes") == 0) {
+ /* Initial modes */
+ len = strlcpy(chan->modes, Arg, sizeof(chan->modes));
+ if (len >= sizeof(chan->modes))
+ Config_Error_TooLong( Line, Var );
+ return;
+ }
+ if( strcasecmp( Var, "Topic" ) == 0 ) {
+ /* Initial topic */
+ len = strlcpy(chan->topic, Arg, sizeof(chan->topic));
+ if (len >= sizeof(chan->topic))
+ Config_Error_TooLong( Line, Var );
+ return;
+ }
+ if( strcasecmp( Var, "Key" ) == 0 ) {
+ /* Initial Channel Key (mode k) */
+ len = strlcpy(chan->key, Arg, sizeof(chan->key));
+ if (len >= sizeof(chan->key))
+ Config_Error_TooLong(Line, Var);
+ return;
+ }
+ if( strcasecmp( Var, "MaxUsers" ) == 0 ) {
+ /* maximum user limit, mode l */
+ chan->maxusers = (unsigned long) atol(Arg);
+ if (chan->maxusers == 0)
+ Config_Error_NaN(Line, Var);
+ return;
+ }
+ if (strcasecmp(Var, "KeyFile") == 0) {
+ /* channel keys */
+ len = strlcpy(chan->keyfile, Arg, sizeof(chan->keyfile));
+ if (len >= sizeof(chan->keyfile))
+ Config_Error_TooLong(Line, Var);
+ return;
+ }
+
+ Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!",
+ NGIRCd_ConfFile, Line, Var );
+} /* Handle_CHANNEL */
+
+
+static bool
+Validate_Config(bool Configtest, bool Rehash)
+{
+ /* Validate configuration settings. */
+
+#ifdef DEBUG
+ int i, servers, servers_once;
+#endif
+ bool config_valid = true;
+ char *ptr;
+
+ /* Validate configured server name, see RFC 2812 section 2.3.1 */
+ ptr = Conf_ServerName;
+ do {
+ if (*ptr >= 'a' && *ptr <= 'z') continue;
+ if (*ptr >= 'A' && *ptr <= 'Z') continue;
+ if (*ptr >= '0' && *ptr <= '9') continue;
+ if (ptr > Conf_ServerName) {
+ if (*ptr == '.' || *ptr == '-')
+ continue;
+ }
+ Conf_ServerName[0] = '\0';
+ break;
+ } while (*(++ptr));
+
+ if (!Conf_ServerName[0]) {
+ /* No server name configured! */
+ config_valid = false;
+ Config_Error(LOG_ALERT,
+ "No (valid) server name configured in \"%s\" (section 'Global': 'Name')!",
+ NGIRCd_ConfFile);
+ if (!Configtest && !Rehash) {
+ Config_Error(LOG_ALERT,
+ "%s exiting due to fatal errors!",
+ PACKAGE_NAME);
+ exit(1);
+ }
+ }
+
+ if (Conf_ServerName[0] && !strchr(Conf_ServerName, '.')) {
+ /* No dot in server name! */
+ config_valid = false;
+ Config_Error(LOG_ALERT,
+ "Invalid server name configured in \"%s\" (section 'Global': 'Name'): Dot missing!",
+ NGIRCd_ConfFile);
+ if (!Configtest) {
+ Config_Error(LOG_ALERT,
+ "%s exiting due to fatal errors!",
+ PACKAGE_NAME);
+ exit(1);
+ }
+ }
+
+#ifdef STRICT_RFC
+ if (!Conf_ServerAdminMail[0]) {
+ /* No administrative contact configured! */
+ config_valid = false;
+ Config_Error(LOG_ALERT,
+ "No administrator email address configured in \"%s\" ('AdminEMail')!",
+ NGIRCd_ConfFile);
+ if (!Configtest) {
+ Config_Error(LOG_ALERT,
+ "%s exiting due to fatal errors!",
+ PACKAGE_NAME);
+ exit(1);
+ }
+ }
+#endif
+
+ if (!Conf_ServerAdmin1[0] && !Conf_ServerAdmin2[0]
+ && !Conf_ServerAdminMail[0]) {
+ /* No administrative information configured! */
+ Config_Error(LOG_WARNING,
+ "No administrative information configured but required by RFC!");
+ }
+
+#ifdef DEBUG
+ servers = servers_once = 0;
+ for (i = 0; i < MAX_SERVERS; i++) {
+ if (Conf_Server[i].name[0]) {
+ servers++;
+ if (Conf_Server[i].flags & CONF_SFLAG_ONCE)
+ servers_once++;
+ }
+ }
+ Log(LOG_DEBUG,
+ "Configuration: Operators=%d, Servers=%d[%d], Channels=%d",
+ Conf_Oper_Count, servers, servers_once, Conf_Channel_Count);
+#endif
+
+ return config_valid;