X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fngircd.c;h=78ffd9a00f029d5e84b3feafd4d7cdd84f53fb99;hp=a2b4666f1fc8263b71df8e910700a296edd7a10f;hb=75c0bd250eeb4c5347d3d2fc1524936f472fcda0;hpb=72accd4ee5d74a59dee93a6b203017e01d5bb3a0 diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c index a2b4666f..78ffd9a0 100644 --- a/src/ngircd/ngircd.c +++ b/src/ngircd/ngircd.c @@ -9,7 +9,7 @@ * Naehere Informationen entnehmen Sie bitter der Datei COPYING. Eine Liste * der an ngIRCd beteiligten Autoren finden Sie in der Datei AUTHORS. * - * $Id: ngircd.c,v 1.37 2002/03/28 14:15:33 alex Exp $ + * $Id: ngircd.c,v 1.43 2002/04/04 13:03:55 alex Exp $ * * ngircd.c: Hier beginnt alles ;-) */ @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -145,7 +146,7 @@ GLOBAL int main( int argc, const char *argv[] ) #endif if( argv[i][n] == 'f' ) { - if(( ! argv[i][n+i] ) && ( i + 1 < argc )) + if(( ! argv[i][n + 1] ) && ( i + 1 < argc )) { /* Ok, danach kommt ein Leerzeichen */ strncpy( NGIRCd_ConfFile, argv[i + 1], FNAME_LEN - 1 ); @@ -247,6 +248,25 @@ GLOBAL int main( int argc, const char *argv[] ) Client_Init( ); Conn_Init( ); + /* Wenn als root ausgefuehrt und eine andere UID + * konfiguriert ist, jetzt zu dieser wechseln */ + if( getuid( ) == 0 ) + { + if( Conf_GID != 0 ) + { + /* Neue Group-ID setzen */ + if( setgid( Conf_GID ) != 0 ) Log( LOG_ERR, "Can't change Group-ID to %u: %s", Conf_GID, strerror( errno )); + } + if( Conf_UID != 0 ) + { + /* Neue User-ID setzen */ + if( setuid( Conf_UID ) != 0 ) Log( LOG_ERR, "Can't change User-ID to %u: %s", Conf_UID, strerror( errno )); + } + } + Log( LOG_INFO, "Running as user %ld, group %ld.", (INT32)getuid( ), (INT32)getgid( )); + + Log_InitErrorfile( ); + /* Signal-Handler initialisieren */ Initialize_Signal_Handler( ); @@ -268,11 +288,6 @@ GLOBAL int main( int argc, const char *argv[] ) Log_Exit( ); } -#ifndef DEBUG - /* aufraeumen */ - if( unlink( ERROR_FILE ) != 0 ) Log( LOG_ERR, "Can't delete \""ERROR_FILE"\": %s", strerror( errno )); -#endif - return 0; } /* main */ @@ -400,13 +415,13 @@ LOCAL VOID Initialize_Listen_Ports( VOID ) /* Ports, auf denen der Server Verbindungen entgegennehmen * soll, initialisieren */ - INT created, i; + UINT created, i; created = 0; for( i = 0; i < Conf_ListenPorts_Count; i++ ) { if( Conn_NewListener( Conf_ListenPorts[i] )) created++; - else Log( LOG_ERR, "Can't listen on port %d!", Conf_ListenPorts[i] ); + else Log( LOG_ERR, "Can't listen on port %u!", Conf_ListenPorts[i] ); } if( created < 1 ) @@ -421,7 +436,8 @@ LOCAL VOID Initialize_Listen_Ports( VOID ) LOCAL VOID Show_Version( VOID ) { puts( NGIRCd_Version( )); - puts( "Copyright (c)2001,2002 by Alexander Barton (alex@barton.de).\n" ); + puts( "Copyright (c)2001,2002 by Alexander Barton ()." ); + puts( "Homepage: \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 */