2 cbc1e59f 2001-12-12 alex * ngIRCd -- The Next Generation IRC Daemon
3 03d971d9 2002-01-02 alex * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
5 cbc1e59f 2001-12-12 alex * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
6 cbc1e59f 2001-12-12 alex * der GNU General Public License (GPL), wie von der Free Software Foundation
7 cbc1e59f 2001-12-12 alex * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
8 cbc1e59f 2001-12-12 alex * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
9 cbc1e59f 2001-12-12 alex * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
10 804b1ec4 2001-12-31 alex * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
12 0d32a3b4 2002-11-02 alex * $Id: conf.c,v 1.35 2002/11/02 22:59:01 alex Exp $
14 cbc1e59f 2001-12-12 alex * conf.h: Konfiguration des ngircd
18 ca33cbda 2002-03-12 alex #include "portab.h"
20 ca33cbda 2002-03-12 alex #include "imp.h"
21 cbc1e59f 2001-12-12 alex #include <assert.h>
22 9856253d 2001-12-30 alex #include <errno.h>
23 f86083a0 2002-03-27 alex #include <stdarg.h>
24 9856253d 2001-12-30 alex #include <stdio.h>
25 b20fa7c6 2002-01-01 alex #include <stdlib.h>
26 9856253d 2001-12-30 alex #include <string.h>
27 f86083a0 2002-03-27 alex #include <unistd.h>
29 f86083a0 2002-03-27 alex #include "ngircd.h"
30 c2f60abe 2002-05-27 alex #include "conn.h"
31 9856253d 2001-12-30 alex #include "client.h"
32 ca33cbda 2002-03-12 alex #include "defines.h"
33 9856253d 2001-12-30 alex #include "log.h"
34 c2f60abe 2002-05-27 alex #include "resolve.h"
35 9856253d 2001-12-30 alex #include "tool.h"
37 ca33cbda 2002-03-12 alex #include "exp.h"
38 cbc1e59f 2001-12-12 alex #include "conf.h"
41 f86083a0 2002-03-27 alex LOCAL BOOLEAN Use_Log = TRUE;
44 c2f60abe 2002-05-27 alex LOCAL VOID Set_Defaults PARAMS(( VOID ));
45 c2f60abe 2002-05-27 alex LOCAL VOID Read_Config PARAMS(( VOID ));
46 c2f60abe 2002-05-27 alex LOCAL VOID Validate_Config PARAMS(( VOID ));
48 c2f60abe 2002-05-27 alex LOCAL VOID Handle_GLOBAL PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
49 c2f60abe 2002-05-27 alex LOCAL VOID Handle_OPERATOR PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
50 c2f60abe 2002-05-27 alex LOCAL VOID Handle_SERVER PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
51 c2f60abe 2002-05-27 alex LOCAL VOID Handle_CHANNEL PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
53 c2f60abe 2002-05-27 alex LOCAL VOID Config_Error PARAMS(( CONST INT Level, CONST CHAR *Format, ... ));
57 c2f60abe 2002-05-27 alex Conf_Init( VOID )
59 f86083a0 2002-03-27 alex Set_Defaults( );
60 f86083a0 2002-03-27 alex Read_Config( );
61 f86083a0 2002-03-27 alex Validate_Config( );
62 f86083a0 2002-03-27 alex } /* Config_Init */
66 c2f60abe 2002-05-27 alex Conf_Test( VOID )
68 f86083a0 2002-03-27 alex /* Konfiguration einlesen, ueberpruefen und ausgeben. */
72 f86083a0 2002-03-27 alex Use_Log = FALSE;
73 f86083a0 2002-03-27 alex Set_Defaults( );
75 f86083a0 2002-03-27 alex printf( "Using \"%s\" as configuration file ...\n", NGIRCd_ConfFile );
76 f86083a0 2002-03-27 alex Read_Config( );
78 f86083a0 2002-03-27 alex /* Wenn stdin ein ein TTY ist: auf Taste warten */
79 f86083a0 2002-03-27 alex if( isatty( fileno( stdout )))
81 f86083a0 2002-03-27 alex puts( "OK, press enter to see a dump of your service configuration ..." );
84 f86083a0 2002-03-27 alex else puts( "Ok, dump of your server configuration follows:\n" );
86 f86083a0 2002-03-27 alex puts( "[GLOBAL]" );
87 f86083a0 2002-03-27 alex printf( " ServerName = %s\n", Conf_ServerName );
88 f86083a0 2002-03-27 alex printf( " ServerInfo = %s\n", Conf_ServerInfo );
89 f86083a0 2002-03-27 alex printf( " ServerPwd = %s\n", Conf_ServerPwd );
90 b615d128 2002-09-16 alex printf( " AdminInfo1 = %s\n", Conf_ServerAdmin1 );
91 b615d128 2002-09-16 alex printf( " AdminInfo2 = %s\n", Conf_ServerAdmin2 );
92 b615d128 2002-09-16 alex printf( " AdminEMail = %s\n", Conf_ServerAdminMail );
93 f86083a0 2002-03-27 alex printf( " MotdFile = %s\n", Conf_MotdFile );
94 f86083a0 2002-03-27 alex printf( " ListenPorts = " );
95 f86083a0 2002-03-27 alex for( i = 0; i < Conf_ListenPorts_Count; i++ )
97 f86083a0 2002-03-27 alex if( i != 0 ) printf( ", " );
98 1c2d0ae5 2002-03-29 alex printf( "%u", Conf_ListenPorts[i] );
100 1c2d0ae5 2002-03-29 alex puts( "" );
101 c7b55aa6 2002-10-09 alex printf( " ServerUID = %ld\n", (LONG)Conf_UID );
102 c7b55aa6 2002-10-09 alex printf( " ServerGID = %ld\n", (LONG)Conf_GID );
103 f86083a0 2002-03-27 alex printf( " PingTimeout = %d\n", Conf_PingTimeout );
104 f86083a0 2002-03-27 alex printf( " PongTimeout = %d\n", Conf_PongTimeout );
105 f86083a0 2002-03-27 alex printf( " ConnectRetry = %d\n", Conf_ConnectRetry );
106 7e1b3b91 2002-09-02 alex printf( " OperCanUseMode = %s\n", Conf_OperCanMode == TRUE ? "yes" : "no" );
107 0d32a3b4 2002-11-02 alex if( Conf_MaxConnections > 0 ) printf( " MaxConnections = %ld\n", Conf_MaxConnections );
108 0d32a3b4 2002-11-02 alex else printf( " MaxConnections = -1\n" );
109 f86083a0 2002-03-27 alex puts( "" );
111 f86083a0 2002-03-27 alex for( i = 0; i < Conf_Oper_Count; i++ )
113 c23535bc 2002-05-22 alex if( ! Conf_Oper[i].name[0] ) continue;
115 c23535bc 2002-05-22 alex /* gueltiger Operator-Block: ausgeben */
116 f86083a0 2002-03-27 alex puts( "[OPERATOR]" );
117 f86083a0 2002-03-27 alex printf( " Name = %s\n", Conf_Oper[i].name );
118 f86083a0 2002-03-27 alex printf( " Password = %s\n", Conf_Oper[i].pwd );
119 f86083a0 2002-03-27 alex puts( "" );
122 f86083a0 2002-03-27 alex for( i = 0; i < Conf_Server_Count; i++ )
124 c23535bc 2002-05-22 alex if( ! Conf_Server[i].name[0] ) continue;
125 c23535bc 2002-05-22 alex if( ! Conf_Server[i].host[0] ) continue;
127 c23535bc 2002-05-22 alex /* gueltiger Server-Block: ausgeben */
128 f86083a0 2002-03-27 alex puts( "[SERVER]" );
129 f86083a0 2002-03-27 alex printf( " Name = %s\n", Conf_Server[i].name );
130 f86083a0 2002-03-27 alex printf( " Host = %s\n", Conf_Server[i].host );
131 f86083a0 2002-03-27 alex printf( " Port = %d\n", Conf_Server[i].port );
132 f86083a0 2002-03-27 alex printf( " Password = %s\n", Conf_Server[i].pwd );
133 f86083a0 2002-03-27 alex printf( " Group = %d\n", Conf_Server[i].group );
134 f86083a0 2002-03-27 alex puts( "" );
137 040f5422 2002-05-21 alex for( i = 0; i < Conf_Channel_Count; i++ )
139 c23535bc 2002-05-22 alex if( ! Conf_Channel[i].name[0] ) continue;
141 c23535bc 2002-05-22 alex /* gueltiger Channel-Block: ausgeben */
142 040f5422 2002-05-21 alex puts( "[CHANNEL]" );
143 040f5422 2002-05-21 alex printf( " Name = %s\n", Conf_Channel[i].name );
144 040f5422 2002-05-21 alex printf( " Modes = %s\n", Conf_Channel[i].modes );
145 040f5422 2002-05-21 alex printf( " Topic = %s\n", Conf_Channel[i].topic );
146 040f5422 2002-05-21 alex puts( "" );
150 f86083a0 2002-03-27 alex } /* Conf_Test */
154 c2f60abe 2002-05-27 alex Set_Defaults( VOID )
156 f86083a0 2002-03-27 alex /* Konfigurationsvariablen initialisieren, d.h. auf Default-Werte setzen. */
158 9856253d 2001-12-30 alex strcpy( Conf_ServerName, "" );
159 f7327524 2002-05-30 alex sprintf( Conf_ServerInfo, "%s %s", PACKAGE, VERSION );
160 ed406b4a 2002-01-03 alex strcpy( Conf_ServerPwd, "" );
162 b615d128 2002-09-16 alex strcpy( Conf_ServerAdmin1, "" );
163 b615d128 2002-09-16 alex strcpy( Conf_ServerAdmin2, "" );
164 b615d128 2002-09-16 alex strcpy( Conf_ServerAdminMail, "" );
166 10aa35cc 2002-03-06 alex strcpy( Conf_MotdFile, MOTD_FILE );
168 9856253d 2001-12-30 alex Conf_ListenPorts_Count = 0;
170 1c2d0ae5 2002-03-29 alex Conf_UID = Conf_GID = 0;
172 08cf5607 2001-12-26 alex Conf_PingTimeout = 120;
173 281d8e45 2002-03-25 alex Conf_PongTimeout = 20;
175 03d971d9 2002-01-02 alex Conf_ConnectRetry = 60;
177 03d971d9 2002-01-02 alex Conf_Oper_Count = 0;
178 03d971d9 2002-01-02 alex Conf_Server_Count = 0;
179 040f5422 2002-05-21 alex Conf_Channel_Count = 0;
181 7e1b3b91 2002-09-02 alex Conf_OperCanMode = FALSE;
183 0d32a3b4 2002-11-02 alex Conf_MaxConnections = 0;
184 f86083a0 2002-03-27 alex } /* Set_Defaults */
188 c2f60abe 2002-05-27 alex Read_Config( VOID )
190 574ae82c 2001-12-26 alex /* Konfigurationsdatei einlesen. */
192 03d971d9 2002-01-02 alex CHAR section[LINE_LEN], str[LINE_LEN], *var, *arg, *ptr;
196 f86083a0 2002-03-27 alex fd = fopen( NGIRCd_ConfFile, "r" );
199 9856253d 2001-12-30 alex /* Keine Konfigurationsdatei gefunden */
200 f86083a0 2002-03-27 alex Config_Error( LOG_ALERT, "Can't read configuration \"%s\": %s", NGIRCd_ConfFile, strerror( errno ));
201 f7327524 2002-05-30 alex Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
206 03d971d9 2002-01-02 alex strcpy( section, "" );
207 9856253d 2001-12-30 alex while( TRUE )
209 804b1ec4 2001-12-31 alex if( ! fgets( str, LINE_LEN, fd )) break;
210 9856253d 2001-12-30 alex ngt_TrimStr( str );
213 9856253d 2001-12-30 alex /* Kommentarzeilen und leere Zeilen ueberspringen */
214 9856253d 2001-12-30 alex if( str[0] == ';' || str[0] == '#' || str[0] == '\0' ) continue;
216 03d971d9 2002-01-02 alex /* Anfang eines Abschnittes? */
217 03d971d9 2002-01-02 alex if(( str[0] == '[' ) && ( str[strlen( str ) - 1] == ']' ))
219 03d971d9 2002-01-02 alex strcpy( section, str );
220 03d971d9 2002-01-02 alex if( strcasecmp( section, "[GLOBAL]" ) == 0 ) continue;
221 03d971d9 2002-01-02 alex if( strcasecmp( section, "[OPERATOR]" ) == 0 )
223 f86083a0 2002-03-27 alex if( Conf_Oper_Count + 1 > MAX_OPERATORS ) Config_Error( LOG_ERR, "Too many operators configured." );
226 03d971d9 2002-01-02 alex /* neuen Operator initialisieren */
227 03d971d9 2002-01-02 alex strcpy( Conf_Oper[Conf_Oper_Count].name, "" );
228 03d971d9 2002-01-02 alex strcpy( Conf_Oper[Conf_Oper_Count].pwd, "" );
229 03d971d9 2002-01-02 alex Conf_Oper_Count++;
233 03d971d9 2002-01-02 alex if( strcasecmp( section, "[SERVER]" ) == 0 )
235 f86083a0 2002-03-27 alex if( Conf_Server_Count + 1 > MAX_SERVERS ) Config_Error( LOG_ERR, "Too many servers configured." );
238 03d971d9 2002-01-02 alex /* neuen Server ("Peer") initialisieren */
239 03d971d9 2002-01-02 alex strcpy( Conf_Server[Conf_Server_Count].host, "" );
240 03d971d9 2002-01-02 alex strcpy( Conf_Server[Conf_Server_Count].ip, "" );
241 03d971d9 2002-01-02 alex strcpy( Conf_Server[Conf_Server_Count].name, "" );
242 03d971d9 2002-01-02 alex strcpy( Conf_Server[Conf_Server_Count].pwd, "" );
243 03d971d9 2002-01-02 alex Conf_Server[Conf_Server_Count].port = 0;
244 d67d94ea 2002-03-10 alex Conf_Server[Conf_Server_Count].group = -1;
245 6debfc31 2002-01-18 alex Conf_Server[Conf_Server_Count].lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY;
246 03d971d9 2002-01-02 alex Conf_Server[Conf_Server_Count].res_stat = NULL;
247 03d971d9 2002-01-02 alex Conf_Server_Count++;
251 040f5422 2002-05-21 alex if( strcasecmp( section, "[CHANNEL]" ) == 0 )
253 040f5422 2002-05-21 alex if( Conf_Channel_Count + 1 > MAX_DEFCHANNELS ) Config_Error( LOG_ERR, "Too many pre-defined channels configured." );
256 040f5422 2002-05-21 alex /* neuen vordefinierten Channel initialisieren */
257 040f5422 2002-05-21 alex strcpy( Conf_Channel[Conf_Channel_Count].name, "" );
258 040f5422 2002-05-21 alex strcpy( Conf_Channel[Conf_Channel_Count].modes, "" );
259 040f5422 2002-05-21 alex strcpy( Conf_Channel[Conf_Channel_Count].topic, "" );
260 040f5422 2002-05-21 alex Conf_Channel_Count++;
264 f86083a0 2002-03-27 alex Config_Error( LOG_ERR, "%s, line %d: Unknown section \"%s\"!", NGIRCd_ConfFile, line, section );
265 03d971d9 2002-01-02 alex section[0] = 0x1;
267 03d971d9 2002-01-02 alex if( section[0] == 0x1 ) continue;
269 03d971d9 2002-01-02 alex /* In Variable und Argument zerlegen */
270 9856253d 2001-12-30 alex ptr = strchr( str, '=' );
271 9856253d 2001-12-30 alex if( ! ptr )
273 f86083a0 2002-03-27 alex Config_Error( LOG_ERR, "%s, line %d: Syntax error!", NGIRCd_ConfFile, line );
276 9856253d 2001-12-30 alex *ptr = '\0';
277 9856253d 2001-12-30 alex var = str; ngt_TrimStr( var );
278 9856253d 2001-12-30 alex arg = ptr + 1; ngt_TrimStr( arg );
280 03d971d9 2002-01-02 alex if( strcasecmp( section, "[GLOBAL]" ) == 0 ) Handle_GLOBAL( line, var, arg );
281 03d971d9 2002-01-02 alex else if( strcasecmp( section, "[OPERATOR]" ) == 0 ) Handle_OPERATOR( line, var, arg );
282 03d971d9 2002-01-02 alex else if( strcasecmp( section, "[SERVER]" ) == 0 ) Handle_SERVER( line, var, arg );
283 040f5422 2002-05-21 alex else if( strcasecmp( section, "[CHANNEL]" ) == 0 ) Handle_CHANNEL( line, var, arg );
284 f86083a0 2002-03-27 alex else Config_Error( LOG_ERR, "%s, line %d: Variable \"%s\" outside section!", NGIRCd_ConfFile, line, var );
287 03d971d9 2002-01-02 alex fclose( fd );
289 1c99b837 2002-03-30 alex /* Wenn kein Port definiert wurde, Port 6667 als Default benutzen */
290 1c99b837 2002-03-30 alex if( Conf_ListenPorts_Count < 1 )
292 1c99b837 2002-03-30 alex Conf_ListenPorts_Count = 1;
293 1c99b837 2002-03-30 alex Conf_ListenPorts[0] = 6667;
295 03d971d9 2002-01-02 alex } /* Read_Config */
299 c2f60abe 2002-05-27 alex Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
304 03d971d9 2002-01-02 alex assert( Line > 0 );
305 03d971d9 2002-01-02 alex assert( Var != NULL );
306 03d971d9 2002-01-02 alex assert( Arg != NULL );
308 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Name" ) == 0 )
310 03d971d9 2002-01-02 alex /* Der Server-Name */
311 10363b39 2002-03-03 alex strncpy( Conf_ServerName, Arg, CLIENT_ID_LEN - 1 );
312 03d971d9 2002-01-02 alex Conf_ServerName[CLIENT_ID_LEN - 1] = '\0';
315 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Info" ) == 0 )
317 03d971d9 2002-01-02 alex /* Server-Info-Text */
318 10363b39 2002-03-03 alex strncpy( Conf_ServerInfo, Arg, CLIENT_INFO_LEN - 1 );
319 03d971d9 2002-01-02 alex Conf_ServerInfo[CLIENT_INFO_LEN - 1] = '\0';
322 ed406b4a 2002-01-03 alex if( strcasecmp( Var, "Password" ) == 0 )
324 10363b39 2002-03-03 alex /* Server-Passwort */
325 10363b39 2002-03-03 alex strncpy( Conf_ServerPwd, Arg, CLIENT_PASS_LEN - 1 );
326 ed406b4a 2002-01-03 alex Conf_ServerPwd[CLIENT_PASS_LEN - 1] = '\0';
329 b615d128 2002-09-16 alex if( strcasecmp( Var, "AdminInfo1" ) == 0 )
331 b615d128 2002-09-16 alex /* Server-Info-Text */
332 b615d128 2002-09-16 alex strncpy( Conf_ServerAdmin1, Arg, CLIENT_INFO_LEN - 1 );
333 b615d128 2002-09-16 alex Conf_ServerAdmin1[CLIENT_INFO_LEN - 1] = '\0';
336 b615d128 2002-09-16 alex if( strcasecmp( Var, "AdminInfo2" ) == 0 )
338 b615d128 2002-09-16 alex /* Server-Info-Text */
339 b615d128 2002-09-16 alex strncpy( Conf_ServerAdmin2, Arg, CLIENT_INFO_LEN - 1 );
340 b615d128 2002-09-16 alex Conf_ServerAdmin2[CLIENT_INFO_LEN - 1] = '\0';
343 b615d128 2002-09-16 alex if( strcasecmp( Var, "AdminEMail" ) == 0 )
345 b615d128 2002-09-16 alex /* Server-Info-Text */
346 b615d128 2002-09-16 alex strncpy( Conf_ServerAdminMail, Arg, CLIENT_INFO_LEN - 1 );
347 b615d128 2002-09-16 alex Conf_ServerAdminMail[CLIENT_INFO_LEN - 1] = '\0';
350 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Ports" ) == 0 )
352 03d971d9 2002-01-02 alex /* Ports, durch "," getrennt, auf denen der Server
353 03d971d9 2002-01-02 alex * Verbindungen annehmen soll */
354 03d971d9 2002-01-02 alex ptr = strtok( Arg, "," );
355 03d971d9 2002-01-02 alex while( ptr )
357 03d971d9 2002-01-02 alex ngt_TrimStr( ptr );
358 03d971d9 2002-01-02 alex port = atol( ptr );
359 f86083a0 2002-03-27 alex if( Conf_ListenPorts_Count + 1 > MAX_LISTEN_PORTS ) Config_Error( LOG_ERR, "Too many listen ports configured. Port %ld ignored.", port );
362 1c2d0ae5 2002-03-29 alex if( port > 0 && port < 0xFFFF ) Conf_ListenPorts[Conf_ListenPorts_Count++] = (UINT)port;
363 f86083a0 2002-03-27 alex else Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Illegal port number %ld!", NGIRCd_ConfFile, Line, port );
365 03d971d9 2002-01-02 alex ptr = strtok( NULL, "," );
369 03d971d9 2002-01-02 alex if( strcasecmp( Var, "MotdFile" ) == 0 )
371 03d971d9 2002-01-02 alex /* Datei mit der "message of the day" (MOTD) */
372 10363b39 2002-03-03 alex strncpy( Conf_MotdFile, Arg, FNAME_LEN - 1 );
373 03d971d9 2002-01-02 alex Conf_MotdFile[FNAME_LEN - 1] = '\0';
376 1c2d0ae5 2002-03-29 alex if( strcasecmp( Var, "ServerUID" ) == 0 )
378 1c2d0ae5 2002-03-29 alex /* UID, mit der der Daemon laufen soll */
379 1c2d0ae5 2002-03-29 alex Conf_UID = (UINT)atoi( Arg );
382 1c2d0ae5 2002-03-29 alex if( strcasecmp( Var, "ServerGID" ) == 0 )
384 1c2d0ae5 2002-03-29 alex /* GID, mit der der Daemon laufen soll */
385 1c2d0ae5 2002-03-29 alex Conf_GID = (UINT)atoi( Arg );
388 03d971d9 2002-01-02 alex if( strcasecmp( Var, "PingTimeout" ) == 0 )
390 03d971d9 2002-01-02 alex /* PING-Timeout */
391 03d971d9 2002-01-02 alex Conf_PingTimeout = atoi( Arg );
392 03d971d9 2002-01-02 alex if(( Conf_PingTimeout ) < 5 ) Conf_PingTimeout = 5;
395 03d971d9 2002-01-02 alex if( strcasecmp( Var, "PongTimeout" ) == 0 )
397 03d971d9 2002-01-02 alex /* PONG-Timeout */
398 03d971d9 2002-01-02 alex Conf_PongTimeout = atoi( Arg );
399 03d971d9 2002-01-02 alex if(( Conf_PongTimeout ) < 5 ) Conf_PongTimeout = 5;
402 03d971d9 2002-01-02 alex if( strcasecmp( Var, "ConnectRetry" ) == 0 )
404 03d971d9 2002-01-02 alex /* Sekunden zwischen Verbindungsversuchen zu anderen Servern */
405 03d971d9 2002-01-02 alex Conf_ConnectRetry = atoi( Arg );
406 03d971d9 2002-01-02 alex if(( Conf_ConnectRetry ) < 5 ) Conf_ConnectRetry = 5;
409 7e1b3b91 2002-09-02 alex if( strcasecmp( Var, "OperCanUseMode" ) == 0 )
411 7e1b3b91 2002-09-02 alex /* Koennen IRC-Operatoren immer MODE benutzen? */
412 7e1b3b91 2002-09-02 alex if( strcasecmp( Arg, "yes" ) == 0 ) Conf_OperCanMode = TRUE;
413 7e1b3b91 2002-09-02 alex else if( strcasecmp( Arg, "true" ) == 0 ) Conf_OperCanMode = TRUE;
414 7e1b3b91 2002-09-02 alex else if( atoi( Arg ) != 0 ) Conf_OperCanMode = TRUE;
415 7e1b3b91 2002-09-02 alex else Conf_OperCanMode = FALSE;
418 0d32a3b4 2002-11-02 alex if( strcasecmp( Var, "MaxConnections" ) == 0 )
420 0d32a3b4 2002-11-02 alex /* Maximale Anzahl von Verbindungen. Werte <= 0 stehen
421 0d32a3b4 2002-11-02 alex * fuer "kein Limit". */
422 0d32a3b4 2002-11-02 alex Conf_MaxConnections = atol( Arg );
426 f86083a0 2002-03-27 alex Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
427 03d971d9 2002-01-02 alex } /* Handle_GLOBAL */
431 c2f60abe 2002-05-27 alex Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg )
433 03d971d9 2002-01-02 alex assert( Line > 0 );
434 03d971d9 2002-01-02 alex assert( Var != NULL );
435 03d971d9 2002-01-02 alex assert( Arg != NULL );
436 03d971d9 2002-01-02 alex assert( Conf_Oper_Count > 0 );
438 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Name" ) == 0 )
440 03d971d9 2002-01-02 alex /* Name des IRC Operator */
441 b615d128 2002-09-16 alex strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_PASS_LEN - 1 );
442 b615d128 2002-09-16 alex Conf_Oper[Conf_Oper_Count - 1].name[CLIENT_PASS_LEN - 1] = '\0';
445 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Password" ) == 0 )
447 03d971d9 2002-01-02 alex /* Passwort des IRC Operator */
448 10363b39 2002-03-03 alex strncpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 );
449 03d971d9 2002-01-02 alex Conf_Oper[Conf_Oper_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0';
453 f86083a0 2002-03-27 alex Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
454 03d971d9 2002-01-02 alex } /* Handle_OPERATOR */
458 c2f60abe 2002-05-27 alex Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
462 03d971d9 2002-01-02 alex assert( Line > 0 );
463 03d971d9 2002-01-02 alex assert( Var != NULL );
464 03d971d9 2002-01-02 alex assert( Arg != NULL );
466 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Host" ) == 0 )
468 03d971d9 2002-01-02 alex /* Hostname des Servers */
469 10363b39 2002-03-03 alex strncpy( Conf_Server[Conf_Server_Count - 1].host, Arg, HOST_LEN - 1 );
470 03d971d9 2002-01-02 alex Conf_Server[Conf_Server_Count - 1].host[HOST_LEN - 1] = '\0';
473 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Name" ) == 0 )
475 03d971d9 2002-01-02 alex /* Name des Servers ("Nick") */
476 10363b39 2002-03-03 alex strncpy( Conf_Server[Conf_Server_Count - 1].name, Arg, CLIENT_ID_LEN - 1 );
477 2e289b50 2002-01-05 alex Conf_Server[Conf_Server_Count - 1].name[CLIENT_ID_LEN - 1] = '\0';
480 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Password" ) == 0 )
482 03d971d9 2002-01-02 alex /* Passwort des Servers */
483 10363b39 2002-03-03 alex strncpy( Conf_Server[Conf_Server_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 );
484 03d971d9 2002-01-02 alex Conf_Server[Conf_Server_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0';
487 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Port" ) == 0 )
489 03d971d9 2002-01-02 alex /* Port, zu dem Verbunden werden soll */
490 03d971d9 2002-01-02 alex port = atol( Arg );
491 d67d94ea 2002-03-10 alex if( port > 0 && port < 0xFFFF ) Conf_Server[Conf_Server_Count - 1].port = (INT)port;
492 f86083a0 2002-03-27 alex else Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Illegal port number %ld!", NGIRCd_ConfFile, Line, port );
495 d67d94ea 2002-03-10 alex if( strcasecmp( Var, "Group" ) == 0 )
497 d67d94ea 2002-03-10 alex /* Server-Gruppe */
498 d67d94ea 2002-03-10 alex Conf_Server[Conf_Server_Count - 1].group = atoi( Arg );
502 f86083a0 2002-03-27 alex Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
503 03d971d9 2002-01-02 alex } /* Handle_SERVER */
507 c2f60abe 2002-05-27 alex Handle_CHANNEL( INT Line, CHAR *Var, CHAR *Arg )
509 040f5422 2002-05-21 alex assert( Line > 0 );
510 040f5422 2002-05-21 alex assert( Var != NULL );
511 040f5422 2002-05-21 alex assert( Arg != NULL );
513 040f5422 2002-05-21 alex if( strcasecmp( Var, "Name" ) == 0 )
515 040f5422 2002-05-21 alex /* Hostname des Servers */
516 040f5422 2002-05-21 alex strncpy( Conf_Channel[Conf_Channel_Count - 1].name, Arg, CHANNEL_NAME_LEN - 1 );
517 040f5422 2002-05-21 alex Conf_Channel[Conf_Channel_Count - 1].name[CHANNEL_NAME_LEN - 1] = '\0';
520 040f5422 2002-05-21 alex if( strcasecmp( Var, "Modes" ) == 0 )
522 040f5422 2002-05-21 alex /* Name des Servers ("Nick") */
523 040f5422 2002-05-21 alex strncpy( Conf_Channel[Conf_Channel_Count - 1].modes, Arg, CHANNEL_MODE_LEN - 1 );
524 040f5422 2002-05-21 alex Conf_Channel[Conf_Channel_Count - 1].modes[CHANNEL_MODE_LEN - 1] = '\0';
527 040f5422 2002-05-21 alex if( strcasecmp( Var, "Topic" ) == 0 )
529 040f5422 2002-05-21 alex /* Passwort des Servers */
530 040f5422 2002-05-21 alex strncpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, CHANNEL_TOPIC_LEN - 1 );
531 040f5422 2002-05-21 alex Conf_Channel[Conf_Channel_Count - 1].topic[CHANNEL_TOPIC_LEN - 1] = '\0';
535 040f5422 2002-05-21 alex Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
536 040f5422 2002-05-21 alex } /* Handle_CHANNEL */
540 c2f60abe 2002-05-27 alex Validate_Config( VOID )
542 9856253d 2001-12-30 alex /* Konfiguration ueberpruefen */
544 9856253d 2001-12-30 alex if( ! Conf_ServerName[0] )
546 9856253d 2001-12-30 alex /* Kein Servername konfiguriert */
547 b615d128 2002-09-16 alex Config_Error( LOG_ALERT, "No server name configured in \"%s\" ('ServerName')!", NGIRCd_ConfFile );
548 f7327524 2002-05-30 alex Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
552 b615d128 2002-09-16 alex #ifdef STRICT_RFC
553 12cad28e 2002-10-21 alex if( ! Conf_ServerAdminMail[0] )
555 b615d128 2002-09-16 alex /* Keine Server-Information konfiguriert */
556 b615d128 2002-09-16 alex Config_Error( LOG_ALERT, "No administrator email address configured in \"%s\" ('AdminEMail')!", NGIRCd_ConfFile );
557 b615d128 2002-09-16 alex Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
562 33bda862 2002-09-19 alex if( ! Conf_ServerAdmin1[0] && ! Conf_ServerAdmin2[0] && ! Conf_ServerAdminMail[0] )
564 b615d128 2002-09-16 alex /* Keine Server-Information konfiguriert */
565 b615d128 2002-09-16 alex Log( LOG_WARNING, "No server information configured but required by RFC!" );
567 9856253d 2001-12-30 alex } /* Validate_Config */
570 f7327524 2002-05-30 alex #ifdef PROTOTYPES
571 f7327524 2002-05-30 alex LOCAL VOID Config_Error( CONST INT Level, CONST CHAR *Format, ... )
573 f7327524 2002-05-30 alex LOCAL VOID Config_Error( Level, Format, va_alist )
574 f7327524 2002-05-30 alex CONST INT Level;
575 f7327524 2002-05-30 alex CONST CHAR *Format;
579 f86083a0 2002-03-27 alex /* Fehler! Auf Console und/oder ins Log schreiben */
581 f86083a0 2002-03-27 alex CHAR msg[MAX_LOG_MSG_LEN];
582 f86083a0 2002-03-27 alex va_list ap;
584 f86083a0 2002-03-27 alex assert( Format != NULL );
586 f86083a0 2002-03-27 alex /* String mit variablen Argumenten zusammenbauen ... */
587 f7327524 2002-05-30 alex #ifdef PROTOTYPES
588 f86083a0 2002-03-27 alex va_start( ap, Format );
590 f7327524 2002-05-30 alex va_start( ap );
592 f86083a0 2002-03-27 alex vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
593 f86083a0 2002-03-27 alex va_end( ap );
595 f86083a0 2002-03-27 alex /* Im "normalen Betrieb" soll der Log-Mechanismus des ngIRCd verwendet
596 f86083a0 2002-03-27 alex * werden, beim Testen der Konfiguration jedoch nicht, hier sollen alle
597 f86083a0 2002-03-27 alex * Meldungen direkt auf die Konsole ausgegeben werden: */
598 ec474a4b 2002-10-04 alex if( Use_Log ) Log( Level, "%s", msg );
599 f86083a0 2002-03-27 alex else puts( msg );
600 f86083a0 2002-03-27 alex } /* Config_Error */
603 cbc1e59f 2001-12-12 alex /* -eof- */