From 883a398f059f98cb31da77dd6e632e4152dcf87e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 2 Apr 2008 22:36:02 +0100 Subject: Rearranged some event handling code. --- bitlbee.c | 12 ++++++++---- irc.c | 13 ++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/bitlbee.c b/bitlbee.c index 59a417f0..230b8ce8 100644 --- a/bitlbee.c +++ b/bitlbee.c @@ -225,12 +225,16 @@ gboolean bitlbee_io_current_client_write( gpointer data, gint fd, b_input_condit if( st == size ) { - g_free( irc->sendbuffer ); - irc->sendbuffer = NULL; - irc->w_watch_source_id = 0; - if( irc->status & USTATUS_SHUTDOWN ) + { irc_free( irc ); + } + else + { + g_free( irc->sendbuffer ); + irc->sendbuffer = NULL; + irc->w_watch_source_id = 0; + } return FALSE; } diff --git a/irc.c b/irc.c index 585cf232..c929d68b 100644 --- a/irc.c +++ b/irc.c @@ -198,12 +198,14 @@ void irc_abort( irc_t *irc, int immed, char *format, ... ) irc->status |= USTATUS_SHUTDOWN; if( irc->sendbuffer && !immed ) { - /* We won't read from this socket anymore. Instead, we'll connect a timer - to it that should shut down the connection in a second, just in case - bitlbee_.._write doesn't do it first. */ + /* Set up a timeout event that should shut down the connection + in a second, just in case ..._write doesn't do it first. */ b_event_remove( irc->r_watch_source_id ); - irc->r_watch_source_id = b_timeout_add( 1000, (b_event_handler) irc_free, irc ); + irc->r_watch_source_id = 0; + + b_event_remove( irc->ping_source_id ); + irc->ping_source_id = b_timeout_add( 1000, (b_event_handler) irc_free, irc ); } else { @@ -273,7 +275,8 @@ void irc_free( irc_t * irc ) if( irc->ping_source_id > 0 ) b_event_remove( irc->ping_source_id ); - b_event_remove( irc->r_watch_source_id ); + if( irc->r_watch_source_id > 0 ) + b_event_remove( irc->r_watch_source_id ); if( irc->w_watch_source_id > 0 ) b_event_remove( irc->w_watch_source_id ); -- cgit v1.2.3 From 8dbe021fab08902eb202da8da26d183cb0832fca Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Apr 2008 00:13:07 +0100 Subject: Don't pass an account_t pointer directly to query_add() since query_del() wants to free it! Passing an indirect pointer instead. --- root_commands.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/root_commands.c b/root_commands.c index 9a60b5af..2bccc465 100644 --- a/root_commands.c +++ b/root_commands.c @@ -205,22 +205,24 @@ static void cmd_drop( irc_t *irc, char **cmd ) void cmd_account_del_yes( gpointer w, void *data ) { - account_t *a = data; - irc_t *irc = a->irc; + account_t **aptr = data; + irc_t *irc = (*aptr)->irc; - if( a->ic ) + if( (*aptr)->ic ) { irc_usermsg( irc, "Account is still logged in, can't delete" ); } else { - account_del( irc, a ); + account_del( irc, (*aptr) ); irc_usermsg( irc, "Account deleted" ); } + g_free( aptr ); } void cmd_account_del_no( gpointer w, void *data ) { + g_free( data ); } static void cmd_account( irc_t *irc, char **cmd ) @@ -277,14 +279,18 @@ static void cmd_account( irc_t *irc, char **cmd ) } else { + account_t **aptr; char *msg; + aptr = g_malloc( sizeof( aptr ) ); + *aptr = a; + msg = g_strdup_printf( "If you remove this account (%s(%s)), BitlBee will " "also forget all your saved nicknames. If you want " "to change your username/password, use the `account " "set' command. Are you sure you want to delete this " "account?", a->prpl->name, a->user ); - query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, a ); + query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, aptr ); g_free( msg ); } } -- cgit v1.2.3 From f3351f0ae5c6014e36e529684b81e78cad9a66ce Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Apr 2008 12:54:31 +0100 Subject: Fixed GLib <2.6 compatibility issue in arc.h. (G_GNUC_MALLOC) --- lib/arc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/arc.h b/lib/arc.h index 58f30d3d..816fa612 100644 --- a/lib/arc.h +++ b/lib/arc.h @@ -30,6 +30,10 @@ struct arc_state unsigned char i, j; }; +#ifndef G_GNUC_MALLOC +#define G_GNUC_MALLOC +#endif + G_GNUC_MALLOC struct arc_state *arc_keymaker( unsigned char *key, int kl, int cycles ); unsigned char arc_getbyte( struct arc_state *st ); int arc_encode( char *clear, int clear_len, unsigned char **crypt, char *password, int pad_to ); -- cgit v1.2.3 From 9143aeb969697e05953b0f60a2fff2581fa0f18c Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Apr 2008 13:26:04 +0100 Subject: query.h now defines a callback function type, not using void* for it anymore. Got rid of the bogus window handler pointer as the first argument to the callback. --- protocols/jabber/jabber_util.c | 8 ++++++-- protocols/msn/msn_util.c | 8 ++++++-- protocols/nogaim.c | 17 ++++++++++------- protocols/nogaim.h | 3 ++- protocols/oscar/oscar.c | 18 ++++++++++++------ protocols/yahoo/yahoo.c | 8 ++++++-- query.c | 7 ++++--- query.h | 8 +++++--- 8 files changed, 51 insertions(+), 26 deletions(-) diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c index 6e872040..518624f6 100644 --- a/protocols/jabber/jabber_util.c +++ b/protocols/jabber/jabber_util.c @@ -245,8 +245,10 @@ struct jabber_buddy_ask_data char *realname; }; -static void jabber_buddy_ask_yes( gpointer w, struct jabber_buddy_ask_data *bla ) +static void jabber_buddy_ask_yes( void *data ) { + struct jabber_buddy_ask_data *bla = data; + presence_send_request( bla->ic, bla->handle, "subscribed" ); if( imcb_find_buddy( bla->ic, bla->handle ) == NULL ) @@ -256,8 +258,10 @@ static void jabber_buddy_ask_yes( gpointer w, struct jabber_buddy_ask_data *bla g_free( bla ); } -static void jabber_buddy_ask_no( gpointer w, struct jabber_buddy_ask_data *bla ) +static void jabber_buddy_ask_no( void *data ) { + struct jabber_buddy_ask_data *bla = data; + presence_send_request( bla->ic, bla->handle, "subscribed" ); g_free( bla->handle ); diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c index fae2877d..58ad22f8 100644 --- a/protocols/msn/msn_util.c +++ b/protocols/msn/msn_util.c @@ -89,8 +89,10 @@ struct msn_buddy_ask_data char *realname; }; -static void msn_buddy_ask_yes( gpointer w, struct msn_buddy_ask_data *bla ) +static void msn_buddy_ask_yes( void *data ) { + struct msn_buddy_ask_data *bla = data; + msn_buddy_list_add( bla->ic, "AL", bla->handle, bla->realname ); if( imcb_find_buddy( bla->ic, bla->handle ) == NULL ) @@ -101,8 +103,10 @@ static void msn_buddy_ask_yes( gpointer w, struct msn_buddy_ask_data *bla ) g_free( bla ); } -static void msn_buddy_ask_no( gpointer w, struct msn_buddy_ask_data *bla ) +static void msn_buddy_ask_no( void *data ) { + struct msn_buddy_ask_data *bla = data; + msn_buddy_list_add( bla->ic, "BL", bla->handle, bla->realname ); g_free( bla->handle ); diff --git a/protocols/nogaim.c b/protocols/nogaim.c index 3ce15166..7466e93a 100644 --- a/protocols/nogaim.c +++ b/protocols/nogaim.c @@ -342,7 +342,8 @@ void imc_logout( struct im_connection *ic, int allow_reconnect ) /* dialogs.c */ -void imcb_ask( struct im_connection *ic, char *msg, void *data, void *doit, void *dont ) +void imcb_ask( struct im_connection *ic, char *msg, void *data, + query_callback doit, query_callback dont ) { query_add( ic->irc, ic, msg, doit, dont, data ); } @@ -494,18 +495,20 @@ struct show_got_added_data char *handle; }; -void show_got_added_no( gpointer w, struct show_got_added_data *data ) +void show_got_added_no( void *data ) { - g_free( data->handle ); + g_free( ((struct show_got_added_data*)data)->handle ); g_free( data ); } -void show_got_added_yes( gpointer w, struct show_got_added_data *data ) +void show_got_added_yes( void *data ) { - data->ic->acc->prpl->add_buddy( data->ic, data->handle, NULL ); - /* imcb_add_buddy( data->ic, NULL, data->handle, data->handle ); */ + struct show_got_added_data *sga = data; - return show_got_added_no( w, data ); + sga->ic->acc->prpl->add_buddy( sga->ic, sga->handle, NULL ); + /* imcb_add_buddy( sga->ic, NULL, sga->handle, sga->handle ); */ + + return show_got_added_no( data ); } void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname ) diff --git a/protocols/nogaim.h b/protocols/nogaim.h index 7d391edd..bdd8bae2 100644 --- a/protocols/nogaim.h +++ b/protocols/nogaim.h @@ -41,6 +41,7 @@ #include "bitlbee.h" #include "account.h" #include "proxy.h" +#include "query.h" #include "md5.h" #define BUF_LEN MSG_LEN @@ -260,7 +261,7 @@ G_MODULE_EXPORT void imcb_error( struct im_connection *ic, char *format, ... ) G * - 'data' can be your custom struct - it will be passed to the callbacks. * - 'doit' or 'dont' will be called depending of the answer of the user. */ -G_MODULE_EXPORT void imcb_ask( struct im_connection *ic, char *msg, void *data, void *doit, void *dont ); +G_MODULE_EXPORT void imcb_ask( struct im_connection *ic, char *msg, void *data, query_callback doit, query_callback dont ); G_MODULE_EXPORT void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname ); /* Buddy management */ diff --git a/protocols/oscar/oscar.c b/protocols/oscar/oscar.c index 9e5de70a..7738c31f 100644 --- a/protocols/oscar/oscar.c +++ b/protocols/oscar/oscar.c @@ -1083,8 +1083,8 @@ static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_ return 1; } -void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv); -void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv); +void oscar_accept_chat(void *data); +void oscar_reject_chat(void *data); static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch2_args *args) { struct im_connection *ic = sess->aux_data; @@ -1118,7 +1118,8 @@ static int incomingim_chan2(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_ return 1; } -static void gaim_icq_authgrant(gpointer w, struct icq_auth *data) { +static void gaim_icq_authgrant(void *data_) { + struct icq_auth *data = data_; char *uin, message; struct oscar_data *od = (struct oscar_data *)data->ic->proto_data; @@ -1133,7 +1134,8 @@ static void gaim_icq_authgrant(gpointer w, struct icq_auth *data) { g_free(data); } -static void gaim_icq_authdeny(gpointer w, struct icq_auth *data) { +static void gaim_icq_authdeny(void *data_) { + struct icq_auth *data = data_; char *uin, *message; struct oscar_data *od = (struct oscar_data *)data->ic->proto_data; @@ -2587,15 +2589,19 @@ struct groupchat *oscar_chat_with(struct im_connection * ic, char *who) return NULL; } -void oscar_accept_chat(gpointer w, struct aim_chat_invitation * inv) +void oscar_accept_chat(void *data) { + struct aim_chat_invitation * inv = data; + oscar_chat_join(inv->ic, inv->name, NULL, NULL); g_free(inv->name); g_free(inv); } -void oscar_reject_chat(gpointer w, struct aim_chat_invitation * inv) +void oscar_reject_chat(void *data) { + struct aim_chat_invitation * inv = data; + g_free(inv->name); g_free(inv); } diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 36579d66..ab30df4d 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -796,16 +796,20 @@ int ext_yahoo_connect(const char *host, int port) return -1; } -static void byahoo_accept_conf( gpointer w, struct byahoo_conf_invitation *inv ) +static void byahoo_accept_conf( void *data ) { + struct byahoo_conf_invitation *inv = data; + yahoo_conference_logon( inv->yid, NULL, inv->members, inv->name ); imcb_chat_add_buddy( inv->c, inv->ic->acc->user ); g_free( inv->name ); g_free( inv ); } -static void byahoo_reject_conf( gpointer w, struct byahoo_conf_invitation *inv ) +static void byahoo_reject_conf( void *data ) { + struct byahoo_conf_invitation *inv = data; + yahoo_conference_decline( inv->yid, NULL, inv->members, inv->name, "User rejected groupchat" ); imcb_chat_free( inv->c ); g_free( inv->name ); diff --git a/query.c b/query.c index 6f9eb77f..e8f69572 100644 --- a/query.c +++ b/query.c @@ -29,7 +29,8 @@ static void query_display( irc_t *irc, query_t *q ); static query_t *query_default( irc_t *irc ); -query_t *query_add( irc_t *irc, struct im_connection *ic, char *question, void *yes, void *no, void *data ) +query_t *query_add( irc_t *irc, struct im_connection *ic, char *question, + query_callback yes, query_callback no, void *data ) { query_t *q = g_new0( query_t, 1 ); @@ -143,7 +144,7 @@ void query_answer( irc_t *irc, query_t *q, int ans ) imcb_log( q->ic, "Accepted: %s", q->question ); else irc_usermsg( irc, "Accepted: %s", q->question ); - q->yes( NULL, q->data ); + q->yes( q->data ); } else { @@ -151,7 +152,7 @@ void query_answer( irc_t *irc, query_t *q, int ans ) imcb_log( q->ic, "Rejected: %s", q->question ); else irc_usermsg( irc, "Rejected: %s", q->question ); - q->no( NULL, q->data ); + q->no( q->data ); } q->data = NULL; diff --git a/query.h b/query.h index b64642c2..e0ca32ec 100644 --- a/query.h +++ b/query.h @@ -26,17 +26,19 @@ #ifndef _QUERY_H #define _QUERY_H +typedef void (*query_callback) ( void *data ); + typedef struct query { struct im_connection *ic; char *question; - void (* yes) ( gpointer w, void *data ); - void (* no) ( gpointer w, void *data ); + query_callback yes, no; void *data; struct query *next; } query_t; -query_t *query_add( irc_t *irc, struct im_connection *ic, char *question, void *yes, void *no, void *data ); +query_t *query_add( irc_t *irc, struct im_connection *ic, char *question, + query_callback yes, query_callback no, void *data ); void query_del( irc_t *irc, query_t *q ); void query_del_by_conn( irc_t *irc, struct im_connection *ic ); void query_answer( irc_t *irc, query_t *q, int ans ); -- cgit v1.2.3 From f35aee7fdfc66138d0525a0a7b9e02ccb1aaaec7 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Apr 2008 13:36:13 +0100 Subject: Fixed #386. --- root_commands.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/root_commands.c b/root_commands.c index 2bccc465..aec91455 100644 --- a/root_commands.c +++ b/root_commands.c @@ -203,24 +203,36 @@ static void cmd_drop( irc_t *irc, char **cmd ) } } -void cmd_account_del_yes( gpointer w, void *data ) +struct cmd_account_del_data { - account_t **aptr = data; - irc_t *irc = (*aptr)->irc; + account_t *a; + irc_t *irc; +}; + +void cmd_account_del_yes( void *data ) +{ + struct cmd_account_del_data *cad = data; + account_t *a; - if( (*aptr)->ic ) + for( a = cad->irc->accounts; a && a != cad->a; a = a->next ); + + if( a == NULL ) + { + irc_usermsg( cad->irc, "Account already deleted" ); + } + else if( a->ic ) { - irc_usermsg( irc, "Account is still logged in, can't delete" ); + irc_usermsg( cad->irc, "Account is still logged in, can't delete" ); } else { - account_del( irc, (*aptr) ); - irc_usermsg( irc, "Account deleted" ); + account_del( cad->irc, a ); + irc_usermsg( cad->irc, "Account deleted" ); } - g_free( aptr ); + g_free( data ); } -void cmd_account_del_no( gpointer w, void *data ) +void cmd_account_del_no( void *data ) { g_free( data ); } @@ -279,18 +291,19 @@ static void cmd_account( irc_t *irc, char **cmd ) } else { - account_t **aptr; + struct cmd_account_del_data *cad; char *msg; - aptr = g_malloc( sizeof( aptr ) ); - *aptr = a; + cad = g_malloc( sizeof( struct cmd_account_del_data ) ); + cad->a = a; + cad->irc = irc; msg = g_strdup_printf( "If you remove this account (%s(%s)), BitlBee will " "also forget all your saved nicknames. If you want " "to change your username/password, use the `account " "set' command. Are you sure you want to delete this " "account?", a->prpl->name, a->user ); - query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, aptr ); + query_add( irc, NULL, msg, cmd_account_del_yes, cmd_account_del_no, cad ); g_free( msg ); } } -- cgit v1.2.3 From 1195cecc99315c9c38e05c8dd0981792e7663583 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 5 Apr 2008 14:03:31 +0100 Subject: Changed root nicknames are now saved. (Bug #378) --- bitlbee.h | 2 ++ doc/user-guide/commands.xml | 10 ++++++++++ irc.c | 1 + root_commands.c | 17 +++++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/bitlbee.h b/bitlbee.h index 420ab70a..60694a2a 100644 --- a/bitlbee.h +++ b/bitlbee.h @@ -159,6 +159,8 @@ void root_command_string( irc_t *irc, user_t *u, char *command, int flags ); void root_command( irc_t *irc, char *command[] ); gboolean bitlbee_shutdown( gpointer data, gint fd, b_input_condition cond ); +char *set_eval_root_nick( set_t *set, char *new_nick ); + extern global_t global; #endif diff --git a/doc/user-guide/commands.xml b/doc/user-guide/commands.xml index c45727b9..6d77f8cd 100644 --- a/doc/user-guide/commands.xml +++ b/doc/user-guide/commands.xml @@ -588,6 +588,16 @@ + + root + + + + Normally the "bot" that takes all your BitlBee commands is called "root". If you don't like this name, you can rename it to anything else using the rename command, or by changing this setting. + + + + true diff --git a/irc.c b/irc.c index c929d68b..a6220140 100644 --- a/irc.c +++ b/irc.c @@ -150,6 +150,7 @@ irc_t *irc_new( int fd ) set_add( &irc->set, "password", NULL, passchange, irc ); set_add( &irc->set, "private", "true", set_eval_bool, irc ); set_add( &irc->set, "query_order", "lifo", NULL, irc ); + set_add( &irc->set, "root_nick", irc->mynick, set_eval_root_nick, irc ); set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc ); set_add( &irc->set, "simulate_netsplit", "true", set_eval_bool, irc ); set_add( &irc->set, "strip_html", "true", NULL, irc ); diff --git a/root_commands.c b/root_commands.c index aec91455..4b27afe3 100644 --- a/root_commands.c +++ b/root_commands.c @@ -602,6 +602,9 @@ static void cmd_rename( irc_t *irc, char **cmd ) { g_free( irc->mynick ); irc->mynick = g_strdup( cmd[2] ); + + if( strcmp( cmd[0], "set_rename" ) != 0 ) + set_setstr( &irc->set, "root_nick", cmd[2] ); } else if( u->send_handler == buddy_send_handler ) { @@ -612,6 +615,20 @@ static void cmd_rename( irc_t *irc, char **cmd ) } } +char *set_eval_root_nick( set_t *set, char *new_nick ) +{ + irc_t *irc = set->data; + + if( strcmp( irc->mynick, new_nick ) != 0 ) + { + char *cmd[] = { "set_rename", irc->mynick, new_nick, NULL }; + + cmd_rename( irc, cmd ); + } + + return strcmp( irc->mynick, new_nick ) == 0 ? new_nick : NULL; +} + static void cmd_remove( irc_t *irc, char **cmd ) { user_t *u; -- cgit v1.2.3 From aa311173a85020bcbbbf61135a5451e171d422f5 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 8 Apr 2008 21:44:34 +0100 Subject: Don't automatically enable MSN debugging messages for debugging builds. --- protocols/msn/msn.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index c8f4f4c6..63759303 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -28,7 +28,7 @@ #define TYPING_NOTIFICATION_MESSAGE "\r\r\rBEWARE, ME R TYPINK MESSAGE!!!!\r\r\r" #define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r" -#ifdef DEBUG +#ifdef DEBUG_MSN #define debug( text... ) imcb_log( ic, text ); #else #define debug( text... ) -- cgit v1.2.3 From aefaac3a5d44537bdf804d1f42e491cc2b931889 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 6 Apr 2008 16:34:25 +0100 Subject: Added ClientInterface configuration option to make BitlBee bind() to a specific interface before connecting to a remote host. --- bitlbee.c | 4 ++-- bitlbee.conf | 7 +++++++ conf.c | 14 ++++++++++---- conf.h | 2 +- lib/proxy.c | 11 +++++++++++ 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/bitlbee.c b/bitlbee.c index 230b8ce8..17431546 100644 --- a/bitlbee.c +++ b/bitlbee.c @@ -53,11 +53,11 @@ int bitlbee_daemon_init() #endif ; - i = getaddrinfo( global.conf->iface, global.conf->port, &hints, &addrinfo_bind ); + i = getaddrinfo( global.conf->iface_in, global.conf->port, &hints, &addrinfo_bind ); if( i ) { log_message( LOGLVL_ERROR, "Couldn't parse address `%s': %s", - global.conf->iface, gai_strerror(i) ); + global.conf->iface_in, gai_strerror(i) ); return -1; } diff --git a/bitlbee.conf b/bitlbee.conf index 99e8106d..c03a564f 100644 --- a/bitlbee.conf +++ b/bitlbee.conf @@ -34,6 +34,13 @@ # DaemonInterface = 0.0.0.0 # DaemonPort = 6667 +## ClientInterface: +## +## If for any reason, you want BitlBee to use a specific address/interface +## for outgoing traffic (IM connections, HTTP(S), etc.), set it here. +## +# ClientInterface = 0.0.0.0 + ## AuthMode ## ## Open -- Accept connections from anyone, use NickServ for user authentication. diff --git a/conf.c b/conf.c index 339af618..8d6291ff 100644 --- a/conf.c +++ b/conf.c @@ -44,7 +44,8 @@ conf_t *conf_load( int argc, char *argv[] ) conf = g_new0( conf_t, 1 ); - conf->iface = NULL; + conf->iface_in = NULL; + conf->iface_out = NULL; conf->port = g_strdup( "6667" ); conf->nofork = 0; conf->verbose = 0; @@ -81,7 +82,7 @@ conf_t *conf_load( int argc, char *argv[] ) { if( opt == 'i' ) { - conf->iface = g_strdup( optarg ); + conf->iface_in = g_strdup( optarg ); } else if( opt == 'p' ) { @@ -201,14 +202,19 @@ 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 ); + g_free( conf->iface_in ); + conf->iface_in = 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, "clientinterface" ) == 0 ) + { + g_free( conf->iface_out ); + conf->iface_out = g_strdup( ini->value ); + } else if( g_strcasecmp( ini->key, "authmode" ) == 0 ) { if( g_strcasecmp( ini->value, "registered" ) == 0 ) diff --git a/conf.h b/conf.h index d21ec577..c41fd096 100644 --- a/conf.h +++ b/conf.h @@ -31,7 +31,7 @@ typedef enum authmode { AUTHMODE_OPEN, AUTHMODE_CLOSED, AUTHMODE_REGISTERED } au typedef struct conf { - char *iface; + char *iface_in, *iface_out; char *port; int nofork; int verbose; diff --git a/lib/proxy.c b/lib/proxy.c index 53b89d64..91493557 100644 --- a/lib/proxy.c +++ b/lib/proxy.c @@ -113,6 +113,7 @@ static gboolean gaim_io_connected(gpointer data, gint source, b_input_condition static int proxy_connect_none(const char *host, unsigned short port, struct PHB *phb) { struct sockaddr_in *sin; + struct sockaddr_in me; int fd = -1; if (!(sin = gaim_gethostbyname(host, port))) { @@ -127,6 +128,16 @@ static int proxy_connect_none(const char *host, unsigned short port, struct PHB sock_make_nonblocking(fd); + if( global.conf->iface_out ) + { + me.sin_family = AF_INET; + me.sin_port = 0; + me.sin_addr.s_addr = inet_addr( global.conf->iface_out ); + + if( bind( fd, (struct sockaddr *) &me, sizeof( me ) ) != 0 ) + event_debug( "bind( %d, \"%s\" ) failure\n", fd, global.conf->iface_out ); + } + event_debug("proxy_connect_none( \"%s\", %d ) = %d\n", host, port, fd); if (connect(fd, (struct sockaddr *)sin, sizeof(*sin)) < 0 && !sockerr_again()) { -- cgit v1.2.3 From 99f929cb5faca663969361e4a142d0c309af1725 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 21 Apr 2008 22:53:15 +0100 Subject: Now checking if msn_sb_create() returns NULL. This is very unlikely, but can happen if we run out of file descriptors, for example. --- protocols/msn/ns.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index ff7da6ed..ffaa90a7 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -177,7 +177,15 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) } debug( "Connecting to a new switchboard with key %s", cmd[5] ); - sb = msn_sb_create( ic, server, port, cmd[5], MSN_SB_NEW ); + + if( ( sb = msn_sb_create( ic, server, port, cmd[5], MSN_SB_NEW ) ) == NULL ) + { + /* Although this isn't strictly fatal for the NS connection, it's + definitely something serious (we ran out of file descriptors?). */ + imcb_error( ic, "Could not create new switchboard" ); + imc_logout( ic, TRUE ); + return( 0 ); + } if( md->msgq ) { @@ -467,8 +475,18 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) debug( "Got a call from %s (session %d). Key = %s", cmd[5], session, cmd[4] ); - sb = msn_sb_create( ic, server, port, cmd[4], session ); - sb->who = g_strdup( cmd[5] ); + if( ( sb = msn_sb_create( ic, server, port, cmd[4], session ) ) == NULL ) + { + /* Although this isn't strictly fatal for the NS connection, it's + definitely something serious (we ran out of file descriptors?). */ + imcb_error( ic, "Could not create new switchboard" ); + imc_logout( ic, TRUE ); + return( 0 ); + } + else + { + sb->who = g_strdup( cmd[5] ); + } } else if( strcmp( cmd[0], "ADD" ) == 0 ) { -- cgit v1.2.3 From 46d42308ee9a1120e39923dd38652681f2242665 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 7 May 2008 22:43:53 -0700 Subject: Added bitlbee-dev package, finalized 1.2-4 package. --- debian/changelog | 7 ++++--- debian/control | 9 +++++++++ debian/rules | 44 +++++++++++++++++++++++++++++++++----------- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/debian/changelog b/debian/changelog index b964ee0e..f4b71762 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,11 +1,12 @@ bitlbee (1.2-4) unstable; urgency=low - * Not a real release, just a placeholder for the changelog. * Fixed init script to use the BITLBEE_OPTS variable, not an undefined - DAEMON_OPT. + DAEMON_OPT. (Closes: #474583) * Added dependency information to the init script. (Closes: #472567) + * Added bitlbee-dev package. Patch from RISKO Gergely + with some small modifications. (Closes: #473480) - -- Wilmer van der Gaast Sat, 29 Mar 2008 21:10:33 +0000 + -- Wilmer van der Gaast Wed, 07 May 2008 22:40:40 -0700 bitlbee (1.2-3) unstable; urgency=low diff --git a/debian/control b/debian/control index 8383391b..8faa27b8 100644 --- a/debian/control +++ b/debian/control @@ -11,3 +11,12 @@ Depends: ${shlibs:Depends}, adduser, net-tools, ${debconf-depends}, debianutils Description: An IRC to other chat networks gateway This program can be used as an IRC server which forwards everything you say to people on other chat networks: Jabber, ICQ, AIM, MSN and Yahoo. + +Package: bitlbee-dev +Architecture: all +Depends: bitlbee (= ${binary:Version}) +Description: An IRC to other chat networks gateway + This program can be used as an IRC server which forwards everything you + say to people on other chat networks: Jabber, ICQ, AIM, MSN and Yahoo. + . + This package holds development stuff for compiling plug-ins. diff --git a/debian/rules b/debian/rules index 252fb742..67cb79a3 100755 --- a/debian/rules +++ b/debian/rules @@ -12,21 +12,21 @@ endif build-arch: build-arch-stamp build-arch-stamp: - if [ ! -d debian ]; then exit 1; fi + [ -d debian ] ./configure --debug=$(DEBUG) --prefix=/usr --etcdir=/etc/bitlbee --events=libevent $(MAKE) # $(MAKE) -C doc/ all touch build-arch-stamp clean: - if [ "`whoami`" != "root" -o ! -d debian ]; then exit 1; fi - rm -rf build-arch-stamp debian/bitlbee debian/*.substvars debian/files + [ "`whoami`" = "root" -a -d debian ] + rm -rf build-arch-stamp debian/bitlbee debian/*.substvars debian/files debian/bitlbee-dev -$(MAKE) distclean # -$(MAKE) -C doc/ clean install-arch: build-arch - if [ "`whoami`" != "root" -o ! -d debian ]; then exit 1; fi + [ "`whoami`" = "root" -a -d debian ] mkdir -p debian/bitlbee/DEBIAN/ $(MAKE) install install-etc DESTDIR=`pwd`/debian/bitlbee @@ -34,8 +34,15 @@ install-arch: build-arch cp doc/user-guide/user-guide.txt debian/bitlbee/usr/share/doc/bitlbee/ cp doc/user-guide/user-guide.html debian/bitlbee/usr/share/doc/bitlbee/ +install-indep: install-arch + [ "`whoami`" = "root" -a -d debian ] + mkdir -p debian/bitlbee-dev/DEBIAN/ + $(MAKE) install-dev DESTDIR=`pwd`/debian/bitlbee-dev + + mkdir -p debian/bitlbee-dev/usr/share/doc/bitlbee-dev/ + binary-arch: build-arch install-arch - if [ "`whoami`" != "root" -o ! -d debian ]; then exit 1; fi + [ "`whoami`" = "root" -a -d debian ] chmod 755 debian/post* debian/pre* debian/config debian/bitlbee.init @@ -51,7 +58,7 @@ binary-arch: build-arch install-arch gzip -9 doc/bitlbee/changelog.Debian doc/bitlbee/changelog doc/bitlbee/user-guide.txt \ doc/bitlbee/examples/* man/man8/bitlbee.8 man/man5/bitlbee.conf.5 - chown -R root.root debian/bitlbee/ + chown -R root:root debian/bitlbee/ find debian/bitlbee/usr/share/ -type d -exec chmod 755 {} \; find debian/bitlbee/usr/share/ -type f -exec chmod 644 {} \; @@ -76,11 +83,26 @@ endif dpkg --build debian/bitlbee .. -debug-build: - BITLBEE_VERSION=\"`date +%Y%m%d`-`hostname`-debug\" debian/rules clean binary DEBUG=1 +binary-indep: install-indep + [ "`whoami`" = "root" -a -d debian ] + + chown -R root.root debian/bitlbee-dev/ + find debian/bitlbee-dev/usr/share/ -type d -exec chmod 755 {} \; + find debian/bitlbee-dev/usr/share/ -type f -exec chmod 644 {} \; + + cp debian/changelog debian/bitlbee-dev/usr/share/doc/bitlbee-dev/changelog.Debian + gzip -9 debian/bitlbee-dev/usr/share/doc/bitlbee-dev/changelog.Debian + cp debian/copyright debian/bitlbee-dev/usr/share/doc/bitlbee-dev/copyright + + cd debian/bitlbee-dev; \ + find usr -type f -exec md5sum {} \; > DEBIAN/md5sums + + dpkg-gencontrol -ldebian/changelog -isp -pbitlbee-dev -Pdebian/bitlbee-dev + + dpkg --build debian/bitlbee-dev .. -binary: binary-arch +binary: binary-arch binary-indep build: build-arch -install: install-arch +install: install-arch install-indep -.PHONY: build-arch build clean binary-arch binary install-arch install +.PHONY: build-arch build clean binary-arch binary install-arch install binary-indep install-indep -- cgit v1.2.3 From a8d28d95e748b5402178c643c4c6e4657e695ce0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sun, 11 May 2008 14:19:09 +0200 Subject: Add homepage and vcs-bzr fields in Debian package. --- debian/changelog | 6 ++++++ debian/control | 2 ++ 2 files changed, 8 insertions(+) diff --git a/debian/changelog b/debian/changelog index b964ee0e..5099a35b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +bitlbee (1.2-5) UNRELEASED; urgency=low + + * Add Homepage and Vcs-Bzr fields. + + -- Jelmer Vernooij Sun, 11 May 2008 14:18:16 +0200 + bitlbee (1.2-4) unstable; urgency=low * Not a real release, just a placeholder for the changelog. diff --git a/debian/control b/debian/control index 8383391b..fb1dec91 100644 --- a/debian/control +++ b/debian/control @@ -4,6 +4,8 @@ Priority: optional Maintainer: Wilmer van der Gaast Standards-Version: 3.5.9 Build-Depends: libglib2.0-dev (>= 2.4), libevent-dev, libgnutls-dev | libnss-dev (>= 1.6), debconf-2.0, po-debconf +Homepage: http://www.bitlbee.org/ +Vcs-Bzr: http://code.bitlbee.org/bitlbee/ Package: bitlbee Architecture: any -- cgit v1.2.3 From 23c4e648e3d38336f949498d0b93e5b399087e44 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 11 May 2008 12:37:34 -0700 Subject: Fixed NULL point dereference in "account set -del" code. --- root_commands.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/root_commands.c b/root_commands.c index 4b27afe3..f55c4b5e 100644 --- a/root_commands.c +++ b/root_commands.c @@ -422,6 +422,12 @@ static void cmd_account( irc_t *irc, char **cmd ) else acc_handle = g_strdup( cmd[2] ); + if( !acc_handle ) + { + irc_usermsg( irc, "Not enough parameters given (need %d)", 3 ); + return; + } + if( ( tmp = strchr( acc_handle, '/' ) ) ) { *tmp = 0; -- cgit v1.2.3 From 51bbec0b0e280be629f7b1086160b7730ebfdb74 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 21 May 2008 12:27:28 +0200 Subject: Revert move of random_bytes() to unix.c --- lib/misc.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ unix.c | 67 -------------------------------------------------------------- 2 files changed, 65 insertions(+), 67 deletions(-) diff --git a/lib/misc.c b/lib/misc.c index 1670b91d..ccf208b5 100644 --- a/lib/misc.c +++ b/lib/misc.c @@ -391,6 +391,71 @@ signed int do_iconv( char *from_cs, char *to_cs, char *src, char *dst, size_t si return( outbuf - dst ); } +/* A pretty reliable random number generator. Tries to use the /dev/random + devices first, and falls back to the random number generator from libc + when it fails. Opens randomizer devices with O_NONBLOCK to make sure a + lack of entropy won't halt BitlBee. */ +void random_bytes( unsigned char *buf, int count ) +{ + static int use_dev = -1; + + /* Actually this probing code isn't really necessary, is it? */ + if( use_dev == -1 ) + { + if( access( "/dev/random", R_OK ) == 0 || access( "/dev/urandom", R_OK ) == 0 ) + use_dev = 1; + else + { + use_dev = 0; + srand( ( getpid() << 16 ) ^ time( NULL ) ); + } + } + + if( use_dev ) + { + int fd; + + /* At least on Linux, /dev/random can block if there's not + enough entropy. We really don't want that, so if it can't + give anything, use /dev/urandom instead. */ + if( ( fd = open( "/dev/random", O_RDONLY | O_NONBLOCK ) ) >= 0 ) + if( read( fd, buf, count ) == count ) + { + close( fd ); + return; + } + close( fd ); + + /* urandom isn't supposed to block at all, but just to be + sure. If it blocks, we'll disable use_dev and use the libc + randomizer instead. */ + if( ( fd = open( "/dev/urandom", O_RDONLY | O_NONBLOCK ) ) >= 0 ) + if( read( fd, buf, count ) == count ) + { + close( fd ); + return; + } + close( fd ); + + /* If /dev/random blocks once, we'll still try to use it + again next time. If /dev/urandom also fails for some + reason, stick with libc during this session. */ + + use_dev = 0; + srand( ( getpid() << 16 ) ^ time( NULL ) ); + } + + if( !use_dev ) + { + int i; + + /* Possibly the LSB of rand() isn't very random on some + platforms. Seems okay on at least Linux and OSX though. */ + for( i = 0; i < count; i ++ ) + buf[i] = rand() & 0xff; + } +} + int is_bool( char *value ) { if( *value == 0 ) diff --git a/unix.c b/unix.c index 39ca5732..d25aeb2e 100644 --- a/unix.c +++ b/unix.c @@ -218,70 +218,3 @@ double gettime() gettimeofday( time, 0 ); return( (double) time->tv_sec + (double) time->tv_usec / 1000000 ); } - -/* A pretty reliable random number generator. Tries to use the /dev/random - devices first, and falls back to the random number generator from libc - when it fails. Opens randomizer devices with O_NONBLOCK to make sure a - lack of entropy won't halt BitlBee. */ -void random_bytes( unsigned char *buf, int count ) -{ - static int use_dev = -1; - - /* Actually this probing code isn't really necessary, is it? */ - if( use_dev == -1 ) - { - if( access( "/dev/random", R_OK ) == 0 || access( "/dev/urandom", R_OK ) == 0 ) - use_dev = 1; - else - { - use_dev = 0; - srand( ( getpid() << 16 ) ^ time( NULL ) ); - } - } - - if( use_dev ) - { - int fd; - - /* At least on Linux, /dev/random can block if there's not - enough entropy. We really don't want that, so if it can't - give anything, use /dev/urandom instead. */ - if( ( fd = open( "/dev/random", O_RDONLY | O_NONBLOCK ) ) >= 0 ) - if( read( fd, buf, count ) == count ) - { - close( fd ); - return; - } - close( fd ); - - /* urandom isn't supposed to block at all, but just to be - sure. If it blocks, we'll disable use_dev and use the libc - randomizer instead. */ - if( ( fd = open( "/dev/urandom", O_RDONLY | O_NONBLOCK ) ) >= 0 ) - if( read( fd, buf, count ) == count ) - { - close( fd ); - return; - } - close( fd ); - - /* If /dev/random blocks once, we'll still try to use it - again next time. If /dev/urandom also fails for some - reason, stick with libc during this session. */ - - use_dev = 0; - srand( ( getpid() << 16 ) ^ time( NULL ) ); - } - - if( !use_dev ) - { - int i; - - /* Possibly the LSB of rand() isn't very random on some - platforms. Seems okay on at least Linux and OSX though. */ - for( i = 0; i < count; i ++ ) - buf[i] = rand() & 0xff; - } -} - - -- cgit v1.2.3