]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/conf.c
12a84d696a24ad06f3a6059078a1590c6b969395
[ngircd-alex.git] / src / ngircd / conf.c
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
4  *
5  * Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
6  * der GNU General Public License (GPL), wie von der Free Software Foundation
7  * herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
8  * der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
9  * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
10  * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
11  *
12  * $Id: conf.c,v 1.39 2002/11/22 17:57:40 alex Exp $
13  *
14  * conf.h: Konfiguration des ngircd
15  */
16
17
18 #include "portab.h"
19
20 #include "imp.h"
21 #include <assert.h>
22 #include <errno.h>
23 #include <stdarg.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <unistd.h>
28 #include <pwd.h>
29 #include <grp.h>
30 #include <sys/types.h>
31
32 #include "ngircd.h"
33 #include "conn.h"
34 #include "client.h"
35 #include "defines.h"
36 #include "log.h"
37 #include "resolve.h"
38 #include "tool.h"
39
40 #include "exp.h"
41 #include "conf.h"
42
43
44 LOCAL BOOLEAN Use_Log = TRUE;
45
46
47 LOCAL VOID Set_Defaults PARAMS(( VOID ));
48 LOCAL VOID Read_Config PARAMS(( VOID ));
49 LOCAL VOID Validate_Config PARAMS(( VOID ));
50
51 LOCAL VOID Handle_GLOBAL PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
52 LOCAL VOID Handle_OPERATOR PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
53 LOCAL VOID Handle_SERVER PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
54 LOCAL VOID Handle_CHANNEL PARAMS(( INT Line, CHAR *Var, CHAR *Arg ));
55
56 LOCAL VOID Config_Error PARAMS(( CONST INT Level, CONST CHAR *Format, ... ));
57
58
59 GLOBAL VOID
60 Conf_Init( VOID )
61 {
62         Set_Defaults( );
63         Read_Config( );
64         Validate_Config( );
65 } /* Config_Init */
66
67
68 GLOBAL INT
69 Conf_Test( VOID )
70 {
71         /* Konfiguration einlesen, ueberpruefen und ausgeben. */
72
73         struct passwd *pwd;
74         struct group *grp;
75         INT i;
76
77         Use_Log = FALSE;
78         Set_Defaults( );
79
80         printf( "Using \"%s\" as configuration file ...\n", NGIRCd_ConfFile );
81         Read_Config( );
82
83         /* Wenn stdin ein ein TTY ist: auf Taste warten */
84         if( isatty( fileno( stdout )))
85         {
86                 puts( "OK, press enter to see a dump of your service configuration ..." );
87                 getchar( );
88         }
89         else puts( "Ok, dump of your server configuration follows:\n" );
90
91         puts( "[GLOBAL]" );
92         printf( "  ServerName = %s\n", Conf_ServerName );
93         printf( "  ServerInfo = %s\n", Conf_ServerInfo );
94         printf( "  ServerPwd = %s\n", Conf_ServerPwd );
95         printf( "  AdminInfo1 = %s\n", Conf_ServerAdmin1 );
96         printf( "  AdminInfo2 = %s\n", Conf_ServerAdmin2 );
97         printf( "  AdminEMail = %s\n", Conf_ServerAdminMail );
98         printf( "  MotdFile = %s\n", Conf_MotdFile );
99         printf( "  Ports = " );
100         for( i = 0; i < Conf_ListenPorts_Count; i++ )
101         {
102                 if( i != 0 ) printf( ", " );
103                 printf( "%u", Conf_ListenPorts[i] );
104         }
105         puts( "" );
106         pwd = getpwuid( Conf_UID );
107         if( pwd ) printf( "  ServerUID = %s\n", pwd->pw_name );
108         else printf( "  ServerUID = %ld\n", (LONG)Conf_UID );
109         grp = getgrgid( Conf_GID );
110         if( grp ) printf( "  ServerGID = %s\n", grp->gr_name );
111         else printf( "  ServerGID = %ld\n", (LONG)Conf_GID );
112         printf( "  PingTimeout = %d\n", Conf_PingTimeout );
113         printf( "  PongTimeout = %d\n", Conf_PongTimeout );
114         printf( "  ConnectRetry = %d\n", Conf_ConnectRetry );
115         printf( "  OperCanUseMode = %s\n", Conf_OperCanMode == TRUE ? "yes" : "no" );
116         if( Conf_MaxConnections > 0 ) printf( "  MaxConnections = %ld\n", Conf_MaxConnections );
117         else printf( "  MaxConnections = -1\n" );
118         puts( "" );
119
120         for( i = 0; i < Conf_Oper_Count; i++ )
121         {
122                 if( ! Conf_Oper[i].name[0] ) continue;
123                 
124                 /* gueltiger Operator-Block: ausgeben */
125                 puts( "[OPERATOR]" );
126                 printf( "  Name = %s\n", Conf_Oper[i].name );
127                 printf( "  Password = %s\n", Conf_Oper[i].pwd );
128                 puts( "" );
129         }
130
131         for( i = 0; i < Conf_Server_Count; i++ )
132         {
133                 if( ! Conf_Server[i].name[0] ) continue;
134                 if( ! Conf_Server[i].host[0] ) continue;
135                 
136                 /* gueltiger Server-Block: ausgeben */
137                 puts( "[SERVER]" );
138                 printf( "  Name = %s\n", Conf_Server[i].name );
139                 printf( "  Host = %s\n", Conf_Server[i].host );
140                 printf( "  Port = %d\n", Conf_Server[i].port );
141                 printf( "  MyPassword = %s\n", Conf_Server[i].pwd_in );
142                 printf( "  PeerPassword = %s\n", Conf_Server[i].pwd_out );
143                 printf( "  Group = %d\n", Conf_Server[i].group );
144                 puts( "" );
145         }
146
147         for( i = 0; i < Conf_Channel_Count; i++ )
148         {
149                 if( ! Conf_Channel[i].name[0] ) continue;
150                 
151                 /* gueltiger Channel-Block: ausgeben */
152                 puts( "[CHANNEL]" );
153                 printf( "  Name = %s\n", Conf_Channel[i].name );
154                 printf( "  Modes = %s\n", Conf_Channel[i].modes );
155                 printf( "  Topic = %s\n", Conf_Channel[i].topic );
156                 puts( "" );
157         }
158         
159         return 0;
160 } /* Conf_Test */
161
162
163 LOCAL VOID
164 Set_Defaults( VOID )
165 {
166         /* Konfigurationsvariablen initialisieren, d.h. auf Default-Werte setzen. */
167
168         strcpy( Conf_ServerName, "" );
169         sprintf( Conf_ServerInfo, "%s %s", PACKAGE, VERSION );
170         strcpy( Conf_ServerPwd, "" );
171
172         strcpy( Conf_ServerAdmin1, "" );
173         strcpy( Conf_ServerAdmin2, "" );
174         strcpy( Conf_ServerAdminMail, "" );
175
176         strcpy( Conf_MotdFile, MOTD_FILE );
177
178         Conf_ListenPorts_Count = 0;
179
180         Conf_UID = Conf_GID = 0;
181         
182         Conf_PingTimeout = 120;
183         Conf_PongTimeout = 20;
184
185         Conf_ConnectRetry = 60;
186
187         Conf_Oper_Count = 0;
188         Conf_Server_Count = 0;
189         Conf_Channel_Count = 0;
190
191         Conf_OperCanMode = FALSE;
192         
193         Conf_MaxConnections = 0;
194 } /* Set_Defaults */
195
196
197 LOCAL VOID
198 Read_Config( VOID )
199 {
200         /* Konfigurationsdatei einlesen. */
201
202         CHAR section[LINE_LEN], str[LINE_LEN], *var, *arg, *ptr;
203         INT line;
204         FILE *fd;
205
206         fd = fopen( NGIRCd_ConfFile, "r" );
207         if( ! fd )
208         {
209                 /* Keine Konfigurationsdatei gefunden */
210                 Config_Error( LOG_ALERT, "Can't read configuration \"%s\": %s", NGIRCd_ConfFile, strerror( errno ));
211                 Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
212                 exit( 1 );
213         }
214
215         Config_Error( LOG_INFO, "Reading configuration from \"%s\" ...", NGIRCd_ConfFile );
216
217         line = 0;
218         strcpy( section, "" );
219         while( TRUE )
220         {
221                 if( ! fgets( str, LINE_LEN, fd )) break;
222                 ngt_TrimStr( str );
223                 line++;
224
225                 /* Kommentarzeilen und leere Zeilen ueberspringen */
226                 if( str[0] == ';' || str[0] == '#' || str[0] == '\0' ) continue;
227
228                 /* Anfang eines Abschnittes? */
229                 if(( str[0] == '[' ) && ( str[strlen( str ) - 1] == ']' ))
230                 {
231                         strcpy( section, str );
232                         if( strcasecmp( section, "[GLOBAL]" ) == 0 ) continue;
233                         if( strcasecmp( section, "[OPERATOR]" ) == 0 )
234                         {
235                                 if( Conf_Oper_Count + 1 > MAX_OPERATORS ) Config_Error( LOG_ERR, "Too many operators configured." );
236                                 else
237                                 {
238                                         /* neuen Operator initialisieren */
239                                         strcpy( Conf_Oper[Conf_Oper_Count].name, "" );
240                                         strcpy( Conf_Oper[Conf_Oper_Count].pwd, "" );
241                                         Conf_Oper_Count++;
242                                 }
243                                 continue;
244                         }
245                         if( strcasecmp( section, "[SERVER]" ) == 0 )
246                         {
247                                 if( Conf_Server_Count + 1 > MAX_SERVERS ) Config_Error( LOG_ERR, "Too many servers configured." );
248                                 else
249                                 {
250                                         /* neuen Server ("Peer") initialisieren */
251                                         strcpy( Conf_Server[Conf_Server_Count].host, "" );
252                                         strcpy( Conf_Server[Conf_Server_Count].ip, "" );
253                                         strcpy( Conf_Server[Conf_Server_Count].name, "" );
254                                         strcpy( Conf_Server[Conf_Server_Count].pwd_in, "" );
255                                         strcpy( Conf_Server[Conf_Server_Count].pwd_out, "" );
256                                         Conf_Server[Conf_Server_Count].port = 0;
257                                         Conf_Server[Conf_Server_Count].group = -1;
258                                         Conf_Server[Conf_Server_Count].lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY;
259                                         Conf_Server[Conf_Server_Count].res_stat = NULL;
260                                         Conf_Server_Count++;
261                                 }
262                                 continue;
263                         }
264                         if( strcasecmp( section, "[CHANNEL]" ) == 0 )
265                         {
266                                 if( Conf_Channel_Count + 1 > MAX_DEFCHANNELS ) Config_Error( LOG_ERR, "Too many pre-defined channels configured." );
267                                 else
268                                 {
269                                         /* neuen vordefinierten Channel initialisieren */
270                                         strcpy( Conf_Channel[Conf_Channel_Count].name, "" );
271                                         strcpy( Conf_Channel[Conf_Channel_Count].modes, "" );
272                                         strcpy( Conf_Channel[Conf_Channel_Count].topic, "" );
273                                         Conf_Channel_Count++;
274                                 }
275                                 continue;
276                         }
277                         Config_Error( LOG_ERR, "%s, line %d: Unknown section \"%s\"!", NGIRCd_ConfFile, line, section );
278                         section[0] = 0x1;
279                 }
280                 if( section[0] == 0x1 ) continue;
281
282                 /* In Variable und Argument zerlegen */
283                 ptr = strchr( str, '=' );
284                 if( ! ptr )
285                 {
286                         Config_Error( LOG_ERR, "%s, line %d: Syntax error!", NGIRCd_ConfFile, line );
287                         continue;
288                 }
289                 *ptr = '\0';
290                 var = str; ngt_TrimStr( var );
291                 arg = ptr + 1; ngt_TrimStr( arg );
292
293                 if( strcasecmp( section, "[GLOBAL]" ) == 0 ) Handle_GLOBAL( line, var, arg );
294                 else if( strcasecmp( section, "[OPERATOR]" ) == 0 ) Handle_OPERATOR( line, var, arg );
295                 else if( strcasecmp( section, "[SERVER]" ) == 0 ) Handle_SERVER( line, var, arg );
296                 else if( strcasecmp( section, "[CHANNEL]" ) == 0 ) Handle_CHANNEL( line, var, arg );
297                 else Config_Error( LOG_ERR, "%s, line %d: Variable \"%s\" outside section!", NGIRCd_ConfFile, line, var );
298         }
299         
300         fclose( fd );
301         
302         /* Wenn kein Port definiert wurde, Port 6667 als Default benutzen */
303         if( Conf_ListenPorts_Count < 1 )
304         {
305                 Conf_ListenPorts_Count = 1;
306                 Conf_ListenPorts[0] = 6667;
307         }
308 } /* Read_Config */
309
310
311 LOCAL VOID
312 Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
313 {
314         struct passwd *pwd;
315         struct group *grp;
316         CHAR *ptr;
317         LONG port;
318         
319         assert( Line > 0 );
320         assert( Var != NULL );
321         assert( Arg != NULL );
322         
323         if( strcasecmp( Var, "Name" ) == 0 )
324         {
325                 /* Der Server-Name */
326                 strncpy( Conf_ServerName, Arg, CLIENT_ID_LEN - 1 );
327                 Conf_ServerName[CLIENT_ID_LEN - 1] = '\0';
328                 return;
329         }
330         if( strcasecmp( Var, "Info" ) == 0 )
331         {
332                 /* Server-Info-Text */
333                 strncpy( Conf_ServerInfo, Arg, CLIENT_INFO_LEN - 1 );
334                 Conf_ServerInfo[CLIENT_INFO_LEN - 1] = '\0';
335                 return;
336         }
337         if( strcasecmp( Var, "Password" ) == 0 )
338         {
339                 /* Server-Passwort */
340                 strncpy( Conf_ServerPwd, Arg, CLIENT_PASS_LEN - 1 );
341                 Conf_ServerPwd[CLIENT_PASS_LEN - 1] = '\0';
342                 return;
343         }
344         if( strcasecmp( Var, "AdminInfo1" ) == 0 )
345         {
346                 /* Server-Info-Text */
347                 strncpy( Conf_ServerAdmin1, Arg, CLIENT_INFO_LEN - 1 );
348                 Conf_ServerAdmin1[CLIENT_INFO_LEN - 1] = '\0';
349                 return;
350         }
351         if( strcasecmp( Var, "AdminInfo2" ) == 0 )
352         {
353                 /* Server-Info-Text */
354                 strncpy( Conf_ServerAdmin2, Arg, CLIENT_INFO_LEN - 1 );
355                 Conf_ServerAdmin2[CLIENT_INFO_LEN - 1] = '\0';
356                 return;
357         }
358         if( strcasecmp( Var, "AdminEMail" ) == 0 )
359         {
360                 /* Server-Info-Text */
361                 strncpy( Conf_ServerAdminMail, Arg, CLIENT_INFO_LEN - 1 );
362                 Conf_ServerAdminMail[CLIENT_INFO_LEN - 1] = '\0';
363                 return;
364         }
365         if( strcasecmp( Var, "Ports" ) == 0 )
366         {
367                 /* Ports, durch "," getrennt, auf denen der Server
368                 * Verbindungen annehmen soll */
369                 ptr = strtok( Arg, "," );
370                 while( ptr )
371                 {
372                         ngt_TrimStr( ptr );
373                         port = atol( ptr );
374                         if( Conf_ListenPorts_Count + 1 > MAX_LISTEN_PORTS ) Config_Error( LOG_ERR, "Too many listen ports configured. Port %ld ignored.", port );
375                         else
376                         {
377                                 if( port > 0 && port < 0xFFFF ) Conf_ListenPorts[Conf_ListenPorts_Count++] = (UINT)port;
378                                 else Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Illegal port number %ld!", NGIRCd_ConfFile, Line, port );
379                         }
380                         ptr = strtok( NULL, "," );
381                 }
382                 return;
383         }
384         if( strcasecmp( Var, "MotdFile" ) == 0 )
385         {
386                 /* Datei mit der "message of the day" (MOTD) */
387                 strncpy( Conf_MotdFile, Arg, FNAME_LEN - 1 );
388                 Conf_MotdFile[FNAME_LEN - 1] = '\0';
389                 return;
390         }
391         if( strcasecmp( Var, "ServerUID" ) == 0 )
392         {
393                 /* UID, mit der der Daemon laufen soll */
394                 pwd = getpwnam( Arg );
395                 if( pwd ) Conf_UID = pwd->pw_uid;
396                 else Conf_UID = (UINT)atoi( Arg );
397                 return;
398         }
399         if( strcasecmp( Var, "ServerGID" ) == 0 )
400         {
401                 /* GID, mit der der Daemon laufen soll */
402                 grp = getgrnam( Arg );
403                 if( grp ) Conf_GID = grp->gr_gid;
404                 else Conf_GID = (UINT)atoi( Arg );
405                 return;
406         }
407         if( strcasecmp( Var, "PingTimeout" ) == 0 )
408         {
409                 /* PING-Timeout */
410                 Conf_PingTimeout = atoi( Arg );
411                 if(( Conf_PingTimeout ) < 5 ) Conf_PingTimeout = 5;
412                 return;
413         }
414         if( strcasecmp( Var, "PongTimeout" ) == 0 )
415         {
416                 /* PONG-Timeout */
417                 Conf_PongTimeout = atoi( Arg );
418                 if(( Conf_PongTimeout ) < 5 ) Conf_PongTimeout = 5;
419                 return;
420         }
421         if( strcasecmp( Var, "ConnectRetry" ) == 0 )
422         {
423                 /* Sekunden zwischen Verbindungsversuchen zu anderen Servern */
424                 Conf_ConnectRetry = atoi( Arg );
425                 if(( Conf_ConnectRetry ) < 5 ) Conf_ConnectRetry = 5;
426                 return;
427         }
428         if( strcasecmp( Var, "OperCanUseMode" ) == 0 )
429         {
430                 /* Koennen IRC-Operatoren immer MODE benutzen? */
431                 if( strcasecmp( Arg, "yes" ) == 0 ) Conf_OperCanMode = TRUE;
432                 else if( strcasecmp( Arg, "true" ) == 0 ) Conf_OperCanMode = TRUE;
433                 else if( atoi( Arg ) != 0 ) Conf_OperCanMode = TRUE;
434                 else Conf_OperCanMode = FALSE;
435                 return;
436         }
437         if( strcasecmp( Var, "MaxConnections" ) == 0 )
438         {
439                 /* Maximale Anzahl von Verbindungen. Werte <= 0 stehen
440                  * fuer "kein Limit". */
441                 Conf_MaxConnections = atol( Arg );
442                 return;
443         }
444                 
445         Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
446 } /* Handle_GLOBAL */
447
448
449 LOCAL VOID
450 Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg )
451 {
452         assert( Line > 0 );
453         assert( Var != NULL );
454         assert( Arg != NULL );
455         assert( Conf_Oper_Count > 0 );
456
457         if( strcasecmp( Var, "Name" ) == 0 )
458         {
459                 /* Name des IRC Operator */
460                 strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_PASS_LEN - 1 );
461                 Conf_Oper[Conf_Oper_Count - 1].name[CLIENT_PASS_LEN - 1] = '\0';
462                 return;
463         }
464         if( strcasecmp( Var, "Password" ) == 0 )
465         {
466                 /* Passwort des IRC Operator */
467                 strncpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 );
468                 Conf_Oper[Conf_Oper_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0';
469                 return;
470         }
471         
472         Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
473 } /* Handle_OPERATOR */
474
475
476 LOCAL VOID
477 Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
478 {
479         LONG port;
480         
481         assert( Line > 0 );
482         assert( Var != NULL );
483         assert( Arg != NULL );
484
485         if( strcasecmp( Var, "Host" ) == 0 )
486         {
487                 /* Hostname des Servers */
488                 strncpy( Conf_Server[Conf_Server_Count - 1].host, Arg, HOST_LEN - 1 );
489                 Conf_Server[Conf_Server_Count - 1].host[HOST_LEN - 1] = '\0';
490                 return;
491         }
492         if( strcasecmp( Var, "Name" ) == 0 )
493         {
494                 /* Name des Servers ("Nick") */
495                 strncpy( Conf_Server[Conf_Server_Count - 1].name, Arg, CLIENT_ID_LEN - 1 );
496                 Conf_Server[Conf_Server_Count - 1].name[CLIENT_ID_LEN - 1] = '\0';
497                 return;
498         }
499         if( strcasecmp( Var, "MyPassword" ) == 0 )
500         {
501                 /* Passwort dieses Servers, welches empfangen werden muss */
502                 strncpy( Conf_Server[Conf_Server_Count - 1].pwd_in, Arg, CLIENT_PASS_LEN - 1 );
503                 Conf_Server[Conf_Server_Count - 1].pwd_in[CLIENT_PASS_LEN - 1] = '\0';
504                 return;
505         }
506         if( strcasecmp( Var, "PeerPassword" ) == 0 )
507         {
508                 /* Passwort des anderen Servers, welches gesendet werden muss */
509                 strncpy( Conf_Server[Conf_Server_Count - 1].pwd_out, Arg, CLIENT_PASS_LEN - 1 );
510                 Conf_Server[Conf_Server_Count - 1].pwd_out[CLIENT_PASS_LEN - 1] = '\0';
511                 return;
512         }
513         if( strcasecmp( Var, "Port" ) == 0 )
514         {
515                 /* Port, zu dem Verbunden werden soll */
516                 port = atol( Arg );
517                 if( port > 0 && port < 0xFFFF ) Conf_Server[Conf_Server_Count - 1].port = (INT)port;
518                 else Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Illegal port number %ld!", NGIRCd_ConfFile, Line, port );
519                 return;
520         }
521         if( strcasecmp( Var, "Group" ) == 0 )
522         {
523                 /* Server-Gruppe */
524                 Conf_Server[Conf_Server_Count - 1].group = atoi( Arg );
525                 return;
526         }
527         
528         Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
529 } /* Handle_SERVER */
530
531
532 LOCAL VOID
533 Handle_CHANNEL( INT Line, CHAR *Var, CHAR *Arg )
534 {
535         assert( Line > 0 );
536         assert( Var != NULL );
537         assert( Arg != NULL );
538
539         if( strcasecmp( Var, "Name" ) == 0 )
540         {
541                 /* Hostname des Servers */
542                 strncpy( Conf_Channel[Conf_Channel_Count - 1].name, Arg, CHANNEL_NAME_LEN - 1 );
543                 Conf_Channel[Conf_Channel_Count - 1].name[CHANNEL_NAME_LEN - 1] = '\0';
544                 return;
545         }
546         if( strcasecmp( Var, "Modes" ) == 0 )
547         {
548                 /* Name des Servers ("Nick") */
549                 strncpy( Conf_Channel[Conf_Channel_Count - 1].modes, Arg, CHANNEL_MODE_LEN - 1 );
550                 Conf_Channel[Conf_Channel_Count - 1].modes[CHANNEL_MODE_LEN - 1] = '\0';
551                 return;
552         }
553         if( strcasecmp( Var, "Topic" ) == 0 )
554         {
555                 /* Passwort des Servers */
556                 strncpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, CHANNEL_TOPIC_LEN - 1 );
557                 Conf_Channel[Conf_Channel_Count - 1].topic[CHANNEL_TOPIC_LEN - 1] = '\0';
558                 return;
559         }
560
561         Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
562 } /* Handle_CHANNEL */
563
564
565 LOCAL VOID
566 Validate_Config( VOID )
567 {
568         /* Konfiguration ueberpruefen */
569         
570         if( ! Conf_ServerName[0] )
571         {
572                 /* Kein Servername konfiguriert */
573                 Config_Error( LOG_ALERT, "No server name configured in \"%s\" ('ServerName')!", NGIRCd_ConfFile );
574                 Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
575                 exit( 1 );
576         }
577
578 #ifdef STRICT_RFC
579         if( ! Conf_ServerAdminMail[0] )
580         {
581                 /* Keine Server-Information konfiguriert */
582                 Config_Error( LOG_ALERT, "No administrator email address configured in \"%s\" ('AdminEMail')!", NGIRCd_ConfFile );
583                 Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
584                 exit( 1 );
585         }
586 #endif
587
588         if( ! Conf_ServerAdmin1[0] && ! Conf_ServerAdmin2[0] && ! Conf_ServerAdminMail[0] )
589         {
590                 /* Keine Server-Information konfiguriert */
591                 Log( LOG_WARNING, "No administrative information configured but required by RFC!" );
592         }
593 } /* Validate_Config */
594
595
596 #ifdef PROTOTYPES
597 LOCAL VOID Config_Error( CONST INT Level, CONST CHAR *Format, ... )
598 #else
599 LOCAL VOID Config_Error( Level, Format, va_alist )
600 CONST INT Level;
601 CONST CHAR *Format;
602 va_dcl
603 #endif
604 {
605         /* Fehler! Auf Console und/oder ins Log schreiben */
606
607         CHAR msg[MAX_LOG_MSG_LEN];
608         va_list ap;
609
610         assert( Format != NULL );
611
612         /* String mit variablen Argumenten zusammenbauen ... */
613 #ifdef PROTOTYPES
614         va_start( ap, Format );
615 #else
616         va_start( ap );
617 #endif
618         vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
619         va_end( ap );
620
621         /* Im "normalen Betrieb" soll der Log-Mechanismus des ngIRCd verwendet
622          * werden, beim Testen der Konfiguration jedoch nicht, hier sollen alle
623          * Meldungen direkt auf die Konsole ausgegeben werden: */
624         if( Use_Log ) Log( Level, "%s", msg );
625         else puts( msg );
626 } /* Config_Error */
627
628
629 /* -eof- */