2 cbc1e59f 2001-12-12 alex * ngIRCd -- The Next Generation IRC Daemon
3 6725d789 2002-12-12 alex * Copyright (c)2001,2002 Alexander Barton (alex@barton.de)
5 6725d789 2002-12-12 alex * This program is free software; you can redistribute it and/or modify
6 6725d789 2002-12-12 alex * it under the terms of the GNU General Public License as published by
7 6725d789 2002-12-12 alex * the Free Software Foundation; either version 2 of the License, or
8 6725d789 2002-12-12 alex * (at your option) any later version.
9 6725d789 2002-12-12 alex * Please read the file COPYING, README and AUTHORS for more information.
11 6725d789 2002-12-12 alex * Configuration management (reading, parsing & validation)
15 ca33cbda 2002-03-12 alex #include "portab.h"
17 281f7583 2002-12-31 alex static char UNUSED id[] = "$Id: conf.c,v 1.53 2002/12/31 16:12:50 alex Exp $";
19 ca33cbda 2002-03-12 alex #include "imp.h"
20 cbc1e59f 2001-12-12 alex #include <assert.h>
21 9856253d 2001-12-30 alex #include <errno.h>
22 f86083a0 2002-03-27 alex #include <stdarg.h>
23 9856253d 2001-12-30 alex #include <stdio.h>
24 b20fa7c6 2002-01-01 alex #include <stdlib.h>
25 9856253d 2001-12-30 alex #include <string.h>
26 f86083a0 2002-03-27 alex #include <unistd.h>
27 ae39724a 2002-11-08 alex #include <pwd.h>
28 ae39724a 2002-11-08 alex #include <grp.h>
29 ae39724a 2002-11-08 alex #include <sys/types.h>
30 b7be46ed 2002-12-18 alex #include <unistd.h>
32 2e02da29 2002-11-30 alex #ifdef HAVE_CTYPE_H
33 2e02da29 2002-11-30 alex # include <ctype.h>
36 f86083a0 2002-03-27 alex #include "ngircd.h"
37 c2f60abe 2002-05-27 alex #include "conn.h"
38 9856253d 2001-12-30 alex #include "client.h"
39 ca33cbda 2002-03-12 alex #include "defines.h"
40 9856253d 2001-12-30 alex #include "log.h"
41 c2f60abe 2002-05-27 alex #include "resolve.h"
42 9856253d 2001-12-30 alex #include "tool.h"
44 ca33cbda 2002-03-12 alex #include "exp.h"
45 cbc1e59f 2001-12-12 alex #include "conf.h"
48 f86083a0 2002-03-27 alex LOCAL BOOLEAN Use_Log = TRUE;
49 a2544e49 2002-12-30 alex LOCAL CONF_SERVER New_Server;
50 a2544e49 2002-12-30 alex LOCAL INT New_Server_Idx;
53 a2544e49 2002-12-30 alex LOCAL VOID Set_Defaults PARAMS(( BOOLEAN InitServers ));
54 c2f60abe 2002-05-27 alex LOCAL VOID Read_Config PARAMS(( VOID ));
55 b7be46ed 2002-12-18 alex LOCAL VOID Validate_Config PARAMS(( BOOLEAN TestOnly ));
57 c2f60abe 2002-05-27 alex LOCAL VOID Handle_GLOBAL PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
58 c2f60abe 2002-05-27 alex LOCAL VOID Handle_OPERATOR PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
59 c2f60abe 2002-05-27 alex LOCAL VOID Handle_SERVER PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
60 c2f60abe 2002-05-27 alex LOCAL VOID Handle_CHANNEL PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
62 c2f60abe 2002-05-27 alex LOCAL VOID Config_Error PARAMS(( CONST INT Level, CONST CHAR *Format, ... ));
64 a2544e49 2002-12-30 alex LOCAL VOID Init_Server_Struct PARAMS(( CONF_SERVER *Server ));
68 c2f60abe 2002-05-27 alex Conf_Init( VOID )
70 a2544e49 2002-12-30 alex Set_Defaults( TRUE );
71 f86083a0 2002-03-27 alex Read_Config( );
72 b7be46ed 2002-12-18 alex Validate_Config( FALSE );
73 f86083a0 2002-03-27 alex } /* Config_Init */
77 a2544e49 2002-12-30 alex Conf_Rehash( VOID )
79 a2544e49 2002-12-30 alex Set_Defaults( FALSE );
80 a2544e49 2002-12-30 alex Read_Config( );
81 a2544e49 2002-12-30 alex Validate_Config( FALSE );
82 a2544e49 2002-12-30 alex } /* Config_Rehash */
86 c2f60abe 2002-05-27 alex Conf_Test( VOID )
88 6725d789 2002-12-12 alex /* Read configuration, validate and output it. */
90 ae39724a 2002-11-08 alex struct passwd *pwd;
91 ae39724a 2002-11-08 alex struct group *grp;
94 f86083a0 2002-03-27 alex Use_Log = FALSE;
95 a2544e49 2002-12-30 alex Set_Defaults( TRUE );
97 f86083a0 2002-03-27 alex Read_Config( );
98 b7be46ed 2002-12-18 alex Validate_Config( TRUE );
100 6725d789 2002-12-12 alex /* If stdin is a valid tty wait for a key: */
101 f86083a0 2002-03-27 alex if( isatty( fileno( stdout )))
103 f86083a0 2002-03-27 alex puts( "OK, press enter to see a dump of your service configuration ..." );
104 f86083a0 2002-03-27 alex getchar( );
106 f86083a0 2002-03-27 alex else puts( "Ok, dump of your server configuration follows:\n" );
108 f86083a0 2002-03-27 alex puts( "[GLOBAL]" );
109 f86083a0 2002-03-27 alex printf( " ServerName = %s\n", Conf_ServerName );
110 f86083a0 2002-03-27 alex printf( " ServerInfo = %s\n", Conf_ServerInfo );
111 f86083a0 2002-03-27 alex printf( " ServerPwd = %s\n", Conf_ServerPwd );
112 b615d128 2002-09-16 alex printf( " AdminInfo1 = %s\n", Conf_ServerAdmin1 );
113 b615d128 2002-09-16 alex printf( " AdminInfo2 = %s\n", Conf_ServerAdmin2 );
114 b615d128 2002-09-16 alex printf( " AdminEMail = %s\n", Conf_ServerAdminMail );
115 f86083a0 2002-03-27 alex printf( " MotdFile = %s\n", Conf_MotdFile );
116 7bbdfb3d 2002-11-18 alex printf( " Ports = " );
117 f86083a0 2002-03-27 alex for( i = 0; i < Conf_ListenPorts_Count; i++ )
119 f86083a0 2002-03-27 alex if( i != 0 ) printf( ", " );
120 1c2d0ae5 2002-03-29 alex printf( "%u", Conf_ListenPorts[i] );
122 1c2d0ae5 2002-03-29 alex puts( "" );
123 ae39724a 2002-11-08 alex pwd = getpwuid( Conf_UID );
124 ae39724a 2002-11-08 alex if( pwd ) printf( " ServerUID = %s\n", pwd->pw_name );
125 ae39724a 2002-11-08 alex else printf( " ServerUID = %ld\n", (LONG)Conf_UID );
126 ae39724a 2002-11-08 alex grp = getgrgid( Conf_GID );
127 ae39724a 2002-11-08 alex if( grp ) printf( " ServerGID = %s\n", grp->gr_name );
128 ae39724a 2002-11-08 alex else printf( " ServerGID = %ld\n", (LONG)Conf_GID );
129 f86083a0 2002-03-27 alex printf( " PingTimeout = %d\n", Conf_PingTimeout );
130 f86083a0 2002-03-27 alex printf( " PongTimeout = %d\n", Conf_PongTimeout );
131 f86083a0 2002-03-27 alex printf( " ConnectRetry = %d\n", Conf_ConnectRetry );
132 7e1b3b91 2002-09-02 alex printf( " OperCanUseMode = %s\n", Conf_OperCanMode == TRUE ? "yes" : "no" );
133 0d32a3b4 2002-11-02 alex if( Conf_MaxConnections > 0 ) printf( " MaxConnections = %ld\n", Conf_MaxConnections );
134 0d32a3b4 2002-11-02 alex else printf( " MaxConnections = -1\n" );
135 8b7b23cf 2002-12-13 alex if( Conf_MaxJoins > 0 ) printf( " MaxJoins = %d\n", Conf_MaxJoins );
136 8b7b23cf 2002-12-13 alex else printf( " MaxJoins = -1\n" );
137 f86083a0 2002-03-27 alex puts( "" );
139 f86083a0 2002-03-27 alex for( i = 0; i < Conf_Oper_Count; i++ )
141 c23535bc 2002-05-22 alex if( ! Conf_Oper[i].name[0] ) continue;
143 6725d789 2002-12-12 alex /* Valid "Operator" section */
144 f86083a0 2002-03-27 alex puts( "[OPERATOR]" );
145 f86083a0 2002-03-27 alex printf( " Name = %s\n", Conf_Oper[i].name );
146 f86083a0 2002-03-27 alex printf( " Password = %s\n", Conf_Oper[i].pwd );
147 f86083a0 2002-03-27 alex puts( "" );
150 a2544e49 2002-12-30 alex for( i = 0; i < MAX_SERVERS; i++ )
152 c23535bc 2002-05-22 alex if( ! Conf_Server[i].name[0] ) continue;
154 6725d789 2002-12-12 alex /* Valid "Server" section */
155 f86083a0 2002-03-27 alex puts( "[SERVER]" );
156 f86083a0 2002-03-27 alex printf( " Name = %s\n", Conf_Server[i].name );
157 f86083a0 2002-03-27 alex printf( " Host = %s\n", Conf_Server[i].host );
158 f86083a0 2002-03-27 alex printf( " Port = %d\n", Conf_Server[i].port );
159 b2615bcc 2002-11-19 alex printf( " MyPassword = %s\n", Conf_Server[i].pwd_in );
160 b2615bcc 2002-11-19 alex printf( " PeerPassword = %s\n", Conf_Server[i].pwd_out );
161 f86083a0 2002-03-27 alex printf( " Group = %d\n", Conf_Server[i].group );
162 f86083a0 2002-03-27 alex puts( "" );
165 040f5422 2002-05-21 alex for( i = 0; i < Conf_Channel_Count; i++ )
167 c23535bc 2002-05-22 alex if( ! Conf_Channel[i].name[0] ) continue;
169 6725d789 2002-12-12 alex /* Valid "Channel" section */
170 040f5422 2002-05-21 alex puts( "[CHANNEL]" );
171 040f5422 2002-05-21 alex printf( " Name = %s\n", Conf_Channel[i].name );
172 040f5422 2002-05-21 alex printf( " Modes = %s\n", Conf_Channel[i].modes );
173 040f5422 2002-05-21 alex printf( " Topic = %s\n", Conf_Channel[i].topic );
174 040f5422 2002-05-21 alex puts( "" );
178 f86083a0 2002-03-27 alex } /* Conf_Test */
181 a2544e49 2002-12-30 alex GLOBAL VOID
182 a2544e49 2002-12-30 alex Conf_UnsetServer( CONN_ID Idx )
184 a2544e49 2002-12-30 alex /* Set next time for next connection attempt, if this is a server
185 a2544e49 2002-12-30 alex * link that is (still) configured here. If the server is set as
186 a2544e49 2002-12-30 alex * "once", delete it from our configuration.
187 a2544e49 2002-12-30 alex * Non-Server-Connections will be silently ignored. */
191 a2544e49 2002-12-30 alex /* Check all our configured servers */
192 a2544e49 2002-12-30 alex for( i = 0; i < MAX_SERVERS; i++ )
194 a2544e49 2002-12-30 alex if( Conf_Server[i].conn_id != Idx ) continue;
196 a2544e49 2002-12-30 alex /* Gotcha! Mark server configuration as "unused": */
197 a2544e49 2002-12-30 alex Conf_Server[i].conn_id = NONE;
199 281f7583 2002-12-31 alex if( Conf_Server[i].flags & CONF_SFLAG_ONCE )
201 a2544e49 2002-12-30 alex /* Delete configuration here */
202 a2544e49 2002-12-30 alex Init_Server_Struct( &Conf_Server[i] );
206 a2544e49 2002-12-30 alex /* Set time for next connect attempt */
207 a2544e49 2002-12-30 alex if( Conf_Server[i].lasttry < time( NULL ) - Conf_ConnectRetry )
209 a2544e49 2002-12-30 alex /* Okay, the connection was established "long enough": */
210 a2544e49 2002-12-30 alex Conf_Server[i].lasttry = time( NULL ) - Conf_ConnectRetry + RECONNECT_DELAY;
215 a2544e49 2002-12-30 alex } /* Conf_UnsetServer */
218 a2544e49 2002-12-30 alex GLOBAL VOID
219 a2544e49 2002-12-30 alex Conf_SetServer( INT ConfServer, CONN_ID Idx )
221 a2544e49 2002-12-30 alex /* Set connection for specified configured server */
223 a2544e49 2002-12-30 alex assert( ConfServer > NONE );
224 a2544e49 2002-12-30 alex assert( Idx > NONE );
226 a2544e49 2002-12-30 alex Conf_Server[ConfServer].conn_id = Idx;
227 a2544e49 2002-12-30 alex } /* Conf_SetServer */
231 a2544e49 2002-12-30 alex Conf_GetServer( CONN_ID Idx )
233 a2544e49 2002-12-30 alex /* Get index of server in configuration structure */
237 a2544e49 2002-12-30 alex assert( Idx > NONE );
239 a2544e49 2002-12-30 alex for( i = 0; i < MAX_SERVERS; i++ )
241 a2544e49 2002-12-30 alex if( Conf_Server[i].conn_id == Idx ) return i;
243 a2544e49 2002-12-30 alex return NONE;
244 a2544e49 2002-12-30 alex } /* Conf_GetServer */
247 281f7583 2002-12-31 alex GLOBAL BOOLEAN
248 281f7583 2002-12-31 alex Conf_EnableServer( CHAR *Name, INT Port )
250 281f7583 2002-12-31 alex /* Enable specified server and adjust port */
254 281f7583 2002-12-31 alex assert( Name != NULL );
256 281f7583 2002-12-31 alex for( i = 0; i < MAX_SERVERS; i++ )
258 281f7583 2002-12-31 alex if( strcasecmp( Conf_Server[i].name, Name ) == 0 )
260 281f7583 2002-12-31 alex /* Gotcha! Set port and enable server: */
261 281f7583 2002-12-31 alex Conf_Server[i].port = Port;
262 281f7583 2002-12-31 alex Conf_Server[i].flags &= ~CONF_SFLAG_DISABLED;
263 281f7583 2002-12-31 alex return TRUE;
266 281f7583 2002-12-31 alex return FALSE;
267 281f7583 2002-12-31 alex } /* Conf_EnableServer */
270 281f7583 2002-12-31 alex GLOBAL BOOLEAN
271 281f7583 2002-12-31 alex Conf_DisableServer( CHAR *Name )
273 281f7583 2002-12-31 alex /* Enable specified server and adjust port */
277 281f7583 2002-12-31 alex assert( Name != NULL );
279 281f7583 2002-12-31 alex for( i = 0; i < MAX_SERVERS; i++ )
281 281f7583 2002-12-31 alex if( strcasecmp( Conf_Server[i].name, Name ) == 0 )
283 281f7583 2002-12-31 alex /* Gotcha! Disable and disconnect server: */
284 281f7583 2002-12-31 alex Conf_Server[i].flags |= CONF_SFLAG_DISABLED;
285 281f7583 2002-12-31 alex if( Conf_Server[i].conn_id > NONE ) Conn_Close( Conf_Server[i].conn_id, NULL, "Server link terminated on operator request", TRUE );
286 281f7583 2002-12-31 alex return TRUE;
289 281f7583 2002-12-31 alex return FALSE;
290 281f7583 2002-12-31 alex } /* Conf_DisableServer */
293 281f7583 2002-12-31 alex GLOBAL BOOLEAN
294 281f7583 2002-12-31 alex Conf_AddServer( CHAR *Name, INT Port, CHAR *Host, CHAR *MyPwd, CHAR *PeerPwd )
296 281f7583 2002-12-31 alex /* Add new server to configuration */
300 281f7583 2002-12-31 alex assert( Name != NULL );
301 281f7583 2002-12-31 alex assert( Host != NULL );
302 281f7583 2002-12-31 alex assert( MyPwd != NULL );
303 281f7583 2002-12-31 alex assert( PeerPwd != NULL );
305 281f7583 2002-12-31 alex /* Search unused item in server configuration structure */
306 281f7583 2002-12-31 alex for( i = 0; i < MAX_SERVERS; i++ )
308 281f7583 2002-12-31 alex /* Is this item used? */
309 281f7583 2002-12-31 alex if( ! Conf_Server[i].name[0] ) break;
311 281f7583 2002-12-31 alex if( i >= MAX_SERVERS ) return FALSE;
313 281f7583 2002-12-31 alex Init_Server_Struct( &Conf_Server[i] );
314 281f7583 2002-12-31 alex strlcpy( Conf_Server[i].name, Name, sizeof( Conf_Server[i].name ));
315 281f7583 2002-12-31 alex strlcpy( Conf_Server[i].host, Host, sizeof( Conf_Server[i].host ));
316 281f7583 2002-12-31 alex strlcpy( Conf_Server[i].pwd_out, MyPwd, sizeof( Conf_Server[i].pwd_out ));
317 281f7583 2002-12-31 alex strlcpy( Conf_Server[i].pwd_in, PeerPwd, sizeof( Conf_Server[i].pwd_in ));
318 281f7583 2002-12-31 alex Conf_Server[i].port = Port;
319 281f7583 2002-12-31 alex Conf_Server[i].flags = CONF_SFLAG_ONCE;
321 281f7583 2002-12-31 alex return TRUE;
322 281f7583 2002-12-31 alex } /* Conf_AddServer */
326 a2544e49 2002-12-30 alex Set_Defaults( BOOLEAN InitServers )
328 6725d789 2002-12-12 alex /* Initialize configuration variables with default values. */
332 9856253d 2001-12-30 alex strcpy( Conf_ServerName, "" );
333 f7327524 2002-05-30 alex sprintf( Conf_ServerInfo, "%s %s", PACKAGE, VERSION );
334 ed406b4a 2002-01-03 alex strcpy( Conf_ServerPwd, "" );
336 b615d128 2002-09-16 alex strcpy( Conf_ServerAdmin1, "" );
337 b615d128 2002-09-16 alex strcpy( Conf_ServerAdmin2, "" );
338 b615d128 2002-09-16 alex strcpy( Conf_ServerAdminMail, "" );
340 6626395c 2002-12-26 alex strlcpy( Conf_MotdFile, SYSCONFDIR, sizeof( Conf_MotdFile ));
341 6626395c 2002-12-26 alex strlcat( Conf_MotdFile, MOTD_FILE, sizeof( Conf_MotdFile ));
343 9856253d 2001-12-30 alex Conf_ListenPorts_Count = 0;
345 1c2d0ae5 2002-03-29 alex Conf_UID = Conf_GID = 0;
347 08cf5607 2001-12-26 alex Conf_PingTimeout = 120;
348 281d8e45 2002-03-25 alex Conf_PongTimeout = 20;
350 03d971d9 2002-01-02 alex Conf_ConnectRetry = 60;
352 03d971d9 2002-01-02 alex Conf_Oper_Count = 0;
353 040f5422 2002-05-21 alex Conf_Channel_Count = 0;
355 7e1b3b91 2002-09-02 alex Conf_OperCanMode = FALSE;
357 8b7b23cf 2002-12-13 alex Conf_MaxConnections = -1;
358 8b7b23cf 2002-12-13 alex Conf_MaxJoins = 10;
360 a2544e49 2002-12-30 alex /* Initialize server configuration structures */
361 a2544e49 2002-12-30 alex if( InitServers ) for( i = 0; i < MAX_SERVERS; Init_Server_Struct( &Conf_Server[i++] ));
362 f86083a0 2002-03-27 alex } /* Set_Defaults */
366 c2f60abe 2002-05-27 alex Read_Config( VOID )
368 6725d789 2002-12-12 alex /* Read configuration file. */
370 03d971d9 2002-01-02 alex CHAR section[LINE_LEN], str[LINE_LEN], *var, *arg, *ptr;
371 a2544e49 2002-12-30 alex INT line, i;
374 a2544e49 2002-12-30 alex /* Open configuration file */
375 f86083a0 2002-03-27 alex fd = fopen( NGIRCd_ConfFile, "r" );
378 6725d789 2002-12-12 alex /* No configuration file found! */
379 f86083a0 2002-03-27 alex Config_Error( LOG_ALERT, "Can't read configuration \"%s\": %s", NGIRCd_ConfFile, strerror( errno ));
380 f7327524 2002-05-30 alex Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
384 03ec91f9 2002-11-22 alex Config_Error( LOG_INFO, "Reading configuration from \"%s\" ...", NGIRCd_ConfFile );
386 a2544e49 2002-12-30 alex /* Clean up server configuration structure: mark all already
387 a2544e49 2002-12-30 alex * configured servers as "once" so that they are deleted
388 a2544e49 2002-12-30 alex * after the next disconnect and delete all unused servers. */
389 a2544e49 2002-12-30 alex for( i = 0; i < MAX_SERVERS; i++ )
391 a2544e49 2002-12-30 alex if( Conf_Server[i].conn_id == NONE ) Init_Server_Struct( &Conf_Server[i] );
392 281f7583 2002-12-31 alex else Conf_Server[i].flags |= CONF_SFLAG_ONCE;
395 a2544e49 2002-12-30 alex /* Initialize variables */
397 03d971d9 2002-01-02 alex strcpy( section, "" );
398 a2544e49 2002-12-30 alex Init_Server_Struct( &New_Server );
399 a2544e49 2002-12-30 alex New_Server_Idx = NONE;
401 a2544e49 2002-12-30 alex /* Read configuration file */
402 9856253d 2001-12-30 alex while( TRUE )
404 804b1ec4 2001-12-31 alex if( ! fgets( str, LINE_LEN, fd )) break;
405 9856253d 2001-12-30 alex ngt_TrimStr( str );
408 6725d789 2002-12-12 alex /* Skip comments and empty lines */
409 9856253d 2001-12-30 alex if( str[0] == ';' || str[0] == '#' || str[0] == '\0' ) continue;
411 6725d789 2002-12-12 alex /* Is this the beginning of a new section? */
412 03d971d9 2002-01-02 alex if(( str[0] == '[' ) && ( str[strlen( str ) - 1] == ']' ))
414 695631b2 2002-12-26 alex strlcpy( section, str, sizeof( section ));
415 03d971d9 2002-01-02 alex if( strcasecmp( section, "[GLOBAL]" ) == 0 ) continue;
416 03d971d9 2002-01-02 alex if( strcasecmp( section, "[OPERATOR]" ) == 0 )
418 f86083a0 2002-03-27 alex if( Conf_Oper_Count + 1 > MAX_OPERATORS ) Config_Error( LOG_ERR, "Too many operators configured." );
421 6725d789 2002-12-12 alex /* Initialize new operator structure */
422 03d971d9 2002-01-02 alex strcpy( Conf_Oper[Conf_Oper_Count].name, "" );
423 03d971d9 2002-01-02 alex strcpy( Conf_Oper[Conf_Oper_Count].pwd, "" );
424 03d971d9 2002-01-02 alex Conf_Oper_Count++;
428 03d971d9 2002-01-02 alex if( strcasecmp( section, "[SERVER]" ) == 0 )
430 a2544e49 2002-12-30 alex /* Check if there is already a server to add */
431 a2544e49 2002-12-30 alex if( New_Server.name[0] )
433 a2544e49 2002-12-30 alex /* Copy data to "real" server structure */
434 a2544e49 2002-12-30 alex assert( New_Server_Idx > NONE );
435 a2544e49 2002-12-30 alex Conf_Server[New_Server_Idx] = New_Server;
438 a2544e49 2002-12-30 alex /* Re-init structure for new server */
439 a2544e49 2002-12-30 alex Init_Server_Struct( &New_Server );
441 a2544e49 2002-12-30 alex /* Search unused item in server configuration structure */
442 a2544e49 2002-12-30 alex for( i = 0; i < MAX_SERVERS; i++ )
444 a2544e49 2002-12-30 alex /* Is this item used? */
445 a2544e49 2002-12-30 alex if( ! Conf_Server[i].name[0] ) break;
447 a2544e49 2002-12-30 alex if( i >= MAX_SERVERS )
449 a2544e49 2002-12-30 alex /* Oops, no free item found! */
450 a2544e49 2002-12-30 alex Config_Error( LOG_ERR, "Too many servers configured." );
451 a2544e49 2002-12-30 alex New_Server_Idx = NONE;
453 a2544e49 2002-12-30 alex else New_Server_Idx = i;
456 040f5422 2002-05-21 alex if( strcasecmp( section, "[CHANNEL]" ) == 0 )
458 040f5422 2002-05-21 alex if( Conf_Channel_Count + 1 > MAX_DEFCHANNELS ) Config_Error( LOG_ERR, "Too many pre-defined channels configured." );
461 6725d789 2002-12-12 alex /* Initialize new channel structure */
462 040f5422 2002-05-21 alex strcpy( Conf_Channel[Conf_Channel_Count].name, "" );
463 040f5422 2002-05-21 alex strcpy( Conf_Channel[Conf_Channel_Count].modes, "" );
464 040f5422 2002-05-21 alex strcpy( Conf_Channel[Conf_Channel_Count].topic, "" );
465 040f5422 2002-05-21 alex Conf_Channel_Count++;
469 f86083a0 2002-03-27 alex Config_Error( LOG_ERR, "%s, line %d: Unknown section \"%s\"!", NGIRCd_ConfFile, line, section );
470 03d971d9 2002-01-02 alex section[0] = 0x1;
472 03d971d9 2002-01-02 alex if( section[0] == 0x1 ) continue;
474 6725d789 2002-12-12 alex /* Split line into variable name and parameters */
475 9856253d 2001-12-30 alex ptr = strchr( str, '=' );
476 9856253d 2001-12-30 alex if( ! ptr )
478 f86083a0 2002-03-27 alex Config_Error( LOG_ERR, "%s, line %d: Syntax error!", NGIRCd_ConfFile, line );
481 9856253d 2001-12-30 alex *ptr = '\0';
482 9856253d 2001-12-30 alex var = str; ngt_TrimStr( var );
483 9856253d 2001-12-30 alex arg = ptr + 1; ngt_TrimStr( arg );
485 03d971d9 2002-01-02 alex if( strcasecmp( section, "[GLOBAL]" ) == 0 ) Handle_GLOBAL( line, var, arg );
486 03d971d9 2002-01-02 alex else if( strcasecmp( section, "[OPERATOR]" ) == 0 ) Handle_OPERATOR( line, var, arg );
487 03d971d9 2002-01-02 alex else if( strcasecmp( section, "[SERVER]" ) == 0 ) Handle_SERVER( line, var, arg );
488 040f5422 2002-05-21 alex else if( strcasecmp( section, "[CHANNEL]" ) == 0 ) Handle_CHANNEL( line, var, arg );
489 f86083a0 2002-03-27 alex else Config_Error( LOG_ERR, "%s, line %d: Variable \"%s\" outside section!", NGIRCd_ConfFile, line, var );
492 a2544e49 2002-12-30 alex /* Close configuration file */
493 03d971d9 2002-01-02 alex fclose( fd );
495 a2544e49 2002-12-30 alex /* Check if there is still a server to add */
496 a2544e49 2002-12-30 alex if( New_Server.name[0] )
498 a2544e49 2002-12-30 alex /* Copy data to "real" server structure */
499 a2544e49 2002-12-30 alex assert( New_Server_Idx > NONE );
500 a2544e49 2002-12-30 alex Conf_Server[New_Server_Idx] = New_Server;
503 6725d789 2002-12-12 alex /* If there are no ports configured use the default: 6667 */
504 1c99b837 2002-03-30 alex if( Conf_ListenPorts_Count < 1 )
506 1c99b837 2002-03-30 alex Conf_ListenPorts_Count = 1;
507 1c99b837 2002-03-30 alex Conf_ListenPorts[0] = 6667;
509 03d971d9 2002-01-02 alex } /* Read_Config */
513 c2f60abe 2002-05-27 alex Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
515 ae39724a 2002-11-08 alex struct passwd *pwd;
516 ae39724a 2002-11-08 alex struct group *grp;
520 03d971d9 2002-01-02 alex assert( Line > 0 );
521 03d971d9 2002-01-02 alex assert( Var != NULL );
522 03d971d9 2002-01-02 alex assert( Arg != NULL );
524 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Name" ) == 0 )
526 6725d789 2002-12-12 alex /* Server name */
527 0ced4181 2002-12-26 alex if( strlcpy( Conf_ServerName, Arg, sizeof( Conf_ServerName )) >= sizeof( Conf_ServerName )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
530 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Info" ) == 0 )
532 6725d789 2002-12-12 alex /* Info text of server */
533 0ced4181 2002-12-26 alex if( strlcpy( Conf_ServerInfo, Arg, sizeof( Conf_ServerInfo )) >= sizeof( Conf_ServerInfo )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Info\" too long!", NGIRCd_ConfFile, Line );
536 ed406b4a 2002-01-03 alex if( strcasecmp( Var, "Password" ) == 0 )
538 6725d789 2002-12-12 alex /* Global server password */
539 0ced4181 2002-12-26 alex if( strlcpy( Conf_ServerPwd, Arg, sizeof( Conf_ServerPwd )) >= sizeof( Conf_ServerPwd )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Password\" too long!", NGIRCd_ConfFile, Line );
542 b615d128 2002-09-16 alex if( strcasecmp( Var, "AdminInfo1" ) == 0 )
544 6725d789 2002-12-12 alex /* Administrative info #1 */
545 0ced4181 2002-12-26 alex if( strlcpy( Conf_ServerAdmin1, Arg, sizeof( Conf_ServerAdmin1 )) >= sizeof( Conf_ServerAdmin1 )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"AdminInfo1\" too long!", NGIRCd_ConfFile, Line );
548 b615d128 2002-09-16 alex if( strcasecmp( Var, "AdminInfo2" ) == 0 )
550 6725d789 2002-12-12 alex /* Administrative info #2 */
551 0ced4181 2002-12-26 alex if( strlcpy( Conf_ServerAdmin2, Arg, sizeof( Conf_ServerAdmin2 )) >= sizeof( Conf_ServerAdmin2 )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"AdminInfo2\" too long!", NGIRCd_ConfFile, Line );
554 b615d128 2002-09-16 alex if( strcasecmp( Var, "AdminEMail" ) == 0 )
556 6725d789 2002-12-12 alex /* Administrative email contact */
557 0ced4181 2002-12-26 alex if( strlcpy( Conf_ServerAdminMail, Arg, sizeof( Conf_ServerAdminMail )) >= sizeof( Conf_ServerAdminMail )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"AdminEMail\" too long!", NGIRCd_ConfFile, Line );
560 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Ports" ) == 0 )
562 6725d789 2002-12-12 alex /* Ports on that the server should listen. More port numbers
563 6725d789 2002-12-12 alex * must be separated by "," */
564 03d971d9 2002-01-02 alex ptr = strtok( Arg, "," );
565 03d971d9 2002-01-02 alex while( ptr )
567 03d971d9 2002-01-02 alex ngt_TrimStr( ptr );
568 03d971d9 2002-01-02 alex port = atol( ptr );
569 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 );
572 1c2d0ae5 2002-03-29 alex if( port > 0 && port < 0xFFFF ) Conf_ListenPorts[Conf_ListenPorts_Count++] = (UINT)port;
573 f86083a0 2002-03-27 alex else Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Illegal port number %ld!", NGIRCd_ConfFile, Line, port );
575 03d971d9 2002-01-02 alex ptr = strtok( NULL, "," );
579 03d971d9 2002-01-02 alex if( strcasecmp( Var, "MotdFile" ) == 0 )
581 6725d789 2002-12-12 alex /* "Message of the day" (MOTD) file */
582 0ced4181 2002-12-26 alex if( strlcpy( Conf_MotdFile, Arg, sizeof( Conf_MotdFile )) >= sizeof( Conf_MotdFile )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MotdFile\" too long!", NGIRCd_ConfFile, Line );
585 1c2d0ae5 2002-03-29 alex if( strcasecmp( Var, "ServerUID" ) == 0 )
587 6725d789 2002-12-12 alex /* UID the daemon should switch to */
588 ae39724a 2002-11-08 alex pwd = getpwnam( Arg );
589 ae39724a 2002-11-08 alex if( pwd ) Conf_UID = pwd->pw_uid;
592 2e02da29 2002-11-30 alex #ifdef HAVE_ISDIGIT
593 2e02da29 2002-11-30 alex if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"ServerUID\" is not a number!", NGIRCd_ConfFile, Line );
596 2e02da29 2002-11-30 alex Conf_UID = (UINT)atoi( Arg );
600 1c2d0ae5 2002-03-29 alex if( strcasecmp( Var, "ServerGID" ) == 0 )
602 6725d789 2002-12-12 alex /* GID the daemon should use */
603 ae39724a 2002-11-08 alex grp = getgrnam( Arg );
604 ae39724a 2002-11-08 alex if( grp ) Conf_GID = grp->gr_gid;
607 2e02da29 2002-11-30 alex #ifdef HAVE_ISDIGIT
608 2e02da29 2002-11-30 alex if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"ServerGID\" is not a number!", NGIRCd_ConfFile, Line );
611 2e02da29 2002-11-30 alex Conf_GID = (UINT)atoi( Arg );
615 03d971d9 2002-01-02 alex if( strcasecmp( Var, "PingTimeout" ) == 0 )
617 6725d789 2002-12-12 alex /* PING timeout */
618 03d971d9 2002-01-02 alex Conf_PingTimeout = atoi( Arg );
619 2e02da29 2002-11-30 alex if( Conf_PingTimeout < 5 )
621 2e02da29 2002-11-30 alex Config_Error( LOG_WARNING, "%s, line %d: Value of \"PingTimeout\" too low!", NGIRCd_ConfFile, Line );
622 2e02da29 2002-11-30 alex Conf_PingTimeout = 5;
626 03d971d9 2002-01-02 alex if( strcasecmp( Var, "PongTimeout" ) == 0 )
628 6725d789 2002-12-12 alex /* PONG timeout */
629 03d971d9 2002-01-02 alex Conf_PongTimeout = atoi( Arg );
630 2e02da29 2002-11-30 alex if( Conf_PongTimeout < 5 )
632 2e02da29 2002-11-30 alex Config_Error( LOG_WARNING, "%s, line %d: Value of \"PongTimeout\" too low!", NGIRCd_ConfFile, Line );
633 2e02da29 2002-11-30 alex Conf_PongTimeout = 5;
637 03d971d9 2002-01-02 alex if( strcasecmp( Var, "ConnectRetry" ) == 0 )
639 6725d789 2002-12-12 alex /* Seconds between connection attempts to other servers */
640 03d971d9 2002-01-02 alex Conf_ConnectRetry = atoi( Arg );
641 2e02da29 2002-11-30 alex if( Conf_ConnectRetry < 5 )
643 2e02da29 2002-11-30 alex Config_Error( LOG_WARNING, "%s, line %d: Value of \"ConnectRetry\" too low!", NGIRCd_ConfFile, Line );
644 2e02da29 2002-11-30 alex Conf_ConnectRetry = 5;
648 7e1b3b91 2002-09-02 alex if( strcasecmp( Var, "OperCanUseMode" ) == 0 )
650 6725d789 2002-12-12 alex /* Are IRC operators allowed to use MODE in channels they aren't Op in? */
651 7e1b3b91 2002-09-02 alex if( strcasecmp( Arg, "yes" ) == 0 ) Conf_OperCanMode = TRUE;
652 7e1b3b91 2002-09-02 alex else if( strcasecmp( Arg, "true" ) == 0 ) Conf_OperCanMode = TRUE;
653 7e1b3b91 2002-09-02 alex else if( atoi( Arg ) != 0 ) Conf_OperCanMode = TRUE;
654 7e1b3b91 2002-09-02 alex else Conf_OperCanMode = FALSE;
657 0d32a3b4 2002-11-02 alex if( strcasecmp( Var, "MaxConnections" ) == 0 )
659 6725d789 2002-12-12 alex /* Maximum number of connections. Values <= 0 are equal to "no limit". */
660 2e02da29 2002-11-30 alex #ifdef HAVE_ISDIGIT
661 2e02da29 2002-11-30 alex if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxConnections\" is not a number!", NGIRCd_ConfFile, Line );
664 0d32a3b4 2002-11-02 alex Conf_MaxConnections = atol( Arg );
667 8b7b23cf 2002-12-13 alex if( strcasecmp( Var, "MaxJoins" ) == 0 )
669 8b7b23cf 2002-12-13 alex /* Maximum number of channels a user can join. Values <= 0 are equal to "no limit". */
670 8b7b23cf 2002-12-13 alex #ifdef HAVE_ISDIGIT
671 8b7b23cf 2002-12-13 alex if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MaxJoins\" is not a number!", NGIRCd_ConfFile, Line );
674 8b7b23cf 2002-12-13 alex Conf_MaxJoins = atoi( Arg );
678 f86083a0 2002-03-27 alex Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
679 03d971d9 2002-01-02 alex } /* Handle_GLOBAL */
683 c2f60abe 2002-05-27 alex Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg )
685 03d971d9 2002-01-02 alex assert( Line > 0 );
686 03d971d9 2002-01-02 alex assert( Var != NULL );
687 03d971d9 2002-01-02 alex assert( Arg != NULL );
688 03d971d9 2002-01-02 alex assert( Conf_Oper_Count > 0 );
690 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Name" ) == 0 )
692 6725d789 2002-12-12 alex /* Name of IRC operator */
693 0ced4181 2002-12-26 alex if( strlcpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, sizeof( Conf_Oper[Conf_Oper_Count - 1].name )) >= sizeof( Conf_Oper[Conf_Oper_Count - 1].name )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
696 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Password" ) == 0 )
698 6725d789 2002-12-12 alex /* Password of IRC operator */
699 0ced4181 2002-12-26 alex if( strlcpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, sizeof( Conf_Oper[Conf_Oper_Count - 1].pwd )) >= sizeof( Conf_Oper[Conf_Oper_Count - 1].pwd )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Password\" too long!", NGIRCd_ConfFile, Line );
703 f86083a0 2002-03-27 alex Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
704 03d971d9 2002-01-02 alex } /* Handle_OPERATOR */
708 c2f60abe 2002-05-27 alex Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
712 03d971d9 2002-01-02 alex assert( Line > 0 );
713 03d971d9 2002-01-02 alex assert( Var != NULL );
714 03d971d9 2002-01-02 alex assert( Arg != NULL );
716 a2544e49 2002-12-30 alex /* Ignore server block if no space is left in server configuration structure */
717 a2544e49 2002-12-30 alex if( New_Server_Idx <= NONE ) return;
719 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Host" ) == 0 )
721 6725d789 2002-12-12 alex /* Hostname of the server */
722 a2544e49 2002-12-30 alex if( strlcpy( New_Server.host, Arg, sizeof( New_Server.host )) >= sizeof( New_Server.host )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Host\" too long!", NGIRCd_ConfFile, Line );
725 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Name" ) == 0 )
727 6725d789 2002-12-12 alex /* Name of the server ("Nick"/"ID") */
728 a2544e49 2002-12-30 alex if( strlcpy( New_Server.name, Arg, sizeof( New_Server.name )) >= sizeof( New_Server.name )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
731 b2615bcc 2002-11-19 alex if( strcasecmp( Var, "MyPassword" ) == 0 )
733 6725d789 2002-12-12 alex /* Password of this server which is sent to the peer */
734 a2544e49 2002-12-30 alex if( strlcpy( New_Server.pwd_in, Arg, sizeof( New_Server.pwd_in )) >= sizeof( New_Server.pwd_in )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MyPassword\" too long!", NGIRCd_ConfFile, Line );
737 b2615bcc 2002-11-19 alex if( strcasecmp( Var, "PeerPassword" ) == 0 )
739 6725d789 2002-12-12 alex /* Passwort of the peer which must be received */
740 a2544e49 2002-12-30 alex if( strlcpy( New_Server.pwd_out, Arg, sizeof( New_Server.pwd_out )) >= sizeof( New_Server.pwd_out )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"PeerPassword\" too long!", NGIRCd_ConfFile, Line );
743 03d971d9 2002-01-02 alex if( strcasecmp( Var, "Port" ) == 0 )
745 6725d789 2002-12-12 alex /* Port to which this server should connect */
746 03d971d9 2002-01-02 alex port = atol( Arg );
747 a2544e49 2002-12-30 alex if( port > 0 && port < 0xFFFF ) New_Server.port = (INT)port;
748 f86083a0 2002-03-27 alex else Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Illegal port number %ld!", NGIRCd_ConfFile, Line, port );
751 d67d94ea 2002-03-10 alex if( strcasecmp( Var, "Group" ) == 0 )
753 6725d789 2002-12-12 alex /* Server group */
754 2e02da29 2002-11-30 alex #ifdef HAVE_ISDIGIT
755 2e02da29 2002-11-30 alex if( ! isdigit( *Arg )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Group\" is not a number!", NGIRCd_ConfFile, Line );
758 a2544e49 2002-12-30 alex New_Server.group = atoi( Arg );
762 f86083a0 2002-03-27 alex Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
763 03d971d9 2002-01-02 alex } /* Handle_SERVER */
767 c2f60abe 2002-05-27 alex Handle_CHANNEL( INT Line, CHAR *Var, CHAR *Arg )
769 040f5422 2002-05-21 alex assert( Line > 0 );
770 040f5422 2002-05-21 alex assert( Var != NULL );
771 040f5422 2002-05-21 alex assert( Arg != NULL );
773 040f5422 2002-05-21 alex if( strcasecmp( Var, "Name" ) == 0 )
775 6725d789 2002-12-12 alex /* Name of the channel */
776 0ced4181 2002-12-26 alex if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].name, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].name )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].name )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
779 040f5422 2002-05-21 alex if( strcasecmp( Var, "Modes" ) == 0 )
781 6725d789 2002-12-12 alex /* Initial modes */
782 0ced4181 2002-12-26 alex if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].modes, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].modes )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].modes )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Modes\" too long!", NGIRCd_ConfFile, Line );
785 040f5422 2002-05-21 alex if( strcasecmp( Var, "Topic" ) == 0 )
787 6725d789 2002-12-12 alex /* Initial topic */
788 0ced4181 2002-12-26 alex if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].topic )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].topic )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Topic\" too long!", NGIRCd_ConfFile, Line );
792 040f5422 2002-05-21 alex Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
793 040f5422 2002-05-21 alex } /* Handle_CHANNEL */
797 b7be46ed 2002-12-18 alex Validate_Config( BOOLEAN Configtest )
799 6725d789 2002-12-12 alex /* Validate configuration settings. */
801 a2544e49 2002-12-30 alex #ifdef DEBUG
802 a2544e49 2002-12-30 alex INT i, servers, servers_once;
805 9856253d 2001-12-30 alex if( ! Conf_ServerName[0] )
807 6725d789 2002-12-12 alex /* No server name configured! */
808 b615d128 2002-09-16 alex Config_Error( LOG_ALERT, "No server name configured in \"%s\" ('ServerName')!", NGIRCd_ConfFile );
809 b7be46ed 2002-12-18 alex if( ! Configtest )
811 b7be46ed 2002-12-18 alex Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
816 b615d128 2002-09-16 alex #ifdef STRICT_RFC
817 12cad28e 2002-10-21 alex if( ! Conf_ServerAdminMail[0] )
819 6725d789 2002-12-12 alex /* No administrative contact configured! */
820 b615d128 2002-09-16 alex Config_Error( LOG_ALERT, "No administrator email address configured in \"%s\" ('AdminEMail')!", NGIRCd_ConfFile );
821 b7be46ed 2002-12-18 alex if( ! Configtest )
823 b7be46ed 2002-12-18 alex Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
829 33bda862 2002-09-19 alex if( ! Conf_ServerAdmin1[0] && ! Conf_ServerAdmin2[0] && ! Conf_ServerAdminMail[0] )
831 6725d789 2002-12-12 alex /* No administrative information configured! */
832 b7be46ed 2002-12-18 alex Config_Error( LOG_WARNING, "No administrative information configured but required by RFC!" );
834 b7be46ed 2002-12-18 alex #ifdef FD_SETSIZE
835 3e4f58e4 2002-12-18 alex if(( Conf_MaxConnections > (LONG)FD_SETSIZE ) || ( Conf_MaxConnections < 1 ))
837 b7be46ed 2002-12-18 alex Conf_MaxConnections = (LONG)FD_SETSIZE;
838 b7be46ed 2002-12-18 alex Config_Error( LOG_ERR, "Setting MaxConnections to %ld, select() can't handle more file descriptors!", Conf_MaxConnections );
841 b7be46ed 2002-12-18 alex Config_Error( LOG_WARN, "Don't know how many file descriptors select() can handle on this system, don't set MaxConnections too high!" );
844 a2544e49 2002-12-30 alex #ifdef DEBUG
845 a2544e49 2002-12-30 alex servers = servers_once = 0;
846 a2544e49 2002-12-30 alex for( i = 0; i < MAX_SERVERS; i++ )
848 a2544e49 2002-12-30 alex if( Conf_Server[i].name[0] )
851 281f7583 2002-12-31 alex if( Conf_Server[i].flags & CONF_SFLAG_ONCE ) servers_once++;
854 a2544e49 2002-12-30 alex Log( LOG_DEBUG, "Configuration: Operators=%d, Servers=%d[%d], Channels=%d", Conf_Oper_Count, servers, servers_once, Conf_Channel_Count );
856 9856253d 2001-12-30 alex } /* Validate_Config */
859 f7327524 2002-05-30 alex #ifdef PROTOTYPES
860 f7327524 2002-05-30 alex LOCAL VOID Config_Error( CONST INT Level, CONST CHAR *Format, ... )
862 f7327524 2002-05-30 alex LOCAL VOID Config_Error( Level, Format, va_alist )
863 f7327524 2002-05-30 alex CONST INT Level;
864 f7327524 2002-05-30 alex CONST CHAR *Format;
868 6725d789 2002-12-12 alex /* Error! Write to console and/or logfile. */
870 f86083a0 2002-03-27 alex CHAR msg[MAX_LOG_MSG_LEN];
871 f86083a0 2002-03-27 alex va_list ap;
873 f86083a0 2002-03-27 alex assert( Format != NULL );
875 f7327524 2002-05-30 alex #ifdef PROTOTYPES
876 f86083a0 2002-03-27 alex va_start( ap, Format );
878 f7327524 2002-05-30 alex va_start( ap );
880 f86083a0 2002-03-27 alex vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
881 f86083a0 2002-03-27 alex va_end( ap );
883 6725d789 2002-12-12 alex /* During "normal operations" the log functions of the daemon should
884 6725d789 2002-12-12 alex * be used, but during testing of the configuration file, all messages
885 6725d789 2002-12-12 alex * should go directly to the console: */
886 ec474a4b 2002-10-04 alex if( Use_Log ) Log( Level, "%s", msg );
887 f86083a0 2002-03-27 alex else puts( msg );
888 f86083a0 2002-03-27 alex } /* Config_Error */
892 a2544e49 2002-12-30 alex Init_Server_Struct( CONF_SERVER *Server )
894 a2544e49 2002-12-30 alex /* Initialize server configuration structur to default values */
896 a2544e49 2002-12-30 alex assert( Server != NULL );
898 a2544e49 2002-12-30 alex strcpy( Server->host, "" );
899 a2544e49 2002-12-30 alex strcpy( Server->ip, "" );
900 a2544e49 2002-12-30 alex strcpy( Server->name, "" );
901 a2544e49 2002-12-30 alex strcpy( Server->pwd_in, "" );
902 a2544e49 2002-12-30 alex strcpy( Server->pwd_out, "" );
903 a2544e49 2002-12-30 alex Server->port = 0;
904 a2544e49 2002-12-30 alex Server->group = NONE;
905 a2544e49 2002-12-30 alex Server->lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY;
906 a2544e49 2002-12-30 alex Server->res_stat = NULL;
907 281f7583 2002-12-31 alex if( NGIRCd_Passive ) Server->flags = CONF_SFLAG_DISABLED;
908 281f7583 2002-12-31 alex else Server->flags = 0;
909 a2544e49 2002-12-30 alex Server->conn_id = NONE;
910 a2544e49 2002-12-30 alex } /* Init_Server_Struct */
913 cbc1e59f 2001-12-12 alex /* -eof- */