1
0
mirror of https://github.com/osmarks/ngircd.git synced 2025-03-12 12:08:12 +00:00

- Backport aus HEAD: UID und GID kann nun auch textuell angegeben werden.

This commit is contained in:
Alexander Barton 2002-11-24 15:25:25 +00:00
parent 266b68b873
commit 6cdc8f7802
2 changed files with 31 additions and 8 deletions

View File

@ -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: conf.c,v 1.29.2.4 2002/11/04 19:18:39 alex Exp $
* $Id: conf.c,v 1.29.2.5 2002/11/24 15:25:25 alex Exp $
*
* conf.h: Konfiguration des ngircd
*/
@ -25,6 +25,9 @@
#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"
@ -67,6 +70,8 @@ Conf_Test( VOID )
{
/* Konfiguration einlesen, ueberpruefen und ausgeben. */
struct passwd *pwd;
struct group *grp;
INT i;
Use_Log = FALSE;
@ -91,15 +96,19 @@ Conf_Test( VOID )
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", (LONG)Conf_UID );
printf( " ServerGID = %ld\n", (LONG)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 );
@ -294,6 +303,8 @@ Read_Config( VOID )
LOCAL VOID
Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
{
struct passwd *pwd;
struct group *grp;
CHAR *ptr;
LONG port;
@ -372,13 +383,17 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
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 )

View File

@ -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.54.2.3 2002/11/04 19:18:39 alex Exp $
* $Id: ngircd.c,v 1.54.2.4 2002/11/24 15:25:25 alex Exp $
*
* ngircd.c: Hier beginnt alles ;-)
*/
@ -29,6 +29,8 @@
#include <sys/stat.h>
#include <sys/wait.h>
#include <time.h>
#include <pwd.h>
#include <grp.h>
#include "resolve.h"
#include "conn.h"
@ -57,6 +59,8 @@ LOCAL VOID Show_Help PARAMS(( VOID ));
GLOBAL int
main( int argc, const char *argv[] )
{
struct passwd *pwd;
struct group *grp;
BOOLEAN ok, configtest = FALSE;
LONG pid, n;
INT i;
@ -275,8 +279,12 @@ main( int argc, const char *argv[] )
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, with PID %ld.", (LONG)getuid( ), (LONG)getgid( ), (LONG)getpid( ));
/* User, Gruppe und Prozess-ID des Daemon ausgeben */
pwd = getpwuid( getuid( )); grp = getgrgid( getgid( ));
Log( LOG_INFO, "Running as user %s(%ld), group %s(%ld), with PID %ld.", pwd ? pwd->pw_name : "unknown", (LONG)getuid( ), grp ? grp->gr_name : "unknown", (LONG)getgid( ), (LONG)getpid( ));
/* stderr in "Error-File" umlenken */
Log_InitErrorfile( );
/* Signal-Handler initialisieren */