2001-12-11 22:53:04 +01:00
|
|
|
/*
|
|
|
|
* ngIRCd -- The Next Generation IRC Daemon
|
2002-01-02 03:44:36 +01:00
|
|
|
* Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
|
2001-12-11 22:53:04 +01:00
|
|
|
*
|
|
|
|
* Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
|
|
|
|
* der GNU General Public License (GPL), wie von der Free Software Foundation
|
|
|
|
* herausgegeben, weitergeben und/oder modifizieren, entweder unter Version 2
|
|
|
|
* der Lizenz oder (wenn Sie es wuenschen) jeder spaeteren Version.
|
|
|
|
* Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste
|
2001-12-31 03:18:51 +01:00
|
|
|
* der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS.
|
2001-12-11 22:53:04 +01:00
|
|
|
*
|
2002-03-31 15:20:42 +02:00
|
|
|
* $Id: ngircd.c,v 1.41 2002/03/31 13:20:42 alex Exp $
|
2001-12-11 22:53:04 +01:00
|
|
|
*
|
|
|
|
* ngircd.c: Hier beginnt alles ;-)
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2002-03-12 15:37:51 +01:00
|
|
|
#include "portab.h"
|
2001-12-11 23:04:21 +01:00
|
|
|
|
2002-03-12 15:37:51 +01:00
|
|
|
#include "imp.h"
|
2001-12-11 22:53:04 +01:00
|
|
|
#include <assert.h>
|
2002-01-12 01:17:28 +01:00
|
|
|
#include <errno.h>
|
2001-12-11 22:53:04 +01:00
|
|
|
#include <stdio.h>
|
2001-12-12 18:21:21 +01:00
|
|
|
#include <signal.h>
|
2002-01-11 15:45:18 +01:00
|
|
|
#include <string.h>
|
2002-01-12 01:17:28 +01:00
|
|
|
#include <unistd.h>
|
2002-01-02 03:44:36 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
2001-12-30 12:42:00 +01:00
|
|
|
#include <time.h>
|
2001-12-12 18:21:21 +01:00
|
|
|
|
2001-12-14 09:15:26 +01:00
|
|
|
#include "channel.h"
|
|
|
|
#include "client.h"
|
2001-12-12 18:21:21 +01:00
|
|
|
#include "conf.h"
|
|
|
|
#include "conn.h"
|
2002-03-12 15:37:51 +01:00
|
|
|
#include "defines.h"
|
2001-12-14 09:15:26 +01:00
|
|
|
#include "irc.h"
|
2001-12-11 22:53:04 +01:00
|
|
|
#include "log.h"
|
2001-12-21 23:24:50 +01:00
|
|
|
#include "parse.h"
|
2001-12-11 22:53:04 +01:00
|
|
|
|
2002-03-12 15:37:51 +01:00
|
|
|
#include "exp.h"
|
2001-12-11 22:53:04 +01:00
|
|
|
#include "ngircd.h"
|
|
|
|
|
|
|
|
|
2001-12-12 18:21:21 +01:00
|
|
|
LOCAL VOID Initialize_Signal_Handler( VOID );
|
2001-12-11 22:53:04 +01:00
|
|
|
LOCAL VOID Signal_Handler( INT Signal );
|
|
|
|
|
2001-12-30 20:26:11 +01:00
|
|
|
LOCAL VOID Initialize_Listen_Ports( VOID );
|
|
|
|
|
2002-01-11 15:45:18 +01:00
|
|
|
LOCAL VOID Show_Version( VOID );
|
|
|
|
LOCAL VOID Show_Help( VOID );
|
|
|
|
|
2001-12-11 22:53:04 +01:00
|
|
|
|
2002-03-25 20:11:01 +01:00
|
|
|
GLOBAL int main( int argc, const char *argv[] )
|
2001-12-11 22:53:04 +01:00
|
|
|
{
|
2002-03-27 17:41:25 +01:00
|
|
|
BOOLEAN ok, configtest = FALSE;
|
2002-03-25 20:11:01 +01:00
|
|
|
INT32 pid, n;
|
|
|
|
INT i;
|
2002-01-11 15:45:18 +01:00
|
|
|
|
|
|
|
NGIRCd_Restart = FALSE;
|
|
|
|
NGIRCd_Quit = FALSE;
|
|
|
|
NGIRCd_NoDaemon = FALSE;
|
2002-02-19 21:08:24 +01:00
|
|
|
NGIRCd_Passive = FALSE;
|
2002-01-11 15:45:18 +01:00
|
|
|
#ifdef DEBUG
|
|
|
|
NGIRCd_Debug = FALSE;
|
|
|
|
#endif
|
2002-01-18 12:12:11 +01:00
|
|
|
#ifdef SNIFFER
|
|
|
|
NGIRCd_Sniffer = FALSE;
|
|
|
|
#endif
|
2002-03-27 17:41:25 +01:00
|
|
|
strcpy( NGIRCd_ConfFile, CONFIG_FILE );
|
2002-01-11 15:45:18 +01:00
|
|
|
|
|
|
|
/* Kommandozeile parsen */
|
|
|
|
for( i = 1; i < argc; i++ )
|
|
|
|
{
|
|
|
|
ok = FALSE;
|
|
|
|
if(( argv[i][0] == '-' ) && ( argv[i][1] == '-' ))
|
|
|
|
{
|
|
|
|
/* Lange Option */
|
|
|
|
|
2002-03-28 15:15:33 +01:00
|
|
|
if( strcmp( argv[i], "--config" ) == 0 )
|
|
|
|
{
|
|
|
|
if( i + 1 < argc )
|
|
|
|
{
|
|
|
|
/* Ok, danach kommt noch ein Parameter */
|
|
|
|
strncpy( NGIRCd_ConfFile, argv[i + 1], FNAME_LEN - 1 );
|
|
|
|
NGIRCd_ConfFile[FNAME_LEN - 1] = '\0';
|
|
|
|
|
|
|
|
/* zum uebernaechsten Parameter */
|
|
|
|
i++; ok = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2002-03-27 17:41:25 +01:00
|
|
|
if( strcmp( argv[i], "--configtest" ) == 0 )
|
|
|
|
{
|
|
|
|
configtest = TRUE;
|
|
|
|
ok = TRUE;
|
|
|
|
}
|
2002-02-19 21:08:24 +01:00
|
|
|
#ifdef DEBUG
|
|
|
|
if( strcmp( argv[i], "--debug" ) == 0 )
|
|
|
|
{
|
|
|
|
NGIRCd_Debug = TRUE;
|
|
|
|
ok = TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
2002-01-11 15:45:18 +01:00
|
|
|
if( strcmp( argv[i], "--help" ) == 0 )
|
|
|
|
{
|
2002-03-27 17:41:25 +01:00
|
|
|
Show_Version( );
|
|
|
|
puts( "" ); Show_Help( ); puts( "" );
|
2002-01-11 15:45:18 +01:00
|
|
|
exit( 1 );
|
|
|
|
}
|
2002-02-19 21:08:24 +01:00
|
|
|
if( strcmp( argv[i], "--nodaemon" ) == 0 )
|
2002-01-11 15:45:18 +01:00
|
|
|
{
|
2002-02-19 21:08:24 +01:00
|
|
|
NGIRCd_NoDaemon = TRUE;
|
|
|
|
ok = TRUE;
|
2002-01-11 15:45:18 +01:00
|
|
|
}
|
2002-02-19 21:08:24 +01:00
|
|
|
if( strcmp( argv[i], "--passive" ) == 0 )
|
2002-01-11 15:45:18 +01:00
|
|
|
{
|
2002-02-19 21:08:24 +01:00
|
|
|
NGIRCd_Passive = TRUE;
|
2002-01-11 15:45:18 +01:00
|
|
|
ok = TRUE;
|
|
|
|
}
|
2002-01-18 12:12:11 +01:00
|
|
|
#ifdef SNIFFER
|
|
|
|
if( strcmp( argv[i], "--sniffer" ) == 0 )
|
|
|
|
{
|
|
|
|
NGIRCd_Sniffer = TRUE;
|
|
|
|
ok = TRUE;
|
|
|
|
}
|
2002-01-11 15:45:18 +01:00
|
|
|
#endif
|
2002-02-19 21:08:24 +01:00
|
|
|
if( strcmp( argv[i], "--version" ) == 0 )
|
2002-01-11 15:45:18 +01:00
|
|
|
{
|
2002-03-10 18:50:48 +01:00
|
|
|
Show_Version( );
|
2002-02-19 21:08:24 +01:00
|
|
|
exit( 1 );
|
2002-01-11 15:45:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(( argv[i][0] == '-' ) && ( argv[i][1] != '-' ))
|
|
|
|
{
|
|
|
|
/* Kurze Option */
|
|
|
|
|
2002-03-25 20:11:01 +01:00
|
|
|
for( n = 1; n < (INT32)strlen( argv[i] ); n++ )
|
2002-01-11 15:45:18 +01:00
|
|
|
{
|
|
|
|
ok = FALSE;
|
|
|
|
#ifdef DEBUG
|
|
|
|
if( argv[i][n] == 'd' )
|
|
|
|
{
|
|
|
|
NGIRCd_Debug = TRUE;
|
|
|
|
ok = TRUE;
|
|
|
|
}
|
2002-01-18 12:12:11 +01:00
|
|
|
#endif
|
2002-03-28 15:15:33 +01:00
|
|
|
if( argv[i][n] == 'f' )
|
|
|
|
{
|
2002-03-31 15:20:42 +02:00
|
|
|
if(( ! argv[i][n + 1] ) && ( i + 1 < argc ))
|
2002-03-28 15:15:33 +01:00
|
|
|
{
|
|
|
|
/* Ok, danach kommt ein Leerzeichen */
|
|
|
|
strncpy( NGIRCd_ConfFile, argv[i + 1], FNAME_LEN - 1 );
|
|
|
|
NGIRCd_ConfFile[FNAME_LEN - 1] = '\0';
|
|
|
|
|
|
|
|
/* zum uebernaechsten Parameter */
|
|
|
|
i++; n = strlen( argv[i] );
|
|
|
|
ok = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2002-02-19 21:08:24 +01:00
|
|
|
if( argv[i][n] == 'n' )
|
|
|
|
{
|
|
|
|
NGIRCd_NoDaemon = TRUE;
|
|
|
|
ok = TRUE;
|
|
|
|
}
|
|
|
|
if( argv[i][n] == 'p' )
|
|
|
|
{
|
|
|
|
NGIRCd_Passive = TRUE;
|
|
|
|
ok = TRUE;
|
|
|
|
}
|
2002-01-18 12:12:11 +01:00
|
|
|
#ifdef SNIFFER
|
|
|
|
if( argv[i][n] == 's' )
|
|
|
|
{
|
|
|
|
NGIRCd_Sniffer = TRUE;
|
|
|
|
ok = TRUE;
|
|
|
|
}
|
2002-01-11 15:45:18 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if( ! ok )
|
|
|
|
{
|
|
|
|
printf( PACKAGE": invalid option \"-%c\"!\n", argv[i][n] );
|
|
|
|
puts( "Try \""PACKAGE" --help\" for more information." );
|
|
|
|
exit( 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if( ! ok )
|
|
|
|
{
|
|
|
|
printf( PACKAGE": invalid option \"%s\"!\n", argv[i] );
|
|
|
|
puts( "Try \""PACKAGE" --help\" for more information." );
|
|
|
|
exit( 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-19 21:08:24 +01:00
|
|
|
/* Debug-Level (fuer IRC-Befehl "VERSION") ermitteln */
|
|
|
|
strcpy( NGIRCd_DebugLevel, "" );
|
|
|
|
#ifdef DEBUG
|
|
|
|
if( NGIRCd_Debug ) strcpy( NGIRCd_DebugLevel, "1" );
|
|
|
|
#endif
|
|
|
|
#ifdef SNIFFER
|
|
|
|
if( NGIRCd_Sniffer ) strcpy( NGIRCd_DebugLevel, "2" );
|
|
|
|
#endif
|
2002-03-27 17:41:25 +01:00
|
|
|
|
|
|
|
/* Soll nur die Konfigurations ueberprueft und ausgegeben werden? */
|
|
|
|
if( configtest )
|
|
|
|
{
|
|
|
|
Show_Version( ); puts( "" );
|
|
|
|
exit( Conf_Test( ));
|
|
|
|
}
|
2002-02-19 21:08:24 +01:00
|
|
|
|
2001-12-13 00:30:42 +01:00
|
|
|
while( ! NGIRCd_Quit )
|
2001-12-11 22:53:04 +01:00
|
|
|
{
|
2002-01-12 01:17:28 +01:00
|
|
|
/* In der Regel wird ein Sub-Prozess ge-fork()'t, der
|
|
|
|
* nicht mehr mit dem Terminal verbunden ist. Mit der
|
|
|
|
* Option "--nodaemon" kann dies (z.B. zum Debuggen)
|
|
|
|
* verhindert werden. */
|
|
|
|
if( ! NGIRCd_NoDaemon )
|
|
|
|
{
|
|
|
|
/* Daemon im Hintergrund erzeugen */
|
2002-03-25 20:11:01 +01:00
|
|
|
pid = (INT32)fork( );
|
2002-01-12 01:17:28 +01:00
|
|
|
if( pid > 0 )
|
|
|
|
{
|
|
|
|
/* "alter" Prozess */
|
|
|
|
exit( 0 );
|
|
|
|
}
|
|
|
|
if( pid < 0 )
|
|
|
|
{
|
|
|
|
/* Fehler */
|
|
|
|
printf( PACKAGE": Can't fork: %s!\nFatal error, exiting now ...", strerror( errno ));
|
|
|
|
exit( 1 );
|
|
|
|
}
|
2002-03-06 16:36:04 +01:00
|
|
|
|
|
|
|
/* Child-Prozess initialisieren */
|
2002-03-25 20:11:01 +01:00
|
|
|
(VOID)setsid( );
|
2002-01-12 01:17:28 +01:00
|
|
|
chdir( "/" );
|
|
|
|
}
|
|
|
|
|
2001-12-31 03:18:51 +01:00
|
|
|
/* Globale Variablen initialisieren */
|
|
|
|
NGIRCd_Start = time( NULL );
|
2002-03-25 20:11:01 +01:00
|
|
|
(VOID)strftime( NGIRCd_StartStr, 64, "%a %b %d %Y at %H:%M:%S (%Z)", localtime( &NGIRCd_Start ));
|
2001-12-31 03:18:51 +01:00
|
|
|
NGIRCd_Restart = FALSE;
|
|
|
|
NGIRCd_Quit = FALSE;
|
|
|
|
|
|
|
|
/* Module initialisieren */
|
|
|
|
Log_Init( );
|
|
|
|
Conf_Init( );
|
|
|
|
Channel_Init( );
|
|
|
|
Client_Init( );
|
|
|
|
Conn_Init( );
|
|
|
|
|
2002-03-29 23:56:40 +01:00
|
|
|
/* Wenn als root ausgefuehrt und eine andere UID
|
|
|
|
* konfiguriert ist, jetzt zu dieser wechseln */
|
2002-03-30 00:34:18 +01:00
|
|
|
if( getuid( ) == 0 )
|
2002-03-29 23:56:40 +01:00
|
|
|
{
|
2002-03-30 00:34:18 +01:00
|
|
|
if( Conf_GID != 0 )
|
2002-03-29 23:56:40 +01:00
|
|
|
{
|
|
|
|
/* Neue Group-ID setzen */
|
|
|
|
if( setgid( Conf_GID ) != 0 ) Log( LOG_ERR, "Can't change Group-ID to %u: %s", Conf_GID, strerror( errno ));
|
|
|
|
}
|
2002-03-30 00:34:18 +01:00
|
|
|
if( Conf_UID != 0 )
|
2002-03-29 23:56:40 +01:00
|
|
|
{
|
|
|
|
/* Neue User-ID setzen */
|
2002-03-30 00:34:18 +01:00
|
|
|
if( setuid( Conf_UID ) != 0 ) Log( LOG_ERR, "Can't change User-ID to %u: %s", Conf_UID, strerror( errno ));
|
2002-03-29 23:56:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Log( LOG_INFO, "Running as user %ld, group %ld.", (INT32)getuid( ), (INT32)getgid( ));
|
|
|
|
|
2002-03-30 00:34:18 +01:00
|
|
|
Log_InitErrorfile( );
|
|
|
|
|
2001-12-31 03:18:51 +01:00
|
|
|
/* Signal-Handler initialisieren */
|
|
|
|
Initialize_Signal_Handler( );
|
|
|
|
|
|
|
|
/* Listen-Ports initialisieren */
|
|
|
|
Initialize_Listen_Ports( );
|
|
|
|
|
|
|
|
/* Hauptschleife */
|
|
|
|
while( TRUE )
|
|
|
|
{
|
|
|
|
if( NGIRCd_Quit || NGIRCd_Restart ) break;
|
|
|
|
Conn_Handler( 5 );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Alles abmelden */
|
|
|
|
Conn_Exit( );
|
|
|
|
Client_Exit( );
|
|
|
|
Channel_Exit( );
|
|
|
|
Conf_Exit( );
|
|
|
|
Log_Exit( );
|
|
|
|
}
|
2002-03-06 16:36:04 +01:00
|
|
|
|
2001-12-11 22:53:04 +01:00
|
|
|
return 0;
|
|
|
|
} /* main */
|
|
|
|
|
|
|
|
|
2002-01-11 15:45:18 +01:00
|
|
|
GLOBAL CHAR *NGIRCd_Version( VOID )
|
|
|
|
{
|
|
|
|
STATIC CHAR version[126];
|
2002-02-18 00:40:21 +01:00
|
|
|
|
|
|
|
sprintf( version, PACKAGE" version "VERSION"-%s", NGIRCd_VersionAddition( ));
|
|
|
|
return version;
|
|
|
|
} /* NGIRCd_Version */
|
|
|
|
|
|
|
|
|
|
|
|
GLOBAL CHAR *NGIRCd_VersionAddition( VOID )
|
|
|
|
{
|
|
|
|
STATIC CHAR txt[64];
|
2002-01-11 15:45:18 +01:00
|
|
|
|
|
|
|
strcpy( txt, "" );
|
|
|
|
|
|
|
|
#ifdef USE_SYSLOG
|
|
|
|
if( txt[0] ) strcat( txt, "+" );
|
|
|
|
strcat( txt, "SYSLOG" );
|
|
|
|
#endif
|
|
|
|
#ifdef STRICT_RFC
|
|
|
|
if( txt[0] ) strcat( txt, "+" );
|
|
|
|
strcat( txt, "RFC" );
|
|
|
|
#endif
|
|
|
|
#ifdef DEBUG
|
|
|
|
if( txt[0] ) strcat( txt, "+" );
|
|
|
|
strcat( txt, "DEBUG" );
|
|
|
|
#endif
|
|
|
|
#ifdef SNIFFER
|
|
|
|
if( txt[0] ) strcat( txt, "+" );
|
|
|
|
strcat( txt, "SNIFFER" );
|
|
|
|
#endif
|
|
|
|
|
2002-02-18 00:40:21 +01:00
|
|
|
if( txt[0] ) strcat( txt, "-" );
|
2002-03-12 23:08:24 +01:00
|
|
|
strcat( txt, TARGET_CPU"/"TARGET_VENDOR"/"TARGET_OS );
|
2002-02-18 00:40:21 +01:00
|
|
|
|
|
|
|
return txt;
|
|
|
|
} /* NGIRCd_VersionAddition */
|
2002-01-11 15:45:18 +01:00
|
|
|
|
|
|
|
|
2001-12-12 18:21:21 +01:00
|
|
|
LOCAL VOID Initialize_Signal_Handler( VOID )
|
|
|
|
{
|
2001-12-26 15:45:37 +01:00
|
|
|
/* Signal-Handler initialisieren: einige Signale
|
|
|
|
* werden ignoriert, andere speziell behandelt. */
|
2001-12-12 18:21:21 +01:00
|
|
|
|
2002-02-25 12:42:47 +01:00
|
|
|
#ifdef HAVE_SIGACTION
|
|
|
|
/* sigaction() ist vorhanden */
|
|
|
|
|
2001-12-12 18:21:21 +01:00
|
|
|
struct sigaction saction;
|
|
|
|
|
|
|
|
/* Signal-Struktur initialisieren */
|
|
|
|
memset( &saction, 0, sizeof( saction ));
|
2002-01-22 18:15:39 +01:00
|
|
|
saction.sa_handler = Signal_Handler;
|
2002-02-19 21:30:47 +01:00
|
|
|
#ifdef SA_RESTART
|
2002-02-23 20:06:47 +01:00
|
|
|
saction.sa_flags |= SA_RESTART;
|
|
|
|
#endif
|
|
|
|
#ifdef SA_NOCLDWAIT
|
|
|
|
saction.sa_flags |= SA_NOCLDWAIT;
|
2002-02-19 21:30:47 +01:00
|
|
|
#endif
|
2001-12-12 18:21:21 +01:00
|
|
|
|
|
|
|
/* Signal-Handler einhaengen */
|
|
|
|
sigaction( SIGINT, &saction, NULL );
|
|
|
|
sigaction( SIGQUIT, &saction, NULL );
|
|
|
|
sigaction( SIGTERM, &saction, NULL);
|
2002-02-18 00:40:21 +01:00
|
|
|
sigaction( SIGHUP, &saction, NULL);
|
2002-01-02 03:44:36 +01:00
|
|
|
sigaction( SIGCHLD, &saction, NULL);
|
2001-12-24 02:34:38 +01:00
|
|
|
|
|
|
|
/* einige Signale ignorieren */
|
|
|
|
saction.sa_handler = SIG_IGN;
|
|
|
|
sigaction( SIGPIPE, &saction, NULL );
|
2002-02-25 12:42:47 +01:00
|
|
|
#else
|
|
|
|
/* kein sigaction() vorhanden */
|
|
|
|
|
|
|
|
/* Signal-Handler einhaengen */
|
|
|
|
signal( SIGINT, Signal_Handler );
|
|
|
|
signal( SIGQUIT, Signal_Handler );
|
|
|
|
signal( SIGTERM, Signal_Handler );
|
|
|
|
signal( SIGHUP, Signal_Handler );
|
|
|
|
signal( SIGCHLD, Signal_Handler );
|
|
|
|
|
|
|
|
/* einige Signale ignorieren */
|
|
|
|
signal( SIGPIPE, SIG_IGN );
|
|
|
|
#endif
|
2001-12-12 18:21:21 +01:00
|
|
|
} /* Initialize_Signal_Handler */
|
|
|
|
|
|
|
|
|
2001-12-11 22:53:04 +01:00
|
|
|
LOCAL VOID Signal_Handler( INT Signal )
|
|
|
|
{
|
2001-12-12 18:21:21 +01:00
|
|
|
/* Signal-Handler. Dieser wird aufgerufen, wenn eines der Signale eintrifft,
|
|
|
|
* fuer das wir uns registriert haben (vgl. Initialize_Signal_Handler). Die
|
|
|
|
* Nummer des eingetroffenen Signals wird der Funktion uebergeben. */
|
|
|
|
|
2001-12-11 22:53:04 +01:00
|
|
|
switch( Signal )
|
|
|
|
{
|
|
|
|
case SIGTERM:
|
2001-12-12 02:40:39 +01:00
|
|
|
case SIGINT:
|
|
|
|
case SIGQUIT:
|
2001-12-12 18:21:21 +01:00
|
|
|
/* wir soll(t)en uns wohl beenden ... */
|
2002-02-18 00:40:21 +01:00
|
|
|
if( Signal == SIGTERM ) Log( LOG_WARNING, "Got TERM signal, terminating now ..." );
|
|
|
|
else if( Signal == SIGINT ) Log( LOG_WARNING, "Got INT signal, terminating now ..." );
|
|
|
|
else if( Signal == SIGQUIT ) Log( LOG_WARNING, "Got QUIT signal, terminating now ..." );
|
2001-12-13 00:30:42 +01:00
|
|
|
NGIRCd_Quit = TRUE;
|
2001-12-11 22:53:04 +01:00
|
|
|
break;
|
2002-02-18 00:40:21 +01:00
|
|
|
case SIGHUP:
|
|
|
|
/* neu starten */
|
|
|
|
Log( LOG_WARNING, "Got HUP signal, restarting now ..." );
|
|
|
|
NGIRCd_Restart = TRUE;
|
|
|
|
break;
|
2002-01-02 03:44:36 +01:00
|
|
|
case SIGCHLD:
|
|
|
|
/* Child-Prozess wurde beendet. Zombies vermeiden: */
|
|
|
|
while( waitpid( -1, NULL, WNOHANG ) > 0);
|
|
|
|
break;
|
2001-12-11 22:53:04 +01:00
|
|
|
default:
|
2001-12-12 18:21:21 +01:00
|
|
|
/* unbekanntes bzw. unbehandeltes Signal */
|
2001-12-13 00:30:42 +01:00
|
|
|
Log( LOG_NOTICE, "Got signal %d! Ignored.", Signal );
|
2001-12-11 22:53:04 +01:00
|
|
|
}
|
|
|
|
} /* Signal_Handler */
|
|
|
|
|
|
|
|
|
2001-12-30 20:26:11 +01:00
|
|
|
LOCAL VOID Initialize_Listen_Ports( VOID )
|
|
|
|
{
|
|
|
|
/* Ports, auf denen der Server Verbindungen entgegennehmen
|
|
|
|
* soll, initialisieren */
|
|
|
|
|
2002-03-29 23:56:40 +01:00
|
|
|
UINT created, i;
|
2001-12-30 20:26:11 +01:00
|
|
|
|
|
|
|
created = 0;
|
|
|
|
for( i = 0; i < Conf_ListenPorts_Count; i++ )
|
|
|
|
{
|
|
|
|
if( Conn_NewListener( Conf_ListenPorts[i] )) created++;
|
2002-03-29 23:56:40 +01:00
|
|
|
else Log( LOG_ERR, "Can't listen on port %u!", Conf_ListenPorts[i] );
|
2001-12-30 20:26:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if( created < 1 )
|
|
|
|
{
|
|
|
|
Log( LOG_ALERT, "Server isn't listening on a single port!" );
|
|
|
|
Log( LOG_ALERT, PACKAGE" exiting due to fatal errors!" );
|
|
|
|
exit( 1 );
|
|
|
|
}
|
|
|
|
} /* Initialize_Listen_Ports */
|
|
|
|
|
2002-01-11 15:45:18 +01:00
|
|
|
|
|
|
|
LOCAL VOID Show_Version( VOID )
|
|
|
|
{
|
|
|
|
puts( NGIRCd_Version( ));
|
|
|
|
puts( "Copyright (c)2001,2002 by Alexander Barton (alex@barton.de).\n" );
|
|
|
|
puts( "This is free software; see the source for copying conditions. There is NO" );
|
|
|
|
puts( "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." );
|
|
|
|
} /* Show_Version */
|
|
|
|
|
|
|
|
|
|
|
|
LOCAL VOID Show_Help( VOID )
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2002-03-28 15:15:33 +01:00
|
|
|
puts( " -d, --debug log extra debug messages" );
|
2002-01-11 15:45:18 +01:00
|
|
|
#endif
|
2002-03-28 15:15:33 +01:00
|
|
|
puts( " -f, --config <f> use file <f> as configuration file" );
|
|
|
|
puts( " -n, --nodaemon don't fork and don't detatch from controlling terminal" );
|
|
|
|
puts( " -p, --passive disable automatic connections to other servers" );
|
2002-01-21 01:02:11 +01:00
|
|
|
#ifdef SNIFFER
|
2002-03-28 15:15:33 +01:00
|
|
|
puts( " -s, --sniffer enable network sniffer and display all IRC traffic" );
|
2002-01-21 01:02:11 +01:00
|
|
|
#endif
|
2002-03-28 15:15:33 +01:00
|
|
|
puts( " --configtest read, validate and display configuration; then exit" );
|
|
|
|
puts( " --version output version information and exit" );
|
|
|
|
puts( " --help display this help and exit" );
|
2002-01-11 15:45:18 +01:00
|
|
|
} /* Show_Help */
|
|
|
|
|
|
|
|
|
2001-12-11 22:53:04 +01:00
|
|
|
/* -eof- */
|