From ba9edaa568088900145bbd1004c864b7d408c38d Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 10 May 2006 19:34:46 +0200 Subject: Moved everything to the BitlBee event handling API. --- unix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'unix.c') diff --git a/unix.c b/unix.c index 89bd65bf..360281ee 100644 --- a/unix.c +++ b/unix.c @@ -46,7 +46,7 @@ int main( int argc, char *argv[], char **envp ) memset( &global, 0, sizeof( global_t ) ); - global.loop = g_main_new( FALSE ); + b_main_init(); log_init(); @@ -116,7 +116,7 @@ int main( int argc, char *argv[], char **envp ) if( help_init( &(global.help) ) == NULL ) log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE ); - g_main_run( global.loop ); + b_main_run(); if( global.restart ) { @@ -164,7 +164,7 @@ static void sighandler( int signal ) the user data now (not to mention writing them to disk), so add a timer. */ log_message( LOGLVL_ERROR, "SIGTERM received, cleaning up process." ); - g_timeout_add_full( G_PRIORITY_LOW, 1, (GSourceFunc) bitlbee_shutdown, NULL, NULL ); + b_timeout_add( 1, (b_event_handler) bitlbee_shutdown, NULL ); first = 0; } -- cgit v1.2.3 From 6e1fed7057ee26f21b0e59a5aeb292d4f3f0e8ae Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 25 Jun 2006 19:07:25 +0200 Subject: Using salted MD5 checksums for the user's BitlBee password and salted RC4 encryption for the IM account passwords, plus some calls to srand() to keep the salts secure and unique. --- unix.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'unix.c') diff --git a/unix.c b/unix.c index 360281ee..23ae1b91 100644 --- a/unix.c +++ b/unix.c @@ -47,20 +47,18 @@ int main( int argc, char *argv[], char **envp ) memset( &global, 0, sizeof( global_t ) ); b_main_init(); - log_init(); - nogaim_init(); - - CONF_FILE = g_strdup( CONF_FILE_DEF ); + srand( time( NULL ) ^ getpid() ); + + CONF_FILE = g_strdup( CONF_FILE_DEF ); global.helpfile = g_strdup( HELP_FILE ); - + global.conf = conf_load( argc, argv ); if( global.conf == NULL ) return( 1 ); - - + if( global.conf->runmode == RUNMODE_INETD ) { i = bitlbee_inetd_init(); @@ -88,7 +86,7 @@ int main( int argc, char *argv[], char **envp ) } if( i != 0 ) return( i ); - + global.storage = storage_init( global.conf->primary_storage, global.conf->migrate_storage ); if ( global.storage == NULL) { log_message( LOGLVL_ERROR, "Unable to load storage backend '%s'", global.conf->primary_storage ); -- cgit v1.2.3 From c227706bc921c3bb426eb315c0d097df30aa9d16 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 24 Dec 2006 20:35:13 +0100 Subject: Refactor the help code to take a filename rather than using the global struct. --- unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'unix.c') diff --git a/unix.c b/unix.c index 23ae1b91..2be16b2b 100644 --- a/unix.c +++ b/unix.c @@ -111,7 +111,7 @@ int main( int argc, char *argv[], char **envp ) if( !getuid() || !geteuid() ) log_message( LOGLVL_WARNING, "BitlBee is running with root privileges. Why?" ); - if( help_init( &(global.help) ) == NULL ) + if( help_init( &(global.help), global.helpfile ) == NULL ) log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE ); b_main_run(); -- cgit v1.2.3 From 60c1a4e76a343c0dbc19690b486190681265db4c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 30 Aug 2007 23:30:27 +0100 Subject: Changed the order in which things are loaded a little bit so global.conf->plugindir is actually filled in before we call nogaim_init(). --- unix.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'unix.c') diff --git a/unix.c b/unix.c index 2be16b2b..0abf43ea 100644 --- a/unix.c +++ b/unix.c @@ -46,19 +46,18 @@ int main( int argc, char *argv[], char **envp ) memset( &global, 0, sizeof( global_t ) ); - b_main_init(); log_init(); - nogaim_init(); - - srand( time( NULL ) ^ getpid() ); - CONF_FILE = g_strdup( CONF_FILE_DEF ); - global.helpfile = g_strdup( HELP_FILE ); - global.conf = conf_load( argc, argv ); if( global.conf == NULL ) return( 1 ); + b_main_init(); + nogaim_init(); + + srand( time( NULL ) ^ getpid() ); + global.helpfile = g_strdup( HELP_FILE ); + if( global.conf->runmode == RUNMODE_INETD ) { i = bitlbee_inetd_init(); -- 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. --- unix.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'unix.c') diff --git a/unix.c b/unix.c index 0abf43ea..75ffcf95 100644 --- a/unix.c +++ b/unix.c @@ -33,6 +33,7 @@ #include #include #include +#include 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 ) ); -- cgit v1.2.3 From 52744f8f65a278a59a8903d5c594e057d63c7006 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Thu, 17 Jan 2008 22:06:55 +0000 Subject: Fixing some Solaris compiler warnings (u_int->uint, adding some typecasts for pid_t variables). --- unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'unix.c') diff --git a/unix.c b/unix.c index 75ffcf95..0aaf505a 100644 --- a/unix.c +++ b/unix.c @@ -196,9 +196,9 @@ static void sighandler( int signal ) while( ( pid = waitpid( 0, &st, WNOHANG ) ) > 0 ) { if( WIFSIGNALED( st ) ) - log_message( LOGLVL_INFO, "Client %d terminated normally. (status = %d)", pid, WEXITSTATUS( st ) ); + log_message( LOGLVL_INFO, "Client %d terminated normally. (status = %d)", (int) pid, WEXITSTATUS( st ) ); else if( WIFEXITED( st ) ) - log_message( LOGLVL_INFO, "Client %d killed by signal %d.", pid, WTERMSIG( st ) ); + log_message( LOGLVL_INFO, "Client %d killed by signal %d.", (int) pid, WTERMSIG( st ) ); } } else if( signal != SIGPIPE ) -- cgit v1.2.3 From 0fbda19314c806e3e677847f3c977eb5a1bc2b61 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 2 Feb 2008 21:48:09 +0000 Subject: Added help_free() and cleaned up some very stale help-related stuff I wasn't even aware of. This closes bug #352. --- unix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'unix.c') diff --git a/unix.c b/unix.c index 0aaf505a..9b670d78 100644 --- a/unix.c +++ b/unix.c @@ -123,11 +123,14 @@ int main( int argc, char *argv[], char **envp ) if( !getuid() || !geteuid() ) log_message( LOGLVL_WARNING, "BitlBee is running with root privileges. Why?" ); - if( help_init( &(global.help), global.helpfile ) == NULL ) + if( help_init( &global.help, global.helpfile ) == NULL ) log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE ); b_main_run(); + /* Mainly good for restarting, to make sure we close the help.txt fd. */ + help_free( &global.help ); + if( global.restart ) { char *fn = ipc_master_save_state(); -- 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. --- unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'unix.c') diff --git a/unix.c b/unix.c index 9b670d78..d25aeb2e 100644 --- a/unix.c +++ b/unix.c @@ -46,7 +46,7 @@ int main( int argc, char *argv[], char **envp ) struct sigaction sig, old; log_init(); - CONF_FILE = g_strdup( CONF_FILE_DEF ); + global.conf_file = g_strdup( CONF_FILE_DEF ); global.conf = conf_load( argc, argv ); if( global.conf == NULL ) return( 1 ); -- cgit v1.2.3