* 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.28 2002/09/02 14:59:17 alex Exp $
+ * $Id: conf.c,v 1.37 2002/11/18 18:47:42 alex Exp $
*
* conf.h: Konfiguration des ngircd
*/
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <pwd.h>
+#include <grp.h>
+#include <sys/types.h>
#include "ngircd.h"
#include "conn.h"
{
/* Konfiguration einlesen, ueberpruefen und ausgeben. */
- UINT i;
+ struct passwd *pwd;
+ struct group *grp;
+ INT i;
Use_Log = FALSE;
Set_Defaults( );
printf( " ServerName = %s\n", Conf_ServerName );
printf( " ServerInfo = %s\n", Conf_ServerInfo );
printf( " ServerPwd = %s\n", Conf_ServerPwd );
+ printf( " AdminInfo1 = %s\n", Conf_ServerAdmin1 );
+ printf( " AdminInfo2 = %s\n", Conf_ServerAdmin2 );
+ printf( " AdminEMail = %s\n", Conf_ServerAdminMail );
printf( " MotdFile = %s\n", Conf_MotdFile );
- printf( " ListenPorts = " );
+ printf( " Ports = " );
for( i = 0; i < Conf_ListenPorts_Count; i++ )
{
if( i != 0 ) printf( ", " );
printf( "%u", Conf_ListenPorts[i] );
}
puts( "" );
- printf( " ServerUID = %ld\n", (INT32)Conf_UID );
- printf( " ServerGID = %ld\n", (INT32)Conf_GID );
+ pwd = getpwuid( Conf_UID );
+ if( pwd ) printf( " ServerUID = %s\n", pwd->pw_name );
+ else printf( " ServerUID = %ld\n", (LONG)Conf_UID );
+ grp = getgrgid( Conf_GID );
+ if( grp ) printf( " ServerGID = %s\n", grp->gr_name );
+ else printf( " ServerGID = %ld\n", (LONG)Conf_GID );
printf( " PingTimeout = %d\n", Conf_PingTimeout );
printf( " PongTimeout = %d\n", Conf_PongTimeout );
printf( " ConnectRetry = %d\n", Conf_ConnectRetry );
printf( " OperCanUseMode = %s\n", Conf_OperCanMode == TRUE ? "yes" : "no" );
+ if( Conf_MaxConnections > 0 ) printf( " MaxConnections = %ld\n", Conf_MaxConnections );
+ else printf( " MaxConnections = -1\n" );
puts( "" );
for( i = 0; i < Conf_Oper_Count; i++ )
sprintf( Conf_ServerInfo, "%s %s", PACKAGE, VERSION );
strcpy( Conf_ServerPwd, "" );
+ strcpy( Conf_ServerAdmin1, "" );
+ strcpy( Conf_ServerAdmin2, "" );
+ strcpy( Conf_ServerAdminMail, "" );
+
strcpy( Conf_MotdFile, MOTD_FILE );
Conf_ListenPorts_Count = 0;
Conf_Channel_Count = 0;
Conf_OperCanMode = FALSE;
+
+ Conf_MaxConnections = 0;
} /* Set_Defaults */
LOCAL VOID
Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
{
+ struct passwd *pwd;
+ struct group *grp;
CHAR *ptr;
- INT32 port;
+ LONG port;
assert( Line > 0 );
assert( Var != NULL );
Conf_ServerPwd[CLIENT_PASS_LEN - 1] = '\0';
return;
}
+ if( strcasecmp( Var, "AdminInfo1" ) == 0 )
+ {
+ /* Server-Info-Text */
+ strncpy( Conf_ServerAdmin1, Arg, CLIENT_INFO_LEN - 1 );
+ Conf_ServerAdmin1[CLIENT_INFO_LEN - 1] = '\0';
+ return;
+ }
+ if( strcasecmp( Var, "AdminInfo2" ) == 0 )
+ {
+ /* Server-Info-Text */
+ strncpy( Conf_ServerAdmin2, Arg, CLIENT_INFO_LEN - 1 );
+ Conf_ServerAdmin2[CLIENT_INFO_LEN - 1] = '\0';
+ return;
+ }
+ if( strcasecmp( Var, "AdminEMail" ) == 0 )
+ {
+ /* Server-Info-Text */
+ strncpy( Conf_ServerAdminMail, Arg, CLIENT_INFO_LEN - 1 );
+ Conf_ServerAdminMail[CLIENT_INFO_LEN - 1] = '\0';
+ return;
+ }
if( strcasecmp( Var, "Ports" ) == 0 )
{
/* Ports, durch "," getrennt, auf denen der Server
if( strcasecmp( Var, "ServerUID" ) == 0 )
{
/* UID, mit der der Daemon laufen soll */
- Conf_UID = (UINT)atoi( Arg );
+ pwd = getpwnam( Arg );
+ if( pwd ) Conf_UID = pwd->pw_uid;
+ else Conf_UID = (UINT)atoi( Arg );
return;
}
if( strcasecmp( Var, "ServerGID" ) == 0 )
{
/* GID, mit der der Daemon laufen soll */
- Conf_GID = (UINT)atoi( Arg );
+ grp = getgrnam( Arg );
+ if( grp ) Conf_GID = grp->gr_gid;
+ else Conf_GID = (UINT)atoi( Arg );
return;
}
if( strcasecmp( Var, "PingTimeout" ) == 0 )
else Conf_OperCanMode = FALSE;
return;
}
+ if( strcasecmp( Var, "MaxConnections" ) == 0 )
+ {
+ /* Maximale Anzahl von Verbindungen. Werte <= 0 stehen
+ * fuer "kein Limit". */
+ Conf_MaxConnections = atol( Arg );
+ return;
+ }
Config_Error( LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var );
} /* Handle_GLOBAL */
if( strcasecmp( Var, "Name" ) == 0 )
{
/* Name des IRC Operator */
- 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';
+ strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_PASS_LEN - 1 );
+ Conf_Oper[Conf_Oper_Count - 1].name[CLIENT_PASS_LEN - 1] = '\0';
return;
}
if( strcasecmp( Var, "Password" ) == 0 )
LOCAL VOID
Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
{
- INT32 port;
+ LONG port;
assert( Line > 0 );
assert( Var != NULL );
if( ! Conf_ServerName[0] )
{
/* Kein Servername konfiguriert */
- Config_Error( LOG_ALERT, "No server name configured in \"%s\"!", NGIRCd_ConfFile );
+ Config_Error( LOG_ALERT, "No server name configured in \"%s\" ('ServerName')!", NGIRCd_ConfFile );
Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
exit( 1 );
}
+
+#ifdef STRICT_RFC
+ if( ! Conf_ServerAdminMail[0] )
+ {
+ /* Keine Server-Information konfiguriert */
+ Config_Error( LOG_ALERT, "No administrator email address configured in \"%s\" ('AdminEMail')!", NGIRCd_ConfFile );
+ Config_Error( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE );
+ exit( 1 );
+ }
+#endif
+
+ if( ! Conf_ServerAdmin1[0] && ! Conf_ServerAdmin2[0] && ! Conf_ServerAdminMail[0] )
+ {
+ /* Keine Server-Information konfiguriert */
+ Log( LOG_WARNING, "No server information configured but required by RFC!" );
+ }
} /* Validate_Config */
/* Im "normalen Betrieb" soll der Log-Mechanismus des ngIRCd verwendet
* werden, beim Testen der Konfiguration jedoch nicht, hier sollen alle
* Meldungen direkt auf die Konsole ausgegeben werden: */
- if( Use_Log ) Log( Level, msg );
+ if( Use_Log ) Log( Level, "%s", msg );
else puts( msg );
} /* Config_Error */