X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fconf.c;h=a99fee2bb6b6c16dd4c395797c4edd1eb48f1f97;hp=4e6137acfce5620dc4121ceb87fddd57c393ccd8;hb=7049b60af48382ce5f4623d32c5fca6d0c9f4fc5;hpb=ed406b4a930a330444c693d648f469537453a3d3 diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 4e6137ac..a99fee2b 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -9,47 +9,15 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: conf.c,v 1.10 2002/01/03 02:27:20 alex Exp $ + * $Id: conf.c,v 1.18 2002/03/12 14:37:52 alex Exp $ * * conf.h: Konfiguration des ngircd - * - * $Log: conf.c,v $ - * Revision 1.10 2002/01/03 02:27:20 alex - * - das Server-Passwort kann nun konfiguriert werden. - * - * Revision 1.9 2002/01/02 02:49:15 alex - * - Konfigurationsdatei "Samba like" umgestellt. - * - es koennen nun mehrere Server und Oprtatoren konfiguriert werden. - * - * Revision 1.7 2002/01/01 18:25:44 alex - * - #include's fuer stdlib.h ergaenzt. - * - * Revision 1.6 2001/12/31 02:18:51 alex - * - viele neue Befehle (WHOIS, ISON, OPER, DIE, RESTART), - * - neuen Header "defines.h" mit (fast) allen Konstanten. - * - Code Cleanups und viele "kleine" Aenderungen & Bugfixes. - * - * Revision 1.5 2001/12/30 19:26:11 alex - * - Unterstuetzung fuer die Konfigurationsdatei eingebaut. - * - * Revision 1.4 2001/12/26 22:48:53 alex - * - MOTD-Datei ist nun konfigurierbar und wird gelesen. - * - * Revision 1.3 2001/12/26 14:45:37 alex - * - "Code Cleanups". - * - * Revision 1.2 2001/12/26 03:19:57 alex - * - erste Konfigurations-Variablen definiert: PING/PONG-Timeout. - * - * Revision 1.1 2001/12/12 17:18:20 alex - * - Modul fuer Server-Konfiguration begonnen. */ -#include -#include "global.h" +#include "portab.h" -#include +#include "imp.h" #include #include #include @@ -57,10 +25,11 @@ #include #include "client.h" +#include "defines.h" #include "log.h" #include "tool.h" -#include +#include "exp.h" #include "conf.h" @@ -78,13 +47,13 @@ GLOBAL VOID Conf_Init( VOID ) /* Konfigurationsvariablen initialisieren: zunaechst Default- * Werte setzen, dann Konfigurationsdtaei einlesen. */ - strcpy( Conf_File, "/usr/local/etc/ngircd.conf" ); + strcpy( Conf_File, CONFIG_FILE ); strcpy( Conf_ServerName, "" ); strcpy( Conf_ServerInfo, PACKAGE" "VERSION ); strcpy( Conf_ServerPwd, "" ); - strcpy( Conf_MotdFile, "/usr/local/etc/ngircd.motd" ); + strcpy( Conf_MotdFile, MOTD_FILE ); Conf_ListenPorts_Count = 0; @@ -165,7 +134,8 @@ LOCAL VOID Read_Config( VOID ) strcpy( Conf_Server[Conf_Server_Count].name, "" ); strcpy( Conf_Server[Conf_Server_Count].pwd, "" ); Conf_Server[Conf_Server_Count].port = 0; - Conf_Server[Conf_Server_Count].lasttry = 0; + Conf_Server[Conf_Server_Count].group = -1; + Conf_Server[Conf_Server_Count].lasttry = time( NULL ) - Conf_ConnectRetry + STARTUP_DELAY; Conf_Server[Conf_Server_Count].res_stat = NULL; Conf_Server_Count++; } @@ -209,21 +179,21 @@ GLOBAL VOID Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg ) if( strcasecmp( Var, "Name" ) == 0 ) { /* Der Server-Name */ - strncpy( Conf_ServerName, Arg, CLIENT_ID_LEN ); + strncpy( Conf_ServerName, Arg, CLIENT_ID_LEN - 1 ); Conf_ServerName[CLIENT_ID_LEN - 1] = '\0'; return; } if( strcasecmp( Var, "Info" ) == 0 ) { /* Server-Info-Text */ - strncpy( Conf_ServerInfo, Arg, CLIENT_INFO_LEN ); + strncpy( Conf_ServerInfo, Arg, CLIENT_INFO_LEN - 1 ); Conf_ServerInfo[CLIENT_INFO_LEN - 1] = '\0'; return; } if( strcasecmp( Var, "Password" ) == 0 ) { - /* Der Server-Name */ - strncpy( Conf_ServerPwd, Arg, CLIENT_PASS_LEN ); + /* Server-Passwort */ + strncpy( Conf_ServerPwd, Arg, CLIENT_PASS_LEN - 1 ); Conf_ServerPwd[CLIENT_PASS_LEN - 1] = '\0'; return; } @@ -249,7 +219,7 @@ GLOBAL VOID Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg ) if( strcasecmp( Var, "MotdFile" ) == 0 ) { /* Datei mit der "message of the day" (MOTD) */ - strncpy( Conf_MotdFile, Arg, FNAME_LEN ); + strncpy( Conf_MotdFile, Arg, FNAME_LEN - 1 ); Conf_MotdFile[FNAME_LEN - 1] = '\0'; return; } @@ -289,14 +259,14 @@ GLOBAL VOID Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg ) if( strcasecmp( Var, "Name" ) == 0 ) { /* Name des IRC Operator */ - strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_ID_LEN ); + strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_ID_LEN - 1 ); Conf_Oper[Conf_Oper_Count - 1].name[CLIENT_ID_LEN - 1] = '\0'; return; } if( strcasecmp( Var, "Password" ) == 0 ) { /* Passwort des IRC Operator */ - strncpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, CLIENT_PASS_LEN ); + strncpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 ); Conf_Oper[Conf_Oper_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0'; return; } @@ -307,7 +277,7 @@ GLOBAL VOID Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg ) GLOBAL VOID Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg ) { - INT port; + INT32 port; assert( Line > 0 ); assert( Var != NULL ); @@ -316,21 +286,21 @@ GLOBAL VOID Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg ) if( strcasecmp( Var, "Host" ) == 0 ) { /* Hostname des Servers */ - strncpy( Conf_Server[Conf_Server_Count - 1].host, Arg, HOST_LEN ); + strncpy( Conf_Server[Conf_Server_Count - 1].host, Arg, HOST_LEN - 1 ); Conf_Server[Conf_Server_Count - 1].host[HOST_LEN - 1] = '\0'; return; } if( strcasecmp( Var, "Name" ) == 0 ) { /* Name des Servers ("Nick") */ - strncpy( Conf_Server[Conf_Server_Count - 1].name, Arg, CLIENT_PASS_LEN ); - Conf_Server[Conf_Server_Count - 1].name[CLIENT_PASS_LEN - 1] = '\0'; + strncpy( Conf_Server[Conf_Server_Count - 1].name, Arg, CLIENT_ID_LEN - 1 ); + Conf_Server[Conf_Server_Count - 1].name[CLIENT_ID_LEN - 1] = '\0'; return; } if( strcasecmp( Var, "Password" ) == 0 ) { /* Passwort des Servers */ - strncpy( Conf_Server[Conf_Server_Count - 1].pwd, Arg, CLIENT_PASS_LEN ); + strncpy( Conf_Server[Conf_Server_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 ); Conf_Server[Conf_Server_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0'; return; } @@ -338,10 +308,16 @@ GLOBAL VOID Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg ) { /* Port, zu dem Verbunden werden soll */ port = atol( Arg ); - if( port > 0 && port < 0xFFFF ) Conf_Server[Conf_Server_Count - 1].port = port; + if( port > 0 && port < 0xFFFF ) Conf_Server[Conf_Server_Count - 1].port = (INT)port; else Log( LOG_ERR, "%s, line %d (section \"Server\"): Illegal port number %ld!", Conf_File, Line, port ); return; } + if( strcasecmp( Var, "Group" ) == 0 ) + { + /* Server-Gruppe */ + Conf_Server[Conf_Server_Count - 1].group = atoi( Arg ); + return; + } Log( LOG_ERR, "%s, line %d (section \"Server\"): Unknown variable \"%s\"!", Conf_File, Line, Var ); } /* Handle_SERVER */ @@ -354,7 +330,7 @@ LOCAL VOID Validate_Config( VOID ) if( ! Conf_ServerName[0] ) { /* Kein Servername konfiguriert */ - Log( LOG_ALERT, "No server name configured (use \"ServerName\")!", Conf_File, strerror( errno )); + Log( LOG_ALERT, "No server name configured in \"%s\"!", Conf_File ); Log( LOG_ALERT, PACKAGE" exiting due to fatal errors!" ); exit( 1 ); }