From c121f8945f7249520342ad86ff00f4986642ca0a Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 14 Jun 2006 22:30:25 +0200 Subject: xml_load() works pretty well now. --- conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 7538825d..dd3a0704 100644 --- a/conf.c +++ b/conf.c @@ -54,7 +54,7 @@ conf_t *conf_load( int argc, char *argv[] ) conf->port = 6667; conf->nofork = 0; conf->verbose = 0; - conf->primary_storage = "text"; + conf->primary_storage = "xml"; conf->runmode = RUNMODE_INETD; conf->authmode = AUTHMODE_OPEN; conf->auth_pass = NULL; -- cgit v1.2.3 From 2befb95e3bdaf5306b55342c175abca174e40ffb Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 20 Jun 2006 23:37:16 +0200 Subject: Added migration storage defaults. --- conf.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'conf.c') diff --git a/conf.c b/conf.c index dd3a0704..d70117f5 100644 --- a/conf.c +++ b/conf.c @@ -41,6 +41,7 @@ static int conf_loadini( conf_t *conf, char *file ); conf_t *conf_load( int argc, char *argv[] ) { + char *mig_list[2] = { "text", NULL }; conf_t *conf; int opt, i; @@ -55,6 +56,7 @@ conf_t *conf_load( int argc, char *argv[] ) conf->nofork = 0; conf->verbose = 0; conf->primary_storage = "xml"; + conf->migrate_storage = mig_list; conf->runmode = RUNMODE_INETD; conf->authmode = AUTHMODE_OPEN; conf->auth_pass = NULL; -- cgit v1.2.3 From 00ab35016e3646aa936ae0c3d7a8531ec68d6f24 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 21 Jun 2006 19:14:49 +0200 Subject: Fixed GError memory leak, correctly setting the migrate_storage default. --- conf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index d70117f5..3154eb9c 100644 --- a/conf.c +++ b/conf.c @@ -41,7 +41,6 @@ static int conf_loadini( conf_t *conf, char *file ); conf_t *conf_load( int argc, char *argv[] ) { - char *mig_list[2] = { "text", NULL }; conf_t *conf; int opt, i; @@ -56,7 +55,7 @@ conf_t *conf_load( int argc, char *argv[] ) conf->nofork = 0; conf->verbose = 0; conf->primary_storage = "xml"; - conf->migrate_storage = mig_list; + conf->migrate_storage = g_strsplit( "text", ",", -1 ); conf->runmode = RUNMODE_INETD; conf->authmode = AUTHMODE_OPEN; conf->auth_pass = NULL; -- cgit v1.2.3 From df1694b9559d4abec748b0506b5f44e684d022a8 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 25 Jun 2006 14:15:42 +0200 Subject: Moving all generic files to lib/ instead of having some in / and some in protocols/, and adding RC4 code. --- conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 3154eb9c..d8b8be72 100644 --- a/conf.c +++ b/conf.c @@ -33,7 +33,7 @@ #include "url.h" #include "ipc.h" -#include "protocols/proxy.h" +#include "proxy.h" char *CONF_FILE; -- cgit v1.2.3 From 5c9512ffa716f2bc8bbf9e2c31ee40624a0ff842 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 30 Jun 2006 11:17:18 +0200 Subject: Made set.c API more generic so it's not specific to irc_t structures anymore, but can be used for account_t structures too, for example. --- conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index d8b8be72..13f150a7 100644 --- a/conf.c +++ b/conf.c @@ -322,7 +322,7 @@ void conf_loaddefaults( irc_t *irc ) { if( g_strcasecmp( ini->section, "defaults" ) == 0 ) { - set_t *s = set_find( irc, ini->key ); + set_t *s = set_find( &irc->set, ini->key ); if( s ) { -- cgit v1.2.3 From 7e0af5345f398a439459ac1752b8a946fb53a87e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 18 Feb 2007 17:10:14 +0000 Subject: configure --pidfile= actually works now. --- conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 13f150a7..24f6133b 100644 --- a/conf.c +++ b/conf.c @@ -62,7 +62,7 @@ conf_t *conf_load( int argc, char *argv[] ) conf->oper_pass = NULL; conf->configdir = g_strdup( CONFIG ); conf->plugindir = g_strdup( PLUGINDIR ); - conf->pidfile = g_strdup( "/var/run/bitlbee.pid" ); + conf->pidfile = g_strdup( PIDFILE ); conf->motdfile = g_strdup( ETCDIR "/motd.txt" ); conf->ping_interval = 180; conf->ping_timeout = 300; -- cgit v1.2.3 From d4589cb29dc06e68e9872316cfcd460c78e6aba3 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 18 Feb 2007 23:47:17 +0000 Subject: Little doc/help update. --- conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 24f6133b..09fd08e1 100644 --- a/conf.c +++ b/conf.c @@ -131,7 +131,7 @@ conf_t *conf_load( int argc, char *argv[] ) } else if( opt == 'h' ) { - printf( "Usage: bitlbee [-D [-i ] [-p ] [-n] [-v]] [-I]\n" + printf( "Usage: bitlbee [-D/-F [-i ] [-p ] [-n] [-v]] [-I]\n" " [-c ] [-d ] [-h]\n" "\n" "An IRC-to-other-chat-networks gateway\n" -- cgit v1.2.3 From e9b755e3726fa41ac2d4ed1c3a6192d1af68edbc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 18 Oct 2007 18:44:25 +0200 Subject: Use standard functions for dealing with both IPv6 and IPv4. --- conf.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 09fd08e1..551e8f5e 100644 --- a/conf.c +++ b/conf.c @@ -46,12 +46,8 @@ conf_t *conf_load( int argc, char *argv[] ) conf = g_new0( conf_t, 1 ); -#ifdef IPV6 - conf->iface = "::"; -#else - conf->iface = "0.0.0.0"; -#endif - conf->port = 6667; + conf->iface = NULL; + conf->port = "6667"; conf->nofork = 0; conf->verbose = 0; conf->primary_storage = "xml"; @@ -88,12 +84,8 @@ conf_t *conf_load( int argc, char *argv[] ) } else if( opt == 'p' ) { - if( ( sscanf( optarg, "%d", &i ) != 1 ) || ( i <= 0 ) || ( i > 65535 ) ) - { - fprintf( stderr, "Invalid port number: %s\n", optarg ); - return( NULL ); - } - conf->port = i; + g_free( conf->port ); + conf->port = g_strdup( optarg ); } else if( opt == 'P' ) { @@ -203,12 +195,7 @@ static int conf_loadini( conf_t *conf, char *file ) } else if( g_strcasecmp( ini->key, "daemonport" ) == 0 ) { - if( ( sscanf( ini->value, "%d", &i ) != 1 ) || ( i <= 0 ) || ( i > 65535 ) ) - { - fprintf( stderr, "Invalid port number: %s\n", ini->value ); - return( 0 ); - } - conf->port = i; + conf->port = g_strdup( ini->value ); } else if( g_strcasecmp( ini->key, "authmode" ) == 0 ) { -- cgit v1.2.3 From d75597b0b31f8aa8ca523a3cfa4869e20fca8466 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 20 Nov 2007 00:13:58 +0000 Subject: Fixed memory management issues introduced by at least the getaddrinfo() change. (Patch from arnau) --- conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 551e8f5e..82487ddf 100644 --- a/conf.c +++ b/conf.c @@ -47,10 +47,10 @@ conf_t *conf_load( int argc, char *argv[] ) conf = g_new0( conf_t, 1 ); conf->iface = NULL; - conf->port = "6667"; + conf->port = g_strdup( "6667" ); conf->nofork = 0; conf->verbose = 0; - conf->primary_storage = "xml"; + conf->primary_storage = g_strdup( "xml" ); conf->migrate_storage = g_strsplit( "text", ",", -1 ); conf->runmode = RUNMODE_INETD; conf->authmode = AUTHMODE_OPEN; -- cgit v1.2.3 From aaf92a9eb64327892e39fdbd7113d797d1d68cec Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 2 Dec 2007 23:18:25 +0000 Subject: Imported setuid() patch from Simo Leone with some modifications. Also adding some missing g_free()s to conf.c. --- conf.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 82487ddf..94c673cc 100644 --- a/conf.c +++ b/conf.c @@ -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 ); -- cgit v1.2.3 From eeb85a8a880fefe655eb31b6322136b61ee969e2 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 11 Feb 2008 12:35:01 +0000 Subject: Got rid of some noise at startup: complaining when the default configuration file couldn't be found while the user specified an alternative location with the -c option, and double complaints about /var/lib/bitlbee/ permissions. --- conf.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 94c673cc..57902826 100644 --- a/conf.c +++ b/conf.c @@ -35,14 +35,12 @@ #include "proxy.h" -char *CONF_FILE; - static int conf_loadini( conf_t *conf, char *file ); conf_t *conf_load( int argc, char *argv[] ) { conf_t *conf; - int opt, i; + int opt, i, config_missing = 0; conf = g_new0( conf_t, 1 ); @@ -65,15 +63,17 @@ conf_t *conf_load( int argc, char *argv[] ) conf->user = NULL; proxytype = 0; - i = conf_loadini( conf, CONF_FILE ); + i = conf_loadini( conf, global.conf_file ); if( i == 0 ) { - fprintf( stderr, "Error: Syntax error in configuration file `%s'.\n", CONF_FILE ); - return( NULL ); + fprintf( stderr, "Error: Syntax error in configuration file `%s'.\n", global.conf_file ); + return NULL; } else if( i == -1 ) { - fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", CONF_FILE ); + config_missing ++; + /* Whine after parsing the options if there was no -c pointing + at a *valid* configuration file. */ } while( argc > 0 && ( opt = getopt( argc, argv, "i:p:P:nvIDFc:d:hR:u:" ) ) >= 0 ) @@ -105,16 +105,16 @@ conf_t *conf_load( int argc, char *argv[] ) conf->runmode = RUNMODE_FORKDAEMON; else if( opt == 'c' ) { - if( strcmp( CONF_FILE, optarg ) != 0 ) + if( strcmp( global.conf_file, optarg ) != 0 ) { - g_free( CONF_FILE ); - CONF_FILE = g_strdup( optarg ); + g_free( global.conf_file ); + global.conf_file = g_strdup( optarg ); g_free( conf ); /* Re-evaluate arguments. Don't use this option twice, you'll end up in an infinite loop! Hope this trick works with all libcs BTW.. */ optind = 1; - return( conf_load( argc, argv ) ); + return conf_load( argc, argv ); } } else if( opt == 'd' ) @@ -142,7 +142,7 @@ conf_t *conf_load( int argc, char *argv[] ) " -c Load alternative configuration file\n" " -d Specify alternative user configuration directory\n" " -h Show this help page.\n" ); - return( NULL ); + return NULL; } else if( opt == 'R' ) { @@ -168,7 +168,10 @@ conf_t *conf_load( int argc, char *argv[] ) conf->configdir = s; } - return( conf ); + if( config_missing ) + fprintf( stderr, "Warning: Unable to read configuration file `%s'.\n", global.conf_file ); + + return conf; } static int conf_loadini( conf_t *conf, char *file ) @@ -177,7 +180,7 @@ static int conf_loadini( conf_t *conf, char *file ) int i; ini = ini_open( file ); - if( ini == NULL ) return( -1 ); + if( ini == NULL ) return -1; while( ini_read( ini ) ) { if( g_strcasecmp( ini->section, "settings" ) == 0 ) @@ -255,7 +258,7 @@ static int conf_loadini( conf_t *conf, char *file ) if( sscanf( ini->value, "%d", &i ) != 1 ) { fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); - return( 0 ); + return 0; } conf->ping_interval = i; } @@ -264,7 +267,7 @@ static int conf_loadini( conf_t *conf, char *file ) if( sscanf( ini->value, "%d", &i ) != 1 ) { fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); - return( 0 ); + return 0; } conf->ping_timeout = i; } @@ -276,7 +279,7 @@ static int conf_loadini( conf_t *conf, char *file ) { fprintf( stderr, "Invalid %s value: %s\n", ini->key, ini->value ); g_free( url ); - return( 0 ); + return 0; } strncpy( proxyhost, url->host, sizeof( proxyhost ) ); @@ -300,7 +303,7 @@ static int conf_loadini( conf_t *conf, char *file ) else { fprintf( stderr, "Error: Unknown setting `%s` in configuration file.\n", ini->key ); - return( 0 ); + return 0; /* For now just ignore unknown keys... */ } } @@ -308,19 +311,19 @@ static int conf_loadini( conf_t *conf, char *file ) { fprintf( stderr, "Error: Unknown section [%s] in configuration file. " "BitlBee configuration must be put in a [settings] section!\n", ini->section ); - return( 0 ); + return 0; } } ini_close( ini ); - return( 1 ); + return 1; } void conf_loaddefaults( irc_t *irc ) { ini_t *ini; - ini = ini_open( CONF_FILE ); + ini = ini_open( global.conf_file ); if( ini == NULL ) return; while( ini_read( ini ) ) { -- cgit v1.2.3 From dd14ecc29b87b9aefa97b6838f5a8595557d46d1 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 23 Mar 2008 15:02:42 +0000 Subject: s/g_strsplit/g_strsplit_set/, thanks to misc@mandriva.org (Bug #380). --- conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index 57902826..339af618 100644 --- a/conf.c +++ b/conf.c @@ -251,7 +251,7 @@ static int conf_loadini( conf_t *conf, char *file ) else if( g_strcasecmp( ini->key, "account_storage_migrate" ) == 0 ) { g_strfreev( conf->migrate_storage ); - conf->migrate_storage = g_strsplit( ini->value, " \t,;", -1 ); + conf->migrate_storage = g_strsplit_set( ini->value, " \t,;", -1 ); } else if( g_strcasecmp( ini->key, "pinginterval" ) == 0 ) { -- cgit v1.2.3