2 * ngIRCd -- The Next Generation IRC Daemon
3 * Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * Please read the file COPYING, README and AUTHORS for more information.
11 * Configuration management (reading, parsing & validation)
32 #include <sys/types.h>
52 static bool Use_Log = true, Using_MotdFile = true;
53 static CONF_SERVER New_Server;
54 static int New_Server_Idx;
56 static size_t Conf_Oper_Count;
57 static size_t Conf_Channel_Count;
58 static char Conf_MotdFile[FNAME_LEN];
60 static void Set_Defaults PARAMS(( bool InitServers ));
61 static bool Read_Config PARAMS(( bool ngircd_starting ));
62 static bool Validate_Config PARAMS(( bool TestOnly, bool Rehash ));
64 static void Handle_GLOBAL PARAMS(( int Line, char *Var, char *Arg ));
65 static void Handle_FEATURES PARAMS(( int Line, char *Var, char *Arg ));
66 static void Handle_OPERATOR PARAMS(( int Line, char *Var, char *Arg ));
67 static void Handle_SERVER PARAMS(( int Line, char *Var, char *Arg ));
68 static void Handle_CHANNEL PARAMS(( int Line, char *Var, char *Arg ));
70 static void Config_Error PARAMS(( const int Level, const char *Format, ... ));
72 static void Config_Error_NaN PARAMS(( const int LINE, const char *Value ));
73 static void Config_Error_TooLong PARAMS(( const int LINE, const char *Value ));
75 static void Init_Server_Struct PARAMS(( CONF_SERVER *Server ));
78 #define DEFAULT_LISTEN_ADDRSTR "::,0.0.0.0"
80 #define DEFAULT_LISTEN_ADDRSTR "0.0.0.0"
84 struct SSLOptions Conf_SSLOptions;
89 free(Conf_SSLOptions.KeyFile);
90 Conf_SSLOptions.KeyFile = NULL;
92 free(Conf_SSLOptions.CertFile);
93 Conf_SSLOptions.CertFile = NULL;
95 free(Conf_SSLOptions.DHFile);
96 Conf_SSLOptions.DHFile = NULL;
97 array_free_wipe(&Conf_SSLOptions.KeyFilePassword);
101 ssl_print_configvar(const char *name, const char *file)
106 printf(" %s =\n", name);
110 fp = fopen(file, "r");
114 fprintf(stderr, "ERROR: %s \"%s\": %s\n",
115 name, file, strerror(errno));
117 printf(" %s = %s\n", name, file);
126 ret = ssl_print_configvar("SSLKeyFile", Conf_SSLOptions.KeyFile);
128 if (!ssl_print_configvar("SSLCertFile", Conf_SSLOptions.CertFile))
131 if (!ssl_print_configvar("SSLDHFile", Conf_SSLOptions.DHFile))
134 if (array_bytes(&Conf_SSLOptions.KeyFilePassword))
135 puts(" SSLKeyFilePassword = <secret>");
137 array_free_wipe(&Conf_SSLOptions.KeyFilePassword);
144 strdup_warn(const char *str)
146 char *ptr = strdup(str);
148 Config_Error(LOG_ERR, "Could not allocate mem for string: %s", str);
158 len = array_length(a, sizeof(UINT16));
160 ports = (UINT16*) array_start(a);
161 printf("%u", (unsigned int) *ports);
164 printf(", %u", (unsigned int) *ports);
172 ports_parse(array *a, int Line, char *Arg)
180 /* Ports on that the server should listen. More port numbers
181 * must be separated by "," */
182 ptr = strtok( Arg, "," );
186 if (port > 0 && port < 0xFFFF) {
187 port16 = (UINT16) port;
188 if (!array_catb(a, (char*)&port16, sizeof port16))
189 Config_Error(LOG_ERR, "%s, line %d Could not add port number %ld: %s",
190 NGIRCd_ConfFile, Line, port, strerror(errno));
192 Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Illegal port number %ld!",
193 NGIRCd_ConfFile, Line, port );
196 ptr = strtok( NULL, "," );
205 Validate_Config(false, false);
212 if (!Read_Config(false))
214 Validate_Config(false, true);
216 /* Update CLIENT structure of local server */
217 Client_SetInfo(Client_ThisServer(), Conf_ServerInfo);
219 } /* Config_Rehash */
223 yesno_to_str(int boolean_value)
234 struct Conf_Oper *op;
237 len = array_length(&Conf_Opers, sizeof(*op));
238 op = array_start(&Conf_Opers);
243 array_free(&Conf_Opers);
249 struct Conf_Oper *op;
252 len = array_length(&Conf_Opers, sizeof(*op));
253 op = array_start(&Conf_Opers);
258 printf(" Name = %s\n", op->name);
259 printf(" Password = %s\n", op->pwd);
260 printf(" Mask = %s\n\n", op->mask ? op->mask : "");
269 /* Read configuration, validate and output it. */
275 size_t predef_channel_count;
276 struct Conf_Channel *predef_chan;
280 if (! Read_Config(true))
283 config_valid = Validate_Config(true, false);
285 /* If stdin and stdout ("you can read our nice message and we can
286 * read in your keypress") are valid tty's, wait for a key: */
287 if( isatty( fileno( stdin )) && isatty( fileno( stdout ))) {
288 puts( "OK, press enter to see a dump of your service configuration ..." );
291 puts( "Ok, dump of your server configuration follows:\n" );
295 printf(" Name = %s\n", Conf_ServerName);
296 printf(" Info = %s\n", Conf_ServerInfo);
298 printf(" Password = %s\n", Conf_ServerPwd);
300 printf(" WebircPassword = %s\n", Conf_WebircPwd);
301 printf(" AdminInfo1 = %s\n", Conf_ServerAdmin1);
302 printf(" AdminInfo2 = %s\n", Conf_ServerAdmin2);
303 printf(" AdminEMail = %s\n", Conf_ServerAdminMail);
304 if (Using_MotdFile) {
305 printf(" MotdFile = %s\n", Conf_MotdFile);
306 printf(" MotdPhrase =\n");
308 printf(" MotdFile = \n");
309 printf(" MotdPhrase = %s\n", array_bytes(&Conf_Motd)
310 ? (const char*) array_start(&Conf_Motd) : "");
312 printf(" ChrootDir = %s\n", Conf_Chroot);
313 printf(" PidFile = %s\n", Conf_PidFile);
314 printf(" Listen = %s\n", Conf_ListenAddress);
315 fputs(" Ports = ", stdout);
316 ports_puts(&Conf_ListenPorts);
318 fputs(" SSLPorts = ", stdout);
319 ports_puts(&Conf_SSLOptions.ListenPorts);
321 config_valid = false;
324 pwd = getpwuid(Conf_UID);
326 printf(" ServerUID = %s\n", pwd->pw_name);
328 printf(" ServerUID = %ld\n", (long)Conf_UID);
329 grp = getgrgid(Conf_GID);
331 printf(" ServerGID = %s\n", grp->gr_name);
333 printf(" ServerGID = %ld\n", (long)Conf_GID);
335 printf(" SyslogFacility = %s\n",
336 ngt_SyslogFacilityName(Conf_SyslogFacility));
338 printf(" PingTimeout = %d\n", Conf_PingTimeout);
339 printf(" PongTimeout = %d\n", Conf_PongTimeout);
340 printf(" ConnectRetry = %d\n", Conf_ConnectRetry);
341 printf(" OperCanUseMode = %s\n", yesno_to_str(Conf_OperCanMode));
342 printf(" OperServerMode = %s\n", yesno_to_str(Conf_OperServerMode));
343 printf(" AllowRemoteOper = %s\n", yesno_to_str(Conf_AllowRemoteOper));
344 printf(" PredefChannelsOnly = %s\n", yesno_to_str(Conf_PredefChannelsOnly));
346 printf(" ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6));
347 printf(" ConnectIPv6 = %s\n", yesno_to_str(Conf_ConnectIPv4));
349 printf(" MaxConnections = %ld\n", Conf_MaxConnections);
350 printf(" MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP);
351 printf(" MaxJoins = %d\n", Conf_MaxJoins > 0 ? Conf_MaxJoins : -1);
352 printf(" MaxNickLength = %u\n\n", Conf_MaxNickLength - 1);
355 printf(" DNS = %s\n", yesno_to_str(Conf_DNS));
356 printf(" Ident = %s\n", yesno_to_str(Conf_Ident));
357 printf(" PAM = %s\n", yesno_to_str(Conf_PAM));
362 for( i = 0; i < MAX_SERVERS; i++ ) {
363 if( ! Conf_Server[i].name[0] ) continue;
365 /* Valid "Server" section */
367 printf( " Name = %s\n", Conf_Server[i].name );
368 printf( " Host = %s\n", Conf_Server[i].host );
369 printf( " Port = %u\n", (unsigned int)Conf_Server[i].port );
371 printf( " SSLConnect = %s\n", Conf_Server[i].SSLConnect?"yes":"no");
373 printf( " MyPassword = %s\n", Conf_Server[i].pwd_in );
374 printf( " PeerPassword = %s\n", Conf_Server[i].pwd_out );
375 printf( " ServiceMask = %s\n", Conf_Server[i].svs_mask);
376 printf( " Group = %d\n", Conf_Server[i].group );
377 printf( " Passive = %s\n\n", Conf_Server[i].flags & CONF_SFLAG_DISABLED ? "yes" : "no");
380 predef_channel_count = array_length(&Conf_Channels, sizeof(*predef_chan));
381 predef_chan = array_start(&Conf_Channels);
383 for (i = 0; i < predef_channel_count; i++, predef_chan++) {
384 if (!predef_chan->name[0])
387 /* Valid "Channel" section */
389 printf(" Name = %s\n", predef_chan->name);
390 printf(" Modes = %s\n", predef_chan->modes);
391 printf(" Key = %s\n", predef_chan->key);
392 printf(" MaxUsers = %lu\n", predef_chan->maxusers);
393 printf(" Topic = %s\n", predef_chan->topic);
394 printf(" KeyFile = %s\n\n", predef_chan->keyfile);
397 return (config_valid ? 0 : 1);
402 Conf_UnsetServer( CONN_ID Idx )
404 /* Set next time for next connection attempt, if this is a server
405 * link that is (still) configured here. If the server is set as
406 * "once", delete it from our configuration.
407 * Non-Server-Connections will be silently ignored. */
412 /* Check all our configured servers */
413 for( i = 0; i < MAX_SERVERS; i++ ) {
414 if( Conf_Server[i].conn_id != Idx ) continue;
416 /* Gotcha! Mark server configuration as "unused": */
417 Conf_Server[i].conn_id = NONE;
419 if( Conf_Server[i].flags & CONF_SFLAG_ONCE ) {
420 /* Delete configuration here */
421 Init_Server_Struct( &Conf_Server[i] );
423 /* Set time for next connect attempt */
425 if (Conf_Server[i].lasttry < t - Conf_ConnectRetry) {
426 /* The connection has been "long", so we don't
427 * require the next attempt to be delayed. */
428 Conf_Server[i].lasttry =
429 t - Conf_ConnectRetry + RECONNECT_DELAY;
431 Conf_Server[i].lasttry = t;
434 } /* Conf_UnsetServer */
438 Conf_SetServer( int ConfServer, CONN_ID Idx )
440 /* Set connection for specified configured server */
442 assert( ConfServer > NONE );
443 assert( Idx > NONE );
445 Conf_Server[ConfServer].conn_id = Idx;
446 } /* Conf_SetServer */
450 Conf_GetServer( CONN_ID Idx )
452 /* Get index of server in configuration structure */
456 assert( Idx > NONE );
458 for( i = 0; i < MAX_SERVERS; i++ ) {
459 if( Conf_Server[i].conn_id == Idx ) return i;
462 } /* Conf_GetServer */
466 Conf_EnableServer( const char *Name, UINT16 Port )
468 /* Enable specified server and adjust port */
472 assert( Name != NULL );
474 for( i = 0; i < MAX_SERVERS; i++ ) {
475 if( strcasecmp( Conf_Server[i].name, Name ) == 0 ) {
476 /* Gotcha! Set port and enable server: */
477 Conf_Server[i].port = Port;
478 Conf_Server[i].flags &= ~CONF_SFLAG_DISABLED;
479 return (Conf_Server[i].port && Conf_Server[i].host[0]);
483 } /* Conf_EnableServer */
487 Conf_EnablePassiveServer(const char *Name)
489 /* Enable specified server */
492 assert( Name != NULL );
493 for (i = 0; i < MAX_SERVERS; i++) {
494 if ((strcasecmp( Conf_Server[i].name, Name ) == 0) && (Conf_Server[i].port > 0)) {
495 /* BINGO! Enable server */
496 Conf_Server[i].flags &= ~CONF_SFLAG_DISABLED;
501 } /* Conf_EnablePassiveServer */
505 Conf_DisableServer( const char *Name )
507 /* Enable specified server and adjust port */
511 assert( Name != NULL );
513 for( i = 0; i < MAX_SERVERS; i++ ) {
514 if( strcasecmp( Conf_Server[i].name, Name ) == 0 ) {
515 /* Gotcha! Disable and disconnect server: */
516 Conf_Server[i].flags |= CONF_SFLAG_DISABLED;
517 if( Conf_Server[i].conn_id > NONE ) Conn_Close( Conf_Server[i].conn_id, NULL, "Server link terminated on operator request", true);
522 } /* Conf_DisableServer */
526 Conf_AddServer( const char *Name, UINT16 Port, const char *Host, const char *MyPwd, const char *PeerPwd )
528 /* Add new server to configuration */
532 assert( Name != NULL );
533 assert( Host != NULL );
534 assert( MyPwd != NULL );
535 assert( PeerPwd != NULL );
537 /* Search unused item in server configuration structure */
538 for( i = 0; i < MAX_SERVERS; i++ ) {
539 /* Is this item used? */
540 if( ! Conf_Server[i].name[0] ) break;
542 if( i >= MAX_SERVERS ) return false;
544 Init_Server_Struct( &Conf_Server[i] );
545 strlcpy( Conf_Server[i].name, Name, sizeof( Conf_Server[i].name ));
546 strlcpy( Conf_Server[i].host, Host, sizeof( Conf_Server[i].host ));
547 strlcpy( Conf_Server[i].pwd_out, MyPwd, sizeof( Conf_Server[i].pwd_out ));
548 strlcpy( Conf_Server[i].pwd_in, PeerPwd, sizeof( Conf_Server[i].pwd_in ));
549 Conf_Server[i].port = Port;
550 Conf_Server[i].flags = CONF_SFLAG_ONCE;
553 } /* Conf_AddServer */
557 * Check if the given nick name is an service
560 Conf_IsService(int ConfServer, const char *Nick)
562 return MatchCaseInsensitive(Conf_Server[ConfServer].svs_mask, Nick);
563 } /* Conf_IsService */
567 Set_Defaults_Optional(void)
583 * Initialize configuration settings with their default values.
586 Set_Defaults(bool InitServers)
590 strcpy(Conf_ServerName, "");
591 snprintf(Conf_ServerInfo, sizeof Conf_ServerInfo, "%s %s",
592 PACKAGE_NAME, PACKAGE_VERSION);
593 strcpy(Conf_ServerPwd, "");
595 strcpy(Conf_ServerAdmin1, "");
596 strcpy(Conf_ServerAdmin2, "");
597 strcpy(Conf_ServerAdminMail, "");
599 strlcpy(Conf_MotdFile, SYSCONFDIR, sizeof(Conf_MotdFile));
600 strlcat(Conf_MotdFile, MOTD_FILE, sizeof(Conf_MotdFile));
602 Conf_UID = Conf_GID = 0;
603 strlcpy(Conf_Chroot, CHROOT_DIR, sizeof(Conf_Chroot));
604 strlcpy(Conf_PidFile, PID_FILE, sizeof(Conf_PidFile));
606 free(Conf_ListenAddress);
607 Conf_ListenAddress = NULL;
609 Conf_PingTimeout = 120;
610 Conf_PongTimeout = 20;
611 Conf_ConnectRetry = 60;
615 Conf_Channel_Count = 0;
617 Conf_OperCanMode = false;
618 Conf_OperServerMode = false;
619 Conf_AllowRemoteOper = false;
620 Conf_PredefChannelsOnly = false;
622 Conf_ConnectIPv4 = true;
623 Conf_ConnectIPv6 = true;
625 Conf_MaxConnections = 0;
626 Conf_MaxConnectionsIP = 5;
628 Conf_MaxNickLength = CLIENT_NICK_LEN_DEFAULT;
632 Conf_SyslogFacility = LOG_LOCAL5;
634 Conf_SyslogFacility = 0;
637 Set_Defaults_Optional();
639 /* Initialize server configuration structures */
641 for (i = 0; i < MAX_SERVERS;
642 Init_Server_Struct(&Conf_Server[i++]));
645 /* Free MOTD; this is important when reloading the configuration */
646 array_free(&Conf_Motd);
653 size_t cnt = array_bytes(&Conf_ListenPorts);
655 cnt += array_bytes(&Conf_SSLOptions.ListenPorts);
661 Read_Motd(const char *filename)
666 if (*filename == '\0')
669 fp = fopen(filename, "r");
671 Log(LOG_WARNING, "Can't read MOTD file \"%s\": %s",
672 filename, strerror(errno));
676 array_free(&Conf_Motd);
677 Using_MotdFile = true;
679 while (fgets(line, (int)sizeof line, fp)) {
680 ngt_TrimLastChr( line, '\n');
682 /* add text including \0 */
683 if (!array_catb(&Conf_Motd, line, strlen(line) + 1)) {
684 Log(LOG_WARNING, "Cannot add MOTD text: %s", strerror(errno));
692 Read_Config( bool ngircd_starting )
694 /* Read configuration file. */
696 char section[LINE_LEN], str[LINE_LEN], *var, *arg, *ptr;
697 const UINT16 defaultport = 6667;
701 /* Open configuration file */
702 fd = fopen( NGIRCd_ConfFile, "r" );
704 /* No configuration file found! */
705 Config_Error( LOG_ALERT, "Can't read configuration \"%s\": %s",
706 NGIRCd_ConfFile, strerror( errno ));
707 if (!ngircd_starting)
709 Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME );
714 Set_Defaults( ngircd_starting );
716 Config_Error( LOG_INFO, "Reading configuration from \"%s\" ...", NGIRCd_ConfFile );
718 /* Clean up server configuration structure: mark all already
719 * configured servers as "once" so that they are deleted
720 * after the next disconnect and delete all unused servers.
721 * And delete all servers which are "duplicates" of servers
722 * that are already marked as "once" (such servers have been
723 * created by the last rehash but are now useless). */
724 for( i = 0; i < MAX_SERVERS; i++ ) {
725 if( Conf_Server[i].conn_id == NONE ) Init_Server_Struct( &Conf_Server[i] );
727 /* This structure is in use ... */
728 if( Conf_Server[i].flags & CONF_SFLAG_ONCE ) {
729 /* Check for duplicates */
730 for( n = 0; n < MAX_SERVERS; n++ ) {
731 if( n == i ) continue;
733 if( Conf_Server[i].conn_id == Conf_Server[n].conn_id ) {
734 Init_Server_Struct( &Conf_Server[n] );
736 Log(LOG_DEBUG,"Deleted unused duplicate server %d (kept %d).",
742 /* Mark server as "once" */
743 Conf_Server[i].flags |= CONF_SFLAG_ONCE;
744 Log( LOG_DEBUG, "Marked server %d as \"once\"", i );
749 /* Initialize variables */
751 strcpy( section, "" );
752 Init_Server_Struct( &New_Server );
753 New_Server_Idx = NONE;
757 /* Read configuration file */
759 if( ! fgets( str, LINE_LEN, fd )) break;
763 /* Skip comments and empty lines */
764 if( str[0] == ';' || str[0] == '#' || str[0] == '\0' ) continue;
766 /* Is this the beginning of a new section? */
767 if(( str[0] == '[' ) && ( str[strlen( str ) - 1] == ']' )) {
768 strlcpy( section, str, sizeof( section ));
769 if (strcasecmp( section, "[GLOBAL]" ) == 0 ||
770 strcasecmp( section, "[FEATURES]") == 0)
773 if( strcasecmp( section, "[SERVER]" ) == 0 ) {
774 /* Check if there is already a server to add */
775 if( New_Server.name[0] ) {
776 /* Copy data to "real" server structure */
777 assert( New_Server_Idx > NONE );
778 Conf_Server[New_Server_Idx] = New_Server;
781 /* Re-init structure for new server */
782 Init_Server_Struct( &New_Server );
784 /* Search unused item in server configuration structure */
785 for( i = 0; i < MAX_SERVERS; i++ ) {
786 /* Is this item used? */
787 if( ! Conf_Server[i].name[0] ) break;
789 if( i >= MAX_SERVERS ) {
790 /* Oops, no free item found! */
791 Config_Error( LOG_ERR, "Too many servers configured." );
792 New_Server_Idx = NONE;
794 else New_Server_Idx = i;
797 if (strcasecmp(section, "[CHANNEL]") == 0) {
798 Conf_Channel_Count++;
801 if (strcasecmp(section, "[OPERATOR]") == 0) {
806 Config_Error( LOG_ERR, "%s, line %d: Unknown section \"%s\"!", NGIRCd_ConfFile, line, section );
809 if( section[0] == 0x1 ) continue;
811 /* Split line into variable name and parameters */
812 ptr = strchr( str, '=' );
814 Config_Error( LOG_ERR, "%s, line %d: Syntax error!", NGIRCd_ConfFile, line );
818 var = str; ngt_TrimStr( var );
819 arg = ptr + 1; ngt_TrimStr( arg );
821 if( strcasecmp( section, "[GLOBAL]" ) == 0 ) Handle_GLOBAL( line, var, arg );
822 else if( strcasecmp( section, "[FEATURES]" ) == 0 ) Handle_FEATURES( line, var, arg );
823 else if( strcasecmp( section, "[OPERATOR]" ) == 0 ) Handle_OPERATOR( line, var, arg );
824 else if( strcasecmp( section, "[SERVER]" ) == 0 ) Handle_SERVER( line, var, arg );
825 else if( strcasecmp( section, "[CHANNEL]" ) == 0 ) Handle_CHANNEL( line, var, arg );
826 else Config_Error( LOG_ERR, "%s, line %d: Variable \"%s\" outside section!", NGIRCd_ConfFile, line, var );
829 /* Close configuration file */
832 /* Check if there is still a server to add */
833 if( New_Server.name[0] ) {
834 /* Copy data to "real" server structure */
835 assert( New_Server_Idx > NONE );
836 Conf_Server[New_Server_Idx] = New_Server;
839 /* not a single listening port? Add default. */
840 if (no_listenports() &&
841 !array_copyb(&Conf_ListenPorts, (char*) &defaultport, sizeof defaultport))
843 Config_Error(LOG_ALERT, "Could not add default listening Port %u: %s",
844 (unsigned int) defaultport, strerror(errno));
849 if (!Conf_ListenAddress)
850 Conf_ListenAddress = strdup_warn(DEFAULT_LISTEN_ADDRSTR);
852 if (!Conf_ListenAddress) {
853 Config_Error(LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME);
857 /* No MOTD phrase configured? (re)try motd file. */
858 if (array_bytes(&Conf_Motd) == 0)
859 Read_Motd(Conf_MotdFile);
865 Check_ArgIsTrue( const char *Arg )
867 if( strcasecmp( Arg, "yes" ) == 0 ) return true;
868 if( strcasecmp( Arg, "true" ) == 0 ) return true;
869 if( atoi( Arg ) != 0 ) return true;
872 } /* Check_ArgIsTrue */
876 Handle_MaxNickLength(int Line, const char *Arg)
880 new = (unsigned) atoi(Arg) + 1;
881 if (new > CLIENT_NICK_LEN) {
882 Config_Error(LOG_WARNING,
883 "%s, line %d: Value of \"MaxNickLength\" exceeds %u!",
884 NGIRCd_ConfFile, Line, CLIENT_NICK_LEN - 1);
885 return CLIENT_NICK_LEN;
888 Config_Error(LOG_WARNING,
889 "%s, line %d: Value of \"MaxNickLength\" must be at least 1!",
890 NGIRCd_ConfFile, Line);
894 } /* Handle_MaxNickLength */
898 WarnIdent(int UNUSED Line)
902 /* user has enabled ident lookups explicitly, but ... */
903 Config_Error(LOG_WARNING,
904 "%s: line %d: %s=True, but ngircd was built without support",
905 NGIRCd_ConfFile, Line, "Ident");
911 WarnPAM(int UNUSED Line)
915 Config_Error(LOG_WARNING,
916 "%s: line %d: %s=True, but ngircd was built without support",
917 NGIRCd_ConfFile, Line, "PAM");
923 CheckLegacyNoOption(const char *Var, const char *Arg)
925 if( strcasecmp( Var, "NoDNS" ) == 0 ) {
926 Conf_DNS = !Check_ArgIsTrue( Arg );
929 if (strcasecmp(Var, "NoIdent") == 0) {
930 Conf_Ident = !Check_ArgIsTrue(Arg);
933 if(strcasecmp(Var, "NoPAM") == 0) {
934 Conf_PAM = !Check_ArgIsTrue(Arg);
941 NoNo(const char *str)
943 assert(strncasecmp("no", str, 2) == 0 && str[2]);
948 InvertArg(const char *arg)
950 return yesno_to_str(!Check_ArgIsTrue(arg));
954 Handle_GLOBAL( int Line, char *Var, char *Arg )
961 assert( Var != NULL );
962 assert( Arg != NULL );
964 if( strcasecmp( Var, "Name" ) == 0 ) {
966 len = strlcpy( Conf_ServerName, Arg, sizeof( Conf_ServerName ));
967 if (len >= sizeof( Conf_ServerName ))
968 Config_Error_TooLong( Line, Var );
971 if( strcasecmp( Var, "Info" ) == 0 ) {
972 /* Info text of server */
973 len = strlcpy( Conf_ServerInfo, Arg, sizeof( Conf_ServerInfo ));
974 if (len >= sizeof( Conf_ServerInfo ))
975 Config_Error_TooLong ( Line, Var );
978 if( strcasecmp( Var, "Password" ) == 0 ) {
979 /* Global server password */
980 len = strlcpy( Conf_ServerPwd, Arg, sizeof( Conf_ServerPwd ));
981 if (len >= sizeof( Conf_ServerPwd ))
982 Config_Error_TooLong( Line, Var );
985 if (strcasecmp(Var, "WebircPassword") == 0) {
986 /* Password required for WEBIRC command */
987 len = strlcpy(Conf_WebircPwd, Arg, sizeof(Conf_WebircPwd));
988 if (len >= sizeof(Conf_WebircPwd))
989 Config_Error_TooLong(Line, Var);
992 if( strcasecmp( Var, "AdminInfo1" ) == 0 ) {
993 /* Administrative info #1 */
994 len = strlcpy( Conf_ServerAdmin1, Arg, sizeof( Conf_ServerAdmin1 ));
995 if (len >= sizeof( Conf_ServerAdmin1 ))
996 Config_Error_TooLong ( Line, Var );
999 if( strcasecmp( Var, "AdminInfo2" ) == 0 ) {
1000 /* Administrative info #2 */
1001 len = strlcpy( Conf_ServerAdmin2, Arg, sizeof( Conf_ServerAdmin2 ));
1002 if (len >= sizeof( Conf_ServerAdmin2 ))
1003 Config_Error_TooLong ( Line, Var );
1006 if( strcasecmp( Var, "AdminEMail" ) == 0 ) {
1007 /* Administrative email contact */
1008 len = strlcpy( Conf_ServerAdminMail, Arg, sizeof( Conf_ServerAdminMail ));
1009 if (len >= sizeof( Conf_ServerAdminMail ))
1010 Config_Error_TooLong( Line, Var );
1014 if( strcasecmp( Var, "Ports" ) == 0 ) {
1015 ports_parse(&Conf_ListenPorts, Line, Arg);
1018 if( strcasecmp( Var, "MotdFile" ) == 0 ) {
1019 len = strlcpy( Conf_MotdFile, Arg, sizeof( Conf_MotdFile ));
1020 if (len >= sizeof( Conf_MotdFile ))
1021 Config_Error_TooLong( Line, Var );
1024 if( strcasecmp( Var, "MotdPhrase" ) == 0 ) {
1025 /* "Message of the day" phrase (instead of file) */
1029 if (len >= LINE_LEN) {
1030 Config_Error_TooLong( Line, Var );
1033 if (!array_copyb(&Conf_Motd, Arg, len + 1))
1034 Config_Error(LOG_WARNING, "%s, line %d: Could not append MotdPhrase: %s",
1035 NGIRCd_ConfFile, Line, strerror(errno));
1036 Using_MotdFile = false;
1039 if( strcasecmp( Var, "ChrootDir" ) == 0 ) {
1040 /* directory for chroot() */
1041 len = strlcpy( Conf_Chroot, Arg, sizeof( Conf_Chroot ));
1042 if (len >= sizeof( Conf_Chroot ))
1043 Config_Error_TooLong( Line, Var );
1046 if ( strcasecmp( Var, "PidFile" ) == 0 ) {
1047 /* name of pidfile */
1048 len = strlcpy( Conf_PidFile, Arg, sizeof( Conf_PidFile ));
1049 if (len >= sizeof( Conf_PidFile ))
1050 Config_Error_TooLong( Line, Var );
1053 if( strcasecmp( Var, "ServerUID" ) == 0 ) {
1054 /* UID the daemon should switch to */
1055 pwd = getpwnam( Arg );
1056 if( pwd ) Conf_UID = pwd->pw_uid;
1058 Conf_UID = (unsigned int)atoi( Arg );
1059 if (!Conf_UID && strcmp(Arg, "0"))
1060 Config_Error_NaN(Line, Var);
1064 if( strcasecmp( Var, "ServerGID" ) == 0 ) {
1065 /* GID the daemon should use */
1066 grp = getgrnam( Arg );
1067 if( grp ) Conf_GID = grp->gr_gid;
1069 Conf_GID = (unsigned int)atoi(Arg);
1070 if (!Conf_GID && strcmp(Arg, "0"))
1071 Config_Error_NaN( Line, Var );
1075 if( strcasecmp( Var, "PingTimeout" ) == 0 ) {
1077 Conf_PingTimeout = atoi( Arg );
1078 if( Conf_PingTimeout < 5 ) {
1079 Config_Error( LOG_WARNING, "%s, line %d: Value of \"PingTimeout\" too low!",
1080 NGIRCd_ConfFile, Line );
1081 Conf_PingTimeout = 5;
1085 if( strcasecmp( Var, "PongTimeout" ) == 0 ) {
1087 Conf_PongTimeout = atoi( Arg );
1088 if( Conf_PongTimeout < 5 ) {
1089 Config_Error( LOG_WARNING, "%s, line %d: Value of \"PongTimeout\" too low!",
1090 NGIRCd_ConfFile, Line );
1091 Conf_PongTimeout = 5;
1095 if( strcasecmp( Var, "ConnectRetry" ) == 0 ) {
1096 /* Seconds between connection attempts to other servers */
1097 Conf_ConnectRetry = atoi( Arg );
1098 if( Conf_ConnectRetry < 5 ) {
1099 Config_Error( LOG_WARNING, "%s, line %d: Value of \"ConnectRetry\" too low!",
1100 NGIRCd_ConfFile, Line );
1101 Conf_ConnectRetry = 5;
1105 if( strcasecmp( Var, "PredefChannelsOnly" ) == 0 ) {
1106 /* Should we only allow pre-defined-channels? (i.e. users cannot create their own channels) */
1107 Conf_PredefChannelsOnly = Check_ArgIsTrue( Arg );
1111 if (CheckLegacyNoOption(Var, Arg)) {
1112 Config_Error(LOG_WARNING, "%s, line %d: \"No\"-Prefix has been removed, use "
1113 "\"%s = %s\" in [FEATURES] section instead",
1114 NGIRCd_ConfFile, Line, NoNo(Var), InvertArg(Arg));
1115 if (strcasecmp(Var, "NoIdent") == 0)
1117 else if (strcasecmp(Var, "NoPam") == 0)
1122 /* the default setting for all the WANT_IPV6 special options is 'true' */
1123 if( strcasecmp( Var, "ConnectIPv6" ) == 0 ) {
1124 /* connect to other hosts using ipv6, if they have an AAAA record? */
1125 Conf_ConnectIPv6 = Check_ArgIsTrue( Arg );
1128 if( strcasecmp( Var, "ConnectIPv4" ) == 0 ) {
1129 /* connect to other hosts using ipv4.
1130 * again, this can be used for ipv6-only setups */
1131 Conf_ConnectIPv4 = Check_ArgIsTrue( Arg );
1135 if( strcasecmp( Var, "OperCanUseMode" ) == 0 ) {
1136 /* Are IRC operators allowed to use MODE in channels they aren't Op in? */
1137 Conf_OperCanMode = Check_ArgIsTrue( Arg );
1140 if( strcasecmp( Var, "OperServerMode" ) == 0 ) {
1141 /* Mask IRC operator as if coming from the server? (ircd-irc2 compat hack) */
1142 Conf_OperServerMode = Check_ArgIsTrue( Arg );
1145 if(strcasecmp(Var, "AllowRemoteOper") == 0) {
1146 /* Are remote IRC operators allowed to control this server? */
1147 Conf_AllowRemoteOper = Check_ArgIsTrue(Arg);
1150 if( strcasecmp( Var, "MaxConnections" ) == 0 ) {
1151 /* Maximum number of connections. 0 -> "no limit". */
1152 Conf_MaxConnections = atol( Arg );
1153 if (!Conf_MaxConnections && strcmp(Arg, "0"))
1154 Config_Error_NaN(Line, Var);
1157 if( strcasecmp( Var, "MaxConnectionsIP" ) == 0 ) {
1158 /* Maximum number of simultaneous connections from one IP. 0 -> "no limit" */
1159 Conf_MaxConnectionsIP = atoi( Arg );
1160 if (!Conf_MaxConnectionsIP && strcmp(Arg, "0"))
1161 Config_Error_NaN(Line, Var);
1164 if( strcasecmp( Var, "MaxJoins" ) == 0 ) {
1165 /* Maximum number of channels a user can join. 0 -> "no limit". */
1166 Conf_MaxJoins = atoi( Arg );
1167 if (!Conf_MaxJoins && strcmp(Arg, "0"))
1168 Config_Error_NaN(Line, Var);
1171 if( strcasecmp( Var, "MaxNickLength" ) == 0 ) {
1172 /* Maximum length of a nick name; must be same on all servers
1173 * within the IRC network! */
1174 Conf_MaxNickLength = Handle_MaxNickLength(Line, Arg);
1178 if( strcasecmp( Var, "Listen" ) == 0 ) {
1179 /* IP-Address to bind sockets */
1180 if (Conf_ListenAddress) {
1181 Config_Error(LOG_ERR, "Multiple Listen= options, ignoring: %s", Arg);
1184 Conf_ListenAddress = strdup_warn(Arg);
1186 * if allocation fails, we're in trouble:
1187 * we cannot ignore the error -- otherwise ngircd
1188 * would listen on all interfaces.
1190 if (!Conf_ListenAddress) {
1191 Config_Error(LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME);
1198 if( strcasecmp( Var, "SSLPorts" ) == 0 ) {
1199 ports_parse(&Conf_SSLOptions.ListenPorts, Line, Arg);
1203 if( strcasecmp( Var, "SSLKeyFile" ) == 0 ) {
1204 assert(Conf_SSLOptions.KeyFile == NULL );
1205 Conf_SSLOptions.KeyFile = strdup_warn(Arg);
1208 if( strcasecmp( Var, "SSLCertFile" ) == 0 ) {
1209 assert(Conf_SSLOptions.CertFile == NULL );
1210 Conf_SSLOptions.CertFile = strdup_warn(Arg);
1214 if( strcasecmp( Var, "SSLKeyFilePassword" ) == 0 ) {
1215 assert(array_bytes(&Conf_SSLOptions.KeyFilePassword) == 0);
1216 if (!array_copys(&Conf_SSLOptions.KeyFilePassword, Arg))
1217 Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Could not copy %s: %s!",
1218 NGIRCd_ConfFile, Line, Var, strerror(errno));
1221 if( strcasecmp( Var, "SSLDHFile" ) == 0 ) {
1222 assert(Conf_SSLOptions.DHFile == NULL);
1223 Conf_SSLOptions.DHFile = strdup_warn( Arg );
1228 if (strcasecmp(Var, "SyslogFacility") == 0) {
1229 Conf_SyslogFacility = ngt_SyslogFacilityID(Arg,
1230 Conf_SyslogFacility);
1234 Config_Error(LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!",
1235 NGIRCd_ConfFile, Line, Var);
1236 } /* Handle_GLOBAL */
1240 Handle_FEATURES(int Line, char *Var, char *Arg)
1243 assert( Var != NULL );
1244 assert( Arg != NULL );
1246 if( strcasecmp( Var, "DNS" ) == 0 ) {
1247 /* do reverse dns lookups when clients connect? */
1248 Conf_DNS = Check_ArgIsTrue( Arg );
1251 if (strcasecmp(Var, "Ident") == 0) {
1252 /* do IDENT lookups when clients connect? */
1253 Conf_Ident = Check_ArgIsTrue(Arg);
1257 if(strcasecmp(Var, "PAM") == 0) {
1258 /* use PAM library to authenticate users */
1259 Conf_PAM = Check_ArgIsTrue(Arg);
1266 Handle_OPERATOR( int Line, char *Var, char *Arg )
1269 struct Conf_Oper *op;
1272 assert( Var != NULL );
1273 assert( Arg != NULL );
1274 assert( Conf_Oper_Count > 0 );
1276 op = array_alloc(&Conf_Opers, sizeof(*op), Conf_Oper_Count - 1);
1278 Config_Error(LOG_ERR, "Could not allocate memory for operator (%d:%s = %s)", Line, Var, Arg);
1282 if (strcasecmp(Var, "Name") == 0) {
1283 /* Name of IRC operator */
1284 len = strlcpy(op->name, Arg, sizeof(op->name));
1285 if (len >= sizeof(op->name))
1286 Config_Error_TooLong(Line, Var);
1289 if (strcasecmp(Var, "Password") == 0) {
1290 /* Password of IRC operator */
1291 len = strlcpy(op->pwd, Arg, sizeof(op->pwd));
1292 if (len >= sizeof(op->pwd))
1293 Config_Error_TooLong(Line, Var);
1296 if (strcasecmp(Var, "Mask") == 0) {
1298 return; /* Hostname already configured */
1299 op->mask = strdup_warn( Arg );
1302 Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!",
1303 NGIRCd_ConfFile, Line, Var );
1304 } /* Handle_OPERATOR */
1308 Handle_SERVER( int Line, char *Var, char *Arg )
1314 assert( Var != NULL );
1315 assert( Arg != NULL );
1317 /* Ignore server block if no space is left in server configuration structure */
1318 if( New_Server_Idx <= NONE ) return;
1320 if( strcasecmp( Var, "Host" ) == 0 ) {
1321 /* Hostname of the server */
1322 len = strlcpy( New_Server.host, Arg, sizeof( New_Server.host ));
1323 if (len >= sizeof( New_Server.host ))
1324 Config_Error_TooLong ( Line, Var );
1327 if( strcasecmp( Var, "Name" ) == 0 ) {
1328 /* Name of the server ("Nick"/"ID") */
1329 len = strlcpy( New_Server.name, Arg, sizeof( New_Server.name ));
1330 if (len >= sizeof( New_Server.name ))
1331 Config_Error_TooLong( Line, Var );
1334 if (strcasecmp(Var, "Bind") == 0) {
1335 if (ng_ipaddr_init(&New_Server.bind_addr, Arg, 0))
1338 Config_Error(LOG_ERR, "%s, line %d (section \"Server\"): Can't parse IP address \"%s\"",
1339 NGIRCd_ConfFile, Line, Arg);
1342 if( strcasecmp( Var, "MyPassword" ) == 0 ) {
1343 /* Password of this server which is sent to the peer */
1345 Config_Error(LOG_ERR,
1346 "%s, line %d (section \"Server\"): MyPassword must not start with ':'!",
1347 NGIRCd_ConfFile, Line);
1349 len = strlcpy( New_Server.pwd_in, Arg, sizeof( New_Server.pwd_in ));
1350 if (len >= sizeof( New_Server.pwd_in ))
1351 Config_Error_TooLong( Line, Var );
1354 if( strcasecmp( Var, "PeerPassword" ) == 0 ) {
1355 /* Passwort of the peer which must be received */
1356 len = strlcpy( New_Server.pwd_out, Arg, sizeof( New_Server.pwd_out ));
1357 if (len >= sizeof( New_Server.pwd_out ))
1358 Config_Error_TooLong( Line, Var );
1361 if( strcasecmp( Var, "Port" ) == 0 ) {
1362 /* Port to which this server should connect */
1364 if( port > 0 && port < 0xFFFF )
1365 New_Server.port = (UINT16)port;
1367 Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Illegal port number %ld!",
1368 NGIRCd_ConfFile, Line, port );
1372 if( strcasecmp( Var, "SSLConnect" ) == 0 ) {
1373 New_Server.SSLConnect = Check_ArgIsTrue(Arg);
1377 if( strcasecmp( Var, "Group" ) == 0 ) {
1379 New_Server.group = atoi( Arg );
1380 if (!New_Server.group && strcmp(Arg, "0"))
1381 Config_Error_NaN(Line, Var);
1384 if( strcasecmp( Var, "Passive" ) == 0 ) {
1385 if (Check_ArgIsTrue(Arg))
1386 New_Server.flags |= CONF_SFLAG_DISABLED;
1389 if (strcasecmp(Var, "ServiceMask") == 0) {
1390 len = strlcpy(New_Server.svs_mask, ngt_LowerStr(Arg),
1391 sizeof(New_Server.svs_mask));
1392 if (len >= sizeof(New_Server.svs_mask))
1393 Config_Error_TooLong(Line, Var);
1397 Config_Error( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!",
1398 NGIRCd_ConfFile, Line, Var );
1399 } /* Handle_SERVER */
1403 Handle_Channelname(struct Conf_Channel *new_chan, const char *name)
1405 size_t size = sizeof(new_chan->name);
1406 char *dest = new_chan->name;
1408 if (!Channel_IsValidName(name)) {
1410 * maybe user forgot to add a '#'.
1411 * This is only here for user convenience.
1417 return size > strlcpy(dest, name, size);
1422 Handle_CHANNEL(int Line, char *Var, char *Arg)
1426 struct Conf_Channel *chan;
1429 assert( Var != NULL );
1430 assert( Arg != NULL );
1431 assert(Conf_Channel_Count > 0);
1433 chancount = Conf_Channel_Count - 1;
1435 chan = array_alloc(&Conf_Channels, sizeof(*chan), chancount);
1437 Config_Error(LOG_ERR, "Could not allocate memory for predefined channel (%d:%s = %s)", Line, Var, Arg);
1440 if (strcasecmp(Var, "Name") == 0) {
1441 if (!Handle_Channelname(chan, Arg))
1442 Config_Error_TooLong(Line, Var);
1445 if (strcasecmp(Var, "Modes") == 0) {
1447 len = strlcpy(chan->modes, Arg, sizeof(chan->modes));
1448 if (len >= sizeof(chan->modes))
1449 Config_Error_TooLong( Line, Var );
1452 if( strcasecmp( Var, "Topic" ) == 0 ) {
1454 len = strlcpy(chan->topic, Arg, sizeof(chan->topic));
1455 if (len >= sizeof(chan->topic))
1456 Config_Error_TooLong( Line, Var );
1459 if( strcasecmp( Var, "Key" ) == 0 ) {
1460 /* Initial Channel Key (mode k) */
1461 len = strlcpy(chan->key, Arg, sizeof(chan->key));
1462 if (len >= sizeof(chan->key))
1463 Config_Error_TooLong(Line, Var);
1466 if( strcasecmp( Var, "MaxUsers" ) == 0 ) {
1467 /* maximum user limit, mode l */
1468 chan->maxusers = (unsigned long) atol(Arg);
1469 if (!chan->maxusers && strcmp(Arg, "0"))
1470 Config_Error_NaN(Line, Var);
1473 if (strcasecmp(Var, "KeyFile") == 0) {
1475 len = strlcpy(chan->keyfile, Arg, sizeof(chan->keyfile));
1476 if (len >= sizeof(chan->keyfile))
1477 Config_Error_TooLong(Line, Var);
1481 Config_Error( LOG_ERR, "%s, line %d (section \"Channel\"): Unknown variable \"%s\"!",
1482 NGIRCd_ConfFile, Line, Var );
1483 } /* Handle_CHANNEL */
1487 Validate_Config(bool Configtest, bool Rehash)
1489 /* Validate configuration settings. */
1492 int i, servers, servers_once;
1494 bool config_valid = true;
1497 /* Validate configured server name, see RFC 2812 section 2.3.1 */
1498 ptr = Conf_ServerName;
1500 if (*ptr >= 'a' && *ptr <= 'z') continue;
1501 if (*ptr >= 'A' && *ptr <= 'Z') continue;
1502 if (*ptr >= '0' && *ptr <= '9') continue;
1503 if (ptr > Conf_ServerName) {
1504 if (*ptr == '.' || *ptr == '-')
1507 Conf_ServerName[0] = '\0';
1511 if (!Conf_ServerName[0]) {
1512 /* No server name configured! */
1513 config_valid = false;
1514 Config_Error(LOG_ALERT,
1515 "No (valid) server name configured in \"%s\" (section 'Global': 'Name')!",
1517 if (!Configtest && !Rehash) {
1518 Config_Error(LOG_ALERT,
1519 "%s exiting due to fatal errors!",
1525 if (Conf_ServerName[0] && !strchr(Conf_ServerName, '.')) {
1526 /* No dot in server name! */
1527 config_valid = false;
1528 Config_Error(LOG_ALERT,
1529 "Invalid server name configured in \"%s\" (section 'Global': 'Name'): Dot missing!",
1532 Config_Error(LOG_ALERT,
1533 "%s exiting due to fatal errors!",
1540 if (!Conf_ServerAdminMail[0]) {
1541 /* No administrative contact configured! */
1542 config_valid = false;
1543 Config_Error(LOG_ALERT,
1544 "No administrator email address configured in \"%s\" ('AdminEMail')!",
1547 Config_Error(LOG_ALERT,
1548 "%s exiting due to fatal errors!",
1555 if (!Conf_ServerAdmin1[0] && !Conf_ServerAdmin2[0]
1556 && !Conf_ServerAdminMail[0]) {
1557 /* No administrative information configured! */
1558 Config_Error(LOG_WARNING,
1559 "No administrative information configured but required by RFC!");
1563 if (Conf_ServerPwd[0])
1564 Config_Error(LOG_ERR,
1565 "This server uses PAM, \"Password\" will be ignored!");
1569 servers = servers_once = 0;
1570 for (i = 0; i < MAX_SERVERS; i++) {
1571 if (Conf_Server[i].name[0]) {
1573 if (Conf_Server[i].flags & CONF_SFLAG_ONCE)
1578 "Configuration: Operators=%d, Servers=%d[%d], Channels=%d",
1579 Conf_Oper_Count, servers, servers_once, Conf_Channel_Count);
1582 return config_valid;
1583 } /* Validate_Config */
1587 Config_Error_TooLong ( const int Line, const char *Item )
1589 Config_Error( LOG_WARNING, "%s, line %d: Value of \"%s\" too long!", NGIRCd_ConfFile, Line, Item );
1594 Config_Error_NaN( const int Line, const char *Item )
1596 Config_Error( LOG_WARNING, "%s, line %d: Value of \"%s\" is not a number!",
1597 NGIRCd_ConfFile, Line, Item );
1602 static void Config_Error( const int Level, const char *Format, ... )
1604 static void Config_Error( Level, Format, va_alist )
1610 /* Error! Write to console and/or logfile. */
1612 char msg[MAX_LOG_MSG_LEN];
1615 assert( Format != NULL );
1618 va_start( ap, Format );
1622 vsnprintf( msg, MAX_LOG_MSG_LEN, Format, ap );
1625 /* During "normal operations" the log functions of the daemon should
1626 * be used, but during testing of the configuration file, all messages
1627 * should go directly to the console: */
1628 if (Use_Log) Log( Level, "%s", msg );
1630 } /* Config_Error */
1636 Conf_DebugDump(void)
1640 Log(LOG_DEBUG, "Configured servers:");
1641 for (i = 0; i < MAX_SERVERS; i++) {
1642 if (! Conf_Server[i].name[0])
1645 " - %s: %s:%d, last=%ld, group=%d, flags=%d, conn=%d",
1646 Conf_Server[i].name, Conf_Server[i].host,
1647 Conf_Server[i].port, Conf_Server[i].lasttry,
1648 Conf_Server[i].group, Conf_Server[i].flags,
1649 Conf_Server[i].conn_id);
1651 } /* Conf_DebugDump */
1657 Init_Server_Struct( CONF_SERVER *Server )
1659 /* Initialize server configuration structur to default values */
1661 assert( Server != NULL );
1663 memset( Server, 0, sizeof (CONF_SERVER) );
1665 Server->group = NONE;
1666 Server->lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY;
1668 if( NGIRCd_Passive ) Server->flags = CONF_SFLAG_DISABLED;
1670 Proc_InitStruct(&Server->res_stat);
1671 Server->conn_id = NONE;
1672 memset(&Server->bind_addr, 0, sizeof(&Server->bind_addr));
1673 } /* Init_Server_Struct */