diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2007-12-02 23:18:25 +0000 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2007-12-02 23:18:25 +0000 | 
| commit | aaf92a9eb64327892e39fdbd7113d797d1d68cec (patch) | |
| tree | b907c7e55f32b073453a327231a9e76ab1604145 /conf.c | |
| parent | 80e9db97776bfd6c6192135d65027abd8f50887c (diff) | |
Imported setuid() patch from Simo Leone <simo@archlinux...> with some
modifications. Also adding some missing g_free()s to conf.c.
Diffstat (limited to 'conf.c')
| -rw-r--r-- | conf.c | 19 | 
1 files changed, 18 insertions, 1 deletions
| @@ -62,6 +62,7 @@ conf_t *conf_load( int argc, char *argv[] )  	conf->motdfile = g_strdup( ETCDIR "/motd.txt" );  	conf->ping_interval = 180;  	conf->ping_timeout = 300; +	conf->user = NULL;  	proxytype = 0;  	i = conf_loadini( conf, CONF_FILE ); @@ -75,7 +76,7 @@ conf_t *conf_load( int argc, char *argv[] )  		fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", CONF_FILE );  	} -	while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:" ) ) >= 0 ) +	while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u:" ) ) >= 0 )  	/*     ^^^^ Just to make sure we skip this step from the REHASH handler. */  	{  		if( opt == 'i' ) @@ -131,6 +132,7 @@ conf_t *conf_load( int argc, char *argv[] )  			        "  -I  Classic/InetD mode. (Default)\n"  			        "  -D  Daemon mode. (Still EXPERIMENTAL!)\n"  			        "  -F  Forking daemon. (one process per client)\n" +				"  -u  Run daemon as specified user.\n"  			        "  -P  Specify PID-file (not for inetd mode)\n"  			        "  -i  Specify the interface (by IP address) to listen on.\n"  			        "      (Default: 0.0.0.0 (any interface))\n" @@ -150,6 +152,11 @@ conf_t *conf_load( int argc, char *argv[] )  			   mode anyway!) */  			ipc_master_set_statefile( optarg );  		} +		else if( opt == 'u' ) +		{ +			g_free( conf->user ); +			conf->user = g_strdup( optarg ); +		}  	}  	if( conf->configdir[strlen(conf->configdir)-1] != '/' ) @@ -191,10 +198,12 @@ static int conf_loadini( conf_t *conf, char *file )  			}  			else if( g_strcasecmp( ini->key, "daemoninterface" ) == 0 )  			{ +				g_free( conf->iface );  				conf->iface = g_strdup( ini->value );  			}  			else if( g_strcasecmp( ini->key, "daemonport" ) == 0 )  			{ +				g_free( conf->port );  				conf->port = g_strdup( ini->value );  			}  			else if( g_strcasecmp( ini->key, "authmode" ) == 0 ) @@ -208,14 +217,17 @@ static int conf_loadini( conf_t *conf, char *file )  			}  			else if( g_strcasecmp( ini->key, "authpassword" ) == 0 )  			{ +				g_free( conf->auth_pass );  				conf->auth_pass = g_strdup( ini->value );  			}  			else if( g_strcasecmp( ini->key, "operpassword" ) == 0 )  			{ +				g_free( conf->oper_pass );  				conf->oper_pass = g_strdup( ini->value );  			}  			else if( g_strcasecmp( ini->key, "hostname" ) == 0 )  			{ +				g_free( conf->hostname );  				conf->hostname = g_strdup( ini->value );  			}  			else if( g_strcasecmp( ini->key, "configdir" ) == 0 ) @@ -280,6 +292,11 @@ static int conf_loadini( conf_t *conf, char *file )  				g_free( url );  			} +			else if( g_strcasecmp( ini->key, "user" ) == 0 ) +			{ +				g_free( conf->user ); +				conf->user = g_strdup( ini->value ); +			}  			else  			{  				fprintf( stderr, "Error: Unknown setting `%s` in configuration file.\n", ini->key ); | 
