Changeset aaf92a9 for unix.c


Ignore:
Timestamp:
2007-12-02T23:18:25Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
08135df, de03374
Parents:
80e9db9
Message:

Imported setuid() patch from Simo Leone <simo@archlinux...> with some
modifications. Also adding some missing g_free()s to conf.c.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • unix.c

    r80e9db9 raaf92a9  
    3434#include <sys/time.h>
    3535#include <sys/wait.h>
     36#include <pwd.h>
    3637
    3738global_t global;        /* Against global namespace pollution */
     
    4546        struct sigaction sig, old;
    4647       
    47         memset( &global, 0, sizeof( global_t ) );
    48        
    4948        log_init();
    5049        CONF_FILE = g_strdup( CONF_FILE_DEF );
     
    8786                return( i );
    8887       
     88        if( ( global.conf->user && *global.conf->user ) &&
     89            ( global.conf->runmode == RUNMODE_DAEMON ||
     90              global.conf->runmode == RUNMODE_FORKDAEMON ) &&
     91            ( !getuid() || !geteuid() ) )
     92        {
     93                struct passwd *pw = NULL;
     94                pw = getpwnam( global.conf->user );
     95                if( pw )
     96                {
     97                        setgid( pw->pw_gid );
     98                        setuid( pw->pw_uid );
     99                }
     100        }
     101
    89102        global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage );
    90         if ( global.storage == NULL) {
     103        if( global.storage == NULL )
     104        {
    91105                log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage );
    92106                return( 1 );
    93107        }
    94        
    95108       
    96109        /* Catch some signals to tell the user what's happening before quitting */
Note: See TracChangeset for help on using the changeset viewer.