diff options
| author | ulim <a.sporto+bee@gmail.com> | 2007-12-05 02:30:50 +0100 | 
|---|---|---|
| committer | ulim <a.sporto+bee@gmail.com> | 2007-12-05 02:30:50 +0100 | 
| commit | 8076ec04b1b5699f8266fa0e2e17456974ced554 (patch) | |
| tree | c53680ef30c2368e99f396e5e147b9c08437e46e /unix.c | |
| parent | dce390357114e30a424106c99e49cef1e682e1af (diff) | |
| parent | 793cc254ad2479d95d00266d6cb7ab2bcd158834 (diff) | |
merges from upstream/release
  ulim 2007-12-04 Follow rename of jabber_chat_by_jid from upstrem
    ulim 2007-12-04 Merged in current devel
    Wilmer van der Gaast 2007-12-02 Imported setuid() patch from Simo Leone <simo@archlinux...> with some
    Wilmer van der Gaast 2007-12-02 Forgot to return something in jabber_chat_join_failed().
    Wilmer van der Gaast 2007-12-02 Merging a change I should've pulled before committing three other changes.
    Wilmer van der Gaast 2007-12-02 Added charset checks on incoming msgs (from the IRC side) to prevent possible
    Wilmer van der Gaast 2007-12-02 Handling of presence-error packets (only useful for groupchats now), moved
    Wilmer van der Gaast 2007-12-02 Defining DEBUG via CFLAGS so that it'll always be there, even when a file
    ulim 2007-12-04 Jabber file transfer now also with sending! You can't use a proxy yet when
    Wilmer van der Gaast 2007-12-02 Removed retarded printf() (ARGH) and moved the event handling handling of
    Wilmer van der Gaast 2007-11-29 printf() in daemons considered harmful.
    Wilmer van der Gaast 2007-11-28 Fixed the epoll+ForkDaemon combination. The libevent event handling
Diffstat (limited to 'unix.c')
| -rw-r--r-- | unix.c | 21 | 
1 files changed, 17 insertions, 4 deletions
| @@ -33,6 +33,7 @@  #include <unistd.h>  #include <sys/time.h>  #include <sys/wait.h> +#include <pwd.h>  global_t global;	/* Against global namespace pollution */ @@ -44,8 +45,6 @@ int main( int argc, char *argv[], char **envp )  	char *old_cwd = NULL;  	struct sigaction sig, old; -	memset( &global, 0, sizeof( global_t ) ); -	  	log_init();  	CONF_FILE = g_strdup( CONF_FILE_DEF );  	global.conf = conf_load( argc, argv ); @@ -86,12 +85,26 @@ int main( int argc, char *argv[], char **envp )  	if( i != 0 )  		return( i ); +	if( ( global.conf->user && *global.conf->user ) && +	    ( global.conf->runmode == RUNMODE_DAEMON ||  +	      global.conf->runmode == RUNMODE_FORKDAEMON ) && +	    ( !getuid() || !geteuid() ) ) +	{ +		struct passwd *pw = NULL; +		pw = getpwnam( global.conf->user ); +		if( pw ) +		{ +			setgid( pw->pw_gid ); +			setuid( pw->pw_uid ); +		} +	} +  	global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage ); -	if ( global.storage == NULL) { +	if( global.storage == NULL ) +	{  		log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage );  		return( 1 );  	} -	  	/* Catch some signals to tell the user what's happening before quitting */  	memset( &sig, 0, sizeof( sig ) ); | 
