Changeset 823de9d
- Timestamp:
- 2009-03-12T19:10:06Z (16 years ago)
- Branches:
- master
- Children:
- 673a54c
- Parents:
- 9b55485
- Files:
-
- 32 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
r9b55485 r823de9d 107 107 x=$$(basename $$(pwd)); \ 108 108 cd ..; \ 109 tar czf $$x.tar.gz --exclude=debian --exclude=.bzr $$x109 tar czf $$x.tar.gz --exclude=debian --exclude=.bzr* $$x 110 110 111 111 $(subdirs): -
account.c
r9b55485 r823de9d 55 55 56 56 s = set_add( &a->set, "password", NULL, set_eval_account, a ); 57 s->flags |= ACC_SET_NOSAVE ;57 s->flags |= ACC_SET_NOSAVE | SET_NULL_OK; 58 58 59 59 s = set_add( &a->set, "username", NULL, set_eval_account, a ); … … 77 77 /* Double-check: We refuse to edit on-line accounts. */ 78 78 if( set->flags & ACC_SET_OFFLINE_ONLY && acc->ic ) 79 return NULL; 80 81 if( strcmp( set->key, "username" ) == 0 ) 79 return SET_INVALID; 80 81 if( strcmp( set->key, "server" ) == 0 ) 82 { 83 g_free( acc->server ); 84 if( value && *value ) 85 { 86 acc->server = g_strdup( value ); 87 return value; 88 } 89 else 90 { 91 acc->server = g_strdup( set->def ); 92 return g_strdup( set->def ); 93 } 94 } 95 else if( strcmp( set->key, "username" ) == 0 ) 82 96 { 83 97 g_free( acc->user ); … … 87 101 else if( strcmp( set->key, "password" ) == 0 ) 88 102 { 89 g_free( acc->pass ); 90 acc->pass = g_strdup( value ); 91 return NULL; /* password shouldn't be visible in plaintext! */ 92 } 93 else if( strcmp( set->key, "server" ) == 0 ) 94 { 95 g_free( acc->server ); 96 if( *value ) 97 { 98 acc->server = g_strdup( value ); 99 return value; 103 if( value ) 104 { 105 g_free( acc->pass ); 106 acc->pass = g_strdup( value ); 107 return NULL; /* password shouldn't be visible in plaintext! */ 100 108 } 101 109 else 102 110 { 103 acc->server = NULL; 104 return g_strdup( set->def ); 111 /* NULL can (should) be stored in the set_t 112 variable, but is otherwise not correct. */ 113 return SET_INVALID; 105 114 } 106 115 } … … 108 117 { 109 118 if( !is_bool( value ) ) 110 return NULL;119 return SET_INVALID; 111 120 112 121 acc->auto_connect = bool2int( value ); … … 114 123 } 115 124 116 return NULL;125 return SET_INVALID; 117 126 } 118 127 … … 234 243 } 235 244 } 245 246 struct account_reconnect_delay 247 { 248 int start; 249 char op; 250 int step; 251 int max; 252 }; 253 254 int account_reconnect_delay_parse( char *value, struct account_reconnect_delay *p ) 255 { 256 memset( p, 0, sizeof( *p ) ); 257 /* A whole day seems like a sane "maximum maximum". */ 258 p->max = 86400; 259 260 /* Format: /[0-9]+([*+][0-9]+(<[0-9+]))/ */ 261 while( *value && isdigit( *value ) ) 262 p->start = p->start * 10 + *value++ - '0'; 263 264 /* Sure, call me evil for implementing my own fscanf here, but it's 265 dead simple and I immediately know where to continue parsing. */ 266 267 if( *value == 0 ) 268 /* If the string ends now, the delay is constant. */ 269 return 1; 270 else if( *value != '+' && *value != '*' ) 271 /* Otherwise allow either a + or a * */ 272 return 0; 273 274 p->op = *value++; 275 276 /* + or * the delay by this number every time. */ 277 while( *value && isdigit( *value ) ) 278 p->step = p->step * 10 + *value++ - '0'; 279 280 if( *value == 0 ) 281 /* Use the default maximum (one day). */ 282 return 1; 283 else if( *value != '<' ) 284 return 0; 285 286 p->max = 0; 287 value ++; 288 while( *value && isdigit( *value ) ) 289 p->max = p->max * 10 + *value++ - '0'; 290 291 return p->max > 0; 292 } 293 294 char *set_eval_account_reconnect_delay( set_t *set, char *value ) 295 { 296 struct account_reconnect_delay p; 297 298 return account_reconnect_delay_parse( value, &p ) ? value : SET_INVALID; 299 } 300 301 int account_reconnect_delay( account_t *a ) 302 { 303 char *setting = set_getstr( &a->irc->set, "auto_reconnect_delay" ); 304 struct account_reconnect_delay p; 305 306 if( account_reconnect_delay_parse( setting, &p ) ) 307 { 308 if( a->auto_reconnect_delay == 0 ) 309 a->auto_reconnect_delay = p.start; 310 else if( p.op == '+' ) 311 a->auto_reconnect_delay += p.step; 312 else if( p.op == '*' ) 313 a->auto_reconnect_delay *= p.step; 314 315 if( a->auto_reconnect_delay > p.max ) 316 a->auto_reconnect_delay = p.max; 317 } 318 else 319 { 320 a->auto_reconnect_delay = 0; 321 } 322 323 return a->auto_reconnect_delay; 324 } -
account.h
r9b55485 r823de9d 35 35 36 36 int auto_connect; 37 int auto_reconnect_delay; 37 38 int reconnect; 38 39 … … 52 53 53 54 char *set_eval_account( set_t *set, char *value ); 55 char *set_eval_account_reconnect_delay( set_t *set, char *value ); 56 int account_reconnect_delay( account_t *a ); 54 57 55 #define ACC_SET_NOSAVE 156 #define ACC_SET_OFFLINE_ONLY 257 #define ACC_SET_ONLINE_ONLY 458 #define ACC_SET_NOSAVE 0x01 59 #define ACC_SET_OFFLINE_ONLY 0x02 60 #define ACC_SET_ONLINE_ONLY 0x04 58 61 59 62 #endif -
bitlbee.h
r9b55485 r823de9d 32 32 #define _WIN32_WINNT 0x0501 33 33 34 /* Depend on Windows 2000 for now since we need getaddrinfo() */ 35 #define _WIN32_WINNT 0x0501 36 34 37 #define PACKAGE "BitlBee" 35 #define BITLBEE_VERSION "1.2. 1"38 #define BITLBEE_VERSION "1.2.3" 36 39 #define VERSION BITLBEE_VERSION 37 40 -
conf.c
r9b55485 r823de9d 146 146 " -h Show this help page.\n" ); 147 147 return NULL; 148 } 149 else if( opt == 'R' ) 150 { 151 /* Backward compatibility; older BitlBees passed this 152 info using a command-line flag. Allow people to 153 upgrade from such a version for now. */ 154 setenv( "_BITLBEE_RESTART_STATE", optarg, 0 ); 148 155 } 149 156 else if( opt == 'u' ) -
configure
r9b55485 r823de9d 72 72 --gcov=0/1 Disable/enable test coverage reporting $gcov 73 73 --plugins=0/1 Disable/enable plugins support $plugins 74 --otr=0/1 /autoDisable/enable OTR encryption support $otr74 --otr=0/1 Disable/enable OTR encryption support $otr 75 75 76 76 --events=... Event handler (glib, libevent) $events -
doc/CHANGES
r9b55485 r823de9d 3 3 4 4 http://bugs.bitlbee.org/bitlbee/timeline?daysback=90&changeset=on 5 6 Version 1.2.3: 7 - Fixed one more flaw similar to the previous hijacking bug, caused by incon- 8 sistent handling of the USTATUS_IDENTIFIED state. All code touching these 9 variables was reviewed and should be correct now. 10 11 Finished 7 Sep 2008 12 13 Version 1.2.2: 14 - Security bugfix: It was possible to hijack accounts (without gaining access 15 to the old account, it's simply an overwrite) 16 - Some more stability improvements. 17 - Fixed bug where people with non-lowercase nicks couldn't drop their account. 18 - Easier upgrades of non-forking daemon mode servers (using the DEAF 19 command). 20 - Can be cross-compiled for Win32 now! (No support for SSL yet though, which 21 makes it less useful for now.) 22 - Exponential backoff on auto-reconnect. 23 - Changing passwords gives less confusing feedback ("password is empty") now. 24 25 Finished 26 Aug 2008 5 26 6 27 Version 1.2.1: -
doc/user-guide/commands.xml
r9b55485 r823de9d 470 470 </bitlbee-setting> 471 471 472 <bitlbee-setting name="auto_reconnect_delay" type="integer" scope="global"> 473 <default>300</default> 474 475 <description> 476 <para> 477 Tell BitlBee after how many seconds it should attempt to bring an IM-connection back up after a crash. It's not a good idea to set this value very low, it will cause too much useless traffic when an IM-server is down for a few hours. 472 <bitlbee-setting name="auto_reconnect_delay" type="string" scope="global"> 473 <default>5*3<900</default> 474 475 <description> 476 <para> 477 Tell BitlBee after how many seconds it should attempt to bring a broken IM-connection back up. 478 </para> 479 480 <para> 481 This can be one integer, for a constant delay. One can also set it to something like "10*10", which means wait for ten seconds on the first reconnect, multiply it by ten on every failure. Once successfully connected, this delay is re-set to the initial value. With < you can give a maximum delay. 478 482 </para> 479 483 -
ipc.c
r9b55485 r823de9d 33 33 34 34 GSList *child_list = NULL; 35 static char *statefile = NULL; 35 36 36 37 static void ipc_master_cmd_client( irc_t *data, char **cmd ) … … 62 63 } 63 64 64 static void ipc_master_cmd_deaf( irc_t *data, char **cmd )65 {66 if( global.conf->runmode == RUNMODE_DAEMON )67 {68 b_event_remove( global.listen_watch_source_id );69 close( global.listen_socket );70 71 global.listen_socket = global.listen_watch_source_id = -1;72 73 ipc_to_children_str( "OPERMSG :Closed listening socket, waiting "74 "for all users to disconnect." );75 }76 else77 {78 ipc_to_children_str( "OPERMSG :The DEAF command only works in "79 "normal daemon mode. Try DIE instead." );80 }81 }82 83 65 void ipc_master_cmd_rehash( irc_t *data, char **cmd ) 84 66 { … … 116 98 { "hello", 0, ipc_master_cmd_client, 0 }, 117 99 { "die", 0, ipc_master_cmd_die, 0 }, 118 { "deaf", 0, ipc_master_cmd_deaf, 0 },119 100 { "wallops", 1, NULL, IPC_CMD_TO_CHILDREN }, 120 101 { "wall", 1, NULL, IPC_CMD_TO_CHILDREN }, … … 460 441 } 461 442 462 #ifndef _WIN32463 443 char *ipc_master_save_state() 464 444 { … … 501 481 } 502 482 483 void ipc_master_set_statefile( char *fn ) 484 { 485 statefile = g_strdup( fn ); 486 } 487 503 488 504 489 static gboolean new_ipc_client( gpointer data, gint serversock, b_input_condition cond ) … … 521 506 } 522 507 508 #ifndef _WIN32 523 509 int ipc_master_listen_socket() 524 510 { … … 557 543 } 558 544 #else 559 int ipc_master_listen_socket()560 {561 545 /* FIXME: Open named pipe \\.\BITLBEE */ 562 return 0;563 }564 546 #endif 565 547 566 int ipc_master_load_state( char *statefile)548 int ipc_master_load_state() 567 549 { 568 550 struct bitlbee_child *child; … … 572 554 if( statefile == NULL ) 573 555 return 0; 574 575 556 fp = fopen( statefile, "r" ); 576 557 unlink( statefile ); /* Why do it later? :-) */ -
ipc.h
r9b55485 r823de9d 58 58 59 59 char *ipc_master_save_state(); 60 int ipc_master_load_state( char *statefile ); 60 void ipc_master_set_statefile( char *fn ); 61 int ipc_master_load_state(); 61 62 int ipc_master_listen_socket(); 62 63 -
irc.c
r9b55485 r823de9d 33 33 34 34 static gboolean irc_userping( gpointer _irc, int fd, b_input_condition cond ); 35 static void irc_welcome( irc_t *irc );35 static void irc_welcome( irc_t* irc ); 36 36 37 37 GSList *irc_connection_list = NULL; 38 38 39 static char * passchange( set_t *set, char *value )39 static char *set_eval_password( set_t *set, char *value ) 40 40 { 41 41 irc_t *irc = set->data; 42 42 43 irc_setpass( irc, value ); 44 irc_usermsg( irc, "Password successfully changed" ); 45 return NULL; 43 if( irc->status & USTATUS_IDENTIFIED && value ) 44 { 45 irc_setpass( irc, value ); 46 return NULL; 47 } 48 else 49 { 50 return SET_INVALID; 51 } 46 52 } 47 53 … … 80 86 struct sockaddr_storage sock; 81 87 socklen_t socklen = sizeof( sock ); 88 set_t *s; 82 89 83 90 irc = g_new0( irc_t, 1 ); … … 139 146 irc_connection_list = g_slist_append( irc_connection_list, irc ); 140 147 141 s et_add( &irc->set, "auto_connect", "true", set_eval_bool, irc );142 s et_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc );143 s et_add( &irc->set, "auto_reconnect_delay", "300", set_eval_int, irc );144 s et_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc );145 s et_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc );146 s et_add( &irc->set, "charset", "utf-8", set_eval_charset, irc );147 s et_add( &irc->set, "color_encrypted", "true", set_eval_bool, irc );148 s et_add( &irc->set, "debug", "false", set_eval_bool, irc );149 s et_add( &irc->set, "default_target", "root", NULL, irc );150 s et_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc );151 s et_add( &irc->set, "handle_unknown", "root", NULL, irc );152 s et_add( &irc->set, "halfop_buddies", "encrypted", set_eval_halfop_buddies, irc );153 s et_add( &irc->set, "lcnicks", "true", set_eval_bool, irc );154 s et_add( &irc->set, "op_buddies", "trusted", set_eval_op_buddies, irc );155 s et_add( &irc->set, "op_root", "true", set_eval_op_root, irc );156 s et_add( &irc->set, "op_user", "true", set_eval_op_user, irc );157 s et_add( &irc->set, "otr_policy", "opportunistic", set_eval_otr_policy, irc );158 s et_add( &irc->set, "password", NULL, passchange, irc );159 s et_add( &irc->set, "private", "true", set_eval_bool, irc );160 s et_add( &irc->set, "query_order", "lifo", NULL, irc );161 s et_add( &irc->set, "root_nick", irc->mynick, set_eval_root_nick, irc );162 s et_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc );163 s et_add( &irc->set, "simulate_netsplit", "true", set_eval_bool, irc );164 s et_add( &irc->set, "strip_html", "true", NULL, irc );165 s et_add( &irc->set, "to_char", ": ", set_eval_to_char, irc );166 s et_add( &irc->set, "typing_notice", "false", set_eval_bool, irc );167 s et_add( &irc->set, "voice_buddies", "notaway", set_eval_voice_buddies, irc);148 s = set_add( &irc->set, "auto_connect", "true", set_eval_bool, irc ); 149 s = set_add( &irc->set, "auto_reconnect", "false", set_eval_bool, irc ); 150 s = set_add( &irc->set, "auto_reconnect_delay", "5*3<900", set_eval_account_reconnect_delay, irc ); 151 s = set_add( &irc->set, "buddy_sendbuffer", "false", set_eval_bool, irc ); 152 s = set_add( &irc->set, "buddy_sendbuffer_delay", "200", set_eval_int, irc ); 153 s = set_add( &irc->set, "charset", "utf-8", set_eval_charset, irc ); 154 s = set_add( &irc->set, "color_encrypted", "true", set_eval_bool, irc ); 155 s = set_add( &irc->set, "debug", "false", set_eval_bool, irc ); 156 s = set_add( &irc->set, "default_target", "root", NULL, irc ); 157 s = set_add( &irc->set, "display_namechanges", "false", set_eval_bool, irc ); 158 s = set_add( &irc->set, "handle_unknown", "root", NULL, irc ); 159 s = set_add( &irc->set, "halfop_buddies", "encrypted", set_eval_halfop_buddies, irc ); 160 s = set_add( &irc->set, "lcnicks", "true", set_eval_bool, irc ); 161 s = set_add( &irc->set, "op_buddies", "trusted", set_eval_op_buddies, irc ); 162 s = set_add( &irc->set, "op_root", "true", set_eval_op_root, irc ); 163 s = set_add( &irc->set, "otr_policy", "oppurtunistic", set_eval_otr_policy, irc ); 164 s = set_add( &irc->set, "password", NULL, set_eval_password, irc ); 165 s->flags |= SET_NULL_OK; 166 s = set_add( &irc->set, "private", "true", set_eval_bool, irc ); 167 s = set_add( &irc->set, "query_order", "lifo", NULL, irc ); 168 s = set_add( &irc->set, "root_nick", irc->mynick, set_eval_root_nick, irc ); 169 s = set_add( &irc->set, "save_on_quit", "true", set_eval_bool, irc ); 170 s = set_add( &irc->set, "simulate_netsplit", "true", set_eval_bool, irc ); 171 s = set_add( &irc->set, "strip_html", "true", NULL, irc ); 172 s = set_add( &irc->set, "to_char", ": ", set_eval_to_char, irc ); 173 s = set_add( &irc->set, "typing_notice", "false", set_eval_bool, irc ); 174 s = set_add( &irc->set, "voice_buddies", "notaway", set_eval_voice_buddies, irc); 168 175 169 176 conf_loaddefaults( irc ); 170 177 171 178 irc->otr = otr_new(); 172 179 173 180 /* Evaluator sets the iconv/oconv structures. */ 174 181 set_eval_charset( set_find( &irc->set, "charset" ), set_getstr( &irc->set, "charset" ) ); … … 241 248 242 249 if( irc->status & USTATUS_IDENTIFIED && set_getbool( &irc->set, "save_on_quit" ) ) 243 if( storage_save( irc, TRUE ) != STORAGE_OK )250 if( storage_save( irc, NULL, TRUE ) != STORAGE_OK ) 244 251 irc_usermsg( irc, "Error while saving settings!" ); 245 252 … … 322 329 323 330 g_free( irc->last_target ); 324 331 325 332 otr_free(irc->otr); 326 333 327 334 g_free( irc ); 328 335 329 336 if( global.conf->runmode == RUNMODE_INETD || 330 337 global.conf->runmode == RUNMODE_FORKDAEMON || -
irc_commands.c
r9b55485 r823de9d 626 626 { "completions", 0, irc_cmd_completions, IRC_CMD_LOGGED_IN }, 627 627 { "die", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 628 { "deaf", 0, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER },629 628 { "wallops", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, 630 629 { "wall", 1, NULL, IRC_CMD_OPER_ONLY | IRC_CMD_TO_MASTER }, -
lib/ssl_bogus.c
r9b55485 r823de9d 70 70 return 0; 71 71 } 72 73 int ssl_pending( void *conn ) 74 { 75 return 0; 76 } -
protocols/jabber/jabber.c
r9b55485 r823de9d 70 70 71 71 s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); 72 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY ;72 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY | SET_NULL_OK; 73 73 74 74 s = set_add( &acc->set, "ssl", "false", set_eval_bool, acc ); -
protocols/jabber/jabber_util.c
r9b55485 r823de9d 37 37 /* Priority is a signed 8-bit integer, according to RFC 3921. */ 38 38 if( i < -128 || i > 127 ) 39 return NULL;39 return SET_INVALID; 40 40 } 41 41 else 42 return NULL;42 return SET_INVALID; 43 43 44 44 /* Only run this stuff if the account is online ATM, -
protocols/msn/msn.c
r9b55485 r823de9d 113 113 { 114 114 struct msn_switchboard *sb; 115 struct msn_data *md = ic->proto_data;116 115 117 116 if( ( sb = msn_sb_by_handle( ic, who ) ) ) … … 122 121 { 123 122 struct msn_message *m; 124 char buf[1024];125 123 126 124 /* Create a message. We have to arrange a usable switchboard, and send the message later. */ … … 129 127 m->text = g_strdup( message ); 130 128 131 /* FIXME: *CHECK* the reliability of using spare sb's! */ 132 if( ( sb = msn_sb_spare( ic ) ) ) 133 { 134 debug( "Trying to use a spare switchboard to message %s", who ); 135 136 sb->who = g_strdup( who ); 137 g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, who ); 138 if( msn_sb_write( sb, buf, strlen( buf ) ) ) 139 { 140 /* He/She should join the switchboard soon, let's queue the message. */ 141 sb->msgq = g_slist_append( sb->msgq, m ); 142 return( 1 ); 143 } 144 } 145 146 debug( "Creating a new switchboard to message %s", who ); 147 148 /* If we reach this line, there was no spare switchboard, so let's make one. */ 149 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 150 if( !msn_write( ic, buf, strlen( buf ) ) ) 151 { 152 g_free( m->who ); 153 g_free( m->text ); 154 g_free( m ); 155 156 return( 0 ); 157 } 158 159 /* And queue the message to md. We'll pick it up when the switchboard comes up. */ 160 md->msgq = g_slist_append( md->msgq, m ); 161 162 /* FIXME: If the switchboard creation fails, the message will not be sent. */ 163 164 return( 1 ); 129 return msn_sb_write_msg( ic, m ); 165 130 } 166 131 … … 252 217 { 253 218 struct msn_switchboard *sb; 254 struct msn_data *md = ic->proto_data;255 char buf[1024];256 219 257 220 if( ( sb = msn_sb_by_handle( ic, who ) ) ) … … 263 226 { 264 227 struct msn_message *m; 265 266 if( ( sb = msn_sb_spare( ic ) ) )267 {268 debug( "Trying to reuse an existing switchboard as a groupchat with %s", who );269 g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, who );270 if( msn_sb_write( sb, buf, strlen( buf ) ) )271 return msn_sb_to_chat( sb );272 }273 274 /* If the stuff above failed for some reason: */275 debug( "Creating a new switchboard to groupchat with %s", who );276 277 /* Request a new switchboard. */278 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId );279 if( !msn_write( ic, buf, strlen( buf ) ) )280 return( 0 );281 228 282 229 /* Create a magic message. This is quite hackish, but who cares? :-P */ … … 285 232 m->text = g_strdup( GROUPCHAT_SWITCHBOARD_MESSAGE ); 286 233 287 /* Queue the magic message and cross your fingers. */ 288 md->msgq = g_slist_append( md->msgq, m ); 289 290 /* FIXME: Can I try to return something here already? */ 234 msn_sb_write_msg( ic, m ); 235 291 236 return NULL; 292 237 } -
protocols/msn/msn.h
r9b55485 r823de9d 23 23 Suite 330, Boston, MA 02111-1307 USA 24 24 */ 25 26 #ifndef _MSN_H 27 #define _MSN_H 25 28 26 29 /* Some hackish magicstrings to make special-purpose messages/switchboards. … … 176 179 void msn_sb_destroy( struct msn_switchboard *sb ); 177 180 gboolean msn_sb_connected( gpointer data, gint source, b_input_condition cond ); 181 int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m ); 182 183 #endif //_MSN_H -
protocols/msn/ns.c
r9b55485 r823de9d 278 278 if( num_parts == 5 ) 279 279 { 280 int i, groupcount; 281 282 groupcount = atoi( cmd[4] ); 283 if( groupcount > 0 ) 284 { 285 /* valgrind says this is leaking memory, I'm guessing 286 that this happens during server redirects. */ 287 if( md->grouplist ) 288 { 289 for( i = 0; i < md->groupcount; i ++ ) 290 g_free( md->grouplist[i] ); 291 g_free( md->grouplist ); 292 } 293 294 md->groupcount = groupcount; 280 md->buddycount = atoi( cmd[3] ); 281 md->groupcount = atoi( cmd[4] ); 282 if( md->groupcount > 0 ) 295 283 md->grouplist = g_new0( char *, md->groupcount ); 296 } 297 298 md->buddycount = atoi( cmd[3] ); 284 299 285 if( !*cmd[3] || md->buddycount == 0 ) 300 286 msn_logged_in( ic ); … … 679 665 imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); 680 666 } 681 682 g_free( inbox );683 g_free( folders );684 667 } 685 668 else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 ) -
protocols/msn/sb.c
r9b55485 r823de9d 44 44 return( 0 ); 45 45 } 46 47 return( 1 ); 48 } 49 50 int msn_sb_write_msg( struct im_connection *ic, struct msn_message *m ) 51 { 52 struct msn_data *md = ic->proto_data; 53 struct msn_switchboard *sb; 54 char buf[1024]; 55 56 /* FIXME: *CHECK* the reliability of using spare sb's! */ 57 if( ( sb = msn_sb_spare( ic ) ) ) 58 { 59 debug( "Trying to use a spare switchboard to message %s", m->who ); 60 61 sb->who = g_strdup( m->who ); 62 g_snprintf( buf, sizeof( buf ), "CAL %d %s\r\n", ++sb->trId, m->who ); 63 if( msn_sb_write( sb, buf, strlen( buf ) ) ) 64 { 65 /* He/She should join the switchboard soon, let's queue the message. */ 66 sb->msgq = g_slist_append( sb->msgq, m ); 67 return( 1 ); 68 } 69 } 70 71 debug( "Creating a new switchboard to message %s", m->who ); 72 73 /* If we reach this line, there was no spare switchboard, so let's make one. */ 74 g_snprintf( buf, sizeof( buf ), "XFR %d SB\r\n", ++md->trId ); 75 if( !msn_write( ic, buf, strlen( buf ) ) ) 76 { 77 g_free( m->who ); 78 g_free( m->text ); 79 g_free( m ); 80 81 return( 0 ); 82 } 83 84 /* And queue the message to md. We'll pick it up when the switchboard comes up. */ 85 md->msgq = g_slist_append( md->msgq, m ); 86 87 /* FIXME: If the switchboard creation fails, the message will not be sent. */ 46 88 47 89 return( 1 ); -
protocols/nogaim.c
r9b55485 r823de9d 267 267 protocols. */ 268 268 imc_set_away( ic, u->away ); 269 270 /* Apparently we're connected successfully, so reset the 271 exponential backoff timer. */ 272 ic->acc->auto_reconnect_delay = 0; 269 273 } 270 274 … … 290 294 user_t *t, *u; 291 295 account_t *a; 296 int delay; 292 297 293 298 /* Nested calls might happen sometimes, this is probably the best … … 329 334 } 330 335 else if( allow_reconnect && set_getbool( &irc->set, "auto_reconnect" ) && 331 set_getbool( &a->set, "auto_reconnect" ) ) 332 { 333 int delay = set_getint( &irc->set, "auto_reconnect_delay" ); 334 336 set_getbool( &a->set, "auto_reconnect" ) && 337 ( delay = account_reconnect_delay( a ) ) > 0 ) 338 { 335 339 imcb_log( ic, "Reconnecting in %d seconds..", delay ); 336 340 a->reconnect = b_timeout_add( delay * 1000, auto_reconnect, a ); -
protocols/yahoo/libyahoo2.c
r9b55485 r823de9d 69 69 #ifdef __MINGW32__ 70 70 # include <winsock2.h> 71 # define write(a,b,c) send(a,b,c,0) 72 # define read(a,b,c) recv(a,b,c,0) 71 73 #endif 72 74 -
protocols/yahoo/yahoo.c
r9b55485 r823de9d 666 666 667 667 imcb_error( ic, "%s", err ); 668 669 if( fatal )670 imc_logout( ic, TRUE );671 668 } 672 669 -
protocols/yahoo/yahoo_httplib.c
r9b55485 r823de9d 51 51 #ifdef __MINGW32__ 52 52 # include <winsock2.h> 53 # define write(a,b,c) send(a,b,c,0) 54 # define read(a,b,c) recv(a,b,c,0) 53 55 # define snprintf _snprintf 54 56 #endif -
root_commands.c
r9b55485 r823de9d 132 132 static void cmd_identify( irc_t *irc, char **cmd ) 133 133 { 134 storage_status_t status = storage_load( irc ->nick, cmd[1], irc);134 storage_status_t status = storage_load( irc, cmd[1] ); 135 135 char *account_on[] = { "account", "on", NULL }; 136 136 … … 144 144 case STORAGE_OK: 145 145 irc_usermsg( irc, "Password accepted, settings and accounts loaded" ); 146 irc_setpass( irc, cmd[1] ); 147 irc->status |= USTATUS_IDENTIFIED; 146 148 irc_umode_set( irc, "+R", 1 ); 147 149 if( set_getbool( &irc->set, "auto_connect" ) ) … … 163 165 } 164 166 165 irc_setpass( irc, cmd[1] ); 166 switch( storage_save( irc, FALSE )) { 167 switch( storage_save( irc, cmd[1], FALSE ) ) { 167 168 case STORAGE_ALREADY_EXISTS: 168 169 irc_usermsg( irc, "Nick is already registered" ); … … 171 172 case STORAGE_OK: 172 173 irc_usermsg( irc, "Account successfully created" ); 174 irc_setpass( irc, cmd[1] ); 173 175 irc->status |= USTATUS_IDENTIFIED; 174 176 irc_umode_set( irc, "+R", 1 ); … … 239 241 } 240 242 243 static void cmd_showset( irc_t *irc, set_t **head, char *key ) 244 { 245 char *val; 246 247 if( ( val = set_getstr( head, key ) ) ) 248 irc_usermsg( irc, "%s = `%s'", key, val ); 249 else 250 irc_usermsg( irc, "%s is empty", key ); 251 } 252 241 253 static void cmd_account( irc_t *irc, char **cmd ) 242 254 { … … 450 462 { 451 463 set_t *s = set_find( &a->set, set_name ); 464 int st; 452 465 453 466 if( a->ic && s && s->flags & ACC_SET_OFFLINE_ONLY ) … … 465 478 466 479 if( g_strncasecmp( cmd[2], "-del", 4 ) == 0 ) 467 s et_reset( &a->set, set_name );480 st = set_reset( &a->set, set_name ); 468 481 else 469 set_setstr( &a->set, set_name, cmd[3] ); 470 } 471 if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */ 472 { 473 char *s = set_getstr( &a->set, set_name ); 474 if( s ) 475 irc_usermsg( irc, "%s = `%s'", set_name, s ); 482 st = set_setstr( &a->set, set_name, cmd[3] ); 483 484 if( set_getstr( &a->set, set_name ) == NULL ) 485 { 486 if( st ) 487 irc_usermsg( irc, "Setting changed successfully" ); 488 else 489 irc_usermsg( irc, "Failed to change setting" ); 490 } 476 491 else 477 irc_usermsg( irc, "%s is empty", set_name ); 492 { 493 cmd_showset( irc, &a->set, set_name ); 494 } 495 } 496 else if( set_name ) 497 { 498 cmd_showset( irc, &a->set, set_name ); 478 499 } 479 500 else … … 482 503 while( s ) 483 504 { 484 if( s->value || s->def ) 485 irc_usermsg( irc, "%s = `%s'", s->key, s->value ? s->value : s->def ); 486 else 487 irc_usermsg( irc, "%s is empty", s->key ); 505 cmd_showset( irc, &s, s->key ); 488 506 s = s->next; 489 507 } … … 615 633 irc->mynick = g_strdup( cmd[2] ); 616 634 635 /* If we're called internally (user did "set root_nick"), 636 let's not go O(INF). :-) */ 617 637 if( strcmp( cmd[0], "set_rename" ) != 0 ) 618 638 set_setstr( &irc->set, "root_nick", cmd[2] ); … … 638 658 } 639 659 640 return strcmp( irc->mynick, new_nick ) == 0 ? new_nick : NULL;660 return strcmp( irc->mynick, new_nick ) == 0 ? new_nick : SET_INVALID; 641 661 } 642 662 … … 826 846 if( cmd[1] && cmd[2] ) 827 847 { 848 int st; 849 828 850 if( g_strncasecmp( cmd[1], "-del", 4 ) == 0 ) 829 851 { 830 s et_reset( &irc->set, cmd[2] );852 st = set_reset( &irc->set, cmd[2] ); 831 853 set_name = cmd[2]; 832 854 } 833 855 else 834 856 { 835 set_setstr( &irc->set, cmd[1], cmd[2] ); 836 } 837 } 838 if( set_name ) /* else 'forgotten' on purpose.. Must show new value after changing */ 839 { 840 char *s = set_getstr( &irc->set, set_name ); 841 if( s ) 842 irc_usermsg( irc, "%s = `%s'", set_name, s ); 857 st = set_setstr( &irc->set, cmd[1], cmd[2] ); 858 } 859 860 /* Normally we just show the variable's new/unchanged 861 value as feedback to the user, but this has always 862 caused confusion when changing the password. Give 863 other feedback instead: */ 864 if( set_getstr( &irc->set, set_name ) == NULL ) 865 { 866 if( st ) 867 irc_usermsg( irc, "Setting changed successfully" ); 868 else 869 irc_usermsg( irc, "Failed to change setting" ); 870 } 843 871 else 844 irc_usermsg( irc, "%s is empty", set_name ); 872 { 873 cmd_showset( irc, &irc->set, set_name ); 874 } 875 } 876 else if( set_name ) 877 { 878 cmd_showset( irc, &irc->set, set_name ); 845 879 846 880 if( strchr( set_name, '/' ) ) … … 852 886 while( s ) 853 887 { 854 if( s->value || s->def ) 855 irc_usermsg( irc, "%s = `%s'", s->key, s->value ? s->value : s->def ); 856 else 857 irc_usermsg( irc, "%s is empty", s->key ); 888 cmd_showset( irc, &s, s->key ); 858 889 s = s->next; 859 890 } … … 863 894 static void cmd_save( irc_t *irc, char **cmd ) 864 895 { 865 if( storage_save( irc, TRUE ) == STORAGE_OK ) 896 if( ( irc->status & USTATUS_IDENTIFIED ) == 0 ) 897 irc_usermsg( irc, "Please create an account first" ); 898 else if( storage_save( irc, NULL, TRUE ) == STORAGE_OK ) 866 899 irc_usermsg( irc, "Configuration saved" ); 867 900 else -
set.c
r9b55485 r823de9d 26 26 #include "bitlbee.h" 27 27 28 /* Used to use NULL for this, but NULL is actually a "valid" value. */ 29 char *SET_INVALID = "nee"; 30 28 31 set_t *set_add( set_t **head, char *key, char *def, set_eval eval, void *data ) 29 32 { … … 114 117 115 118 if( !s ) 119 /* 120 Used to do this, but it never really made sense. 116 121 s = set_add( head, key, NULL, NULL, NULL ); 117 118 if( s->eval && !( nv = s->eval( s, value ) ) ) 122 */ 123 return 0; 124 125 if( value == NULL && ( s->flags & SET_NULL_OK ) == 0 ) 126 return 0; 127 128 /* Call the evaluator. For invalid values, evaluators should now 129 return SET_INVALID, but previously this was NULL. Try to handle 130 that too if NULL is not an allowed value for this setting. */ 131 if( s->eval && ( ( nv = s->eval( s, value ) ) == SET_INVALID || 132 ( ( s->flags & SET_NULL_OK ) == 0 && nv == NULL ) ) ) 119 133 return 0; 120 134 … … 168 182 } 169 183 170 voidset_reset( set_t **head, char *key )184 int set_reset( set_t **head, char *key ) 171 185 { 172 186 set_t *s; … … 174 188 s = set_find( head, key ); 175 189 if( s ) 176 set_setstr( head, key, s->def ); 190 return set_setstr( head, key, s->def ); 191 192 return 0; 177 193 } 178 194 … … 187 203 for( ; *s; s ++ ) 188 204 if( !isdigit( *s ) ) 189 return NULL;205 return SET_INVALID; 190 206 191 207 return value; … … 194 210 char *set_eval_bool( set_t *set, char *value ) 195 211 { 196 return is_bool( value ) ? value : NULL;212 return is_bool( value ) ? value : SET_INVALID; 197 213 } 198 214 … … 209 225 } 210 226 211 char *set_eval_op_root( set_t *set, char *value )227 char* set_eval_op_root( set_t *set, char* value ) 212 228 { 213 229 irc_t *irc = set->data; 214 char *ret = set_eval_bool(set, value);230 char* ret = set_eval_bool(set, value); 215 231 int b = bool2int(ret); 216 232 217 233 irc_write( irc, ":%s!%s@%s MODE %s %s %s", irc->mynick, irc->mynick, irc->myhost, 218 irc->channel, b?"+o":"-o", irc->mynick ); 234 irc->channel, b?"+o":"-o", irc->mynick); 235 219 236 return ret; 220 237 } 221 238 222 char *set_eval_op_user( set_t *set, char *value )239 char* set_eval_op_user( set_t *set, char* value ) 223 240 { 224 241 irc_t *irc = set->data; 225 char *ret = set_eval_bool(set, value);242 char* ret = set_eval_bool(set, value); 226 243 int b = bool2int(ret); 227 244 228 245 irc_write( irc, ":%s!%s@%s MODE %s %s %s", irc->mynick, irc->mynick, irc->myhost, 229 irc->channel, b?"+o":"-o", irc->nick ); 246 irc->channel, b?"+o":"-o", irc->nick); 247 230 248 return ret; 231 249 } … … 250 268 else 251 269 return NULL; 252 270 253 271 /* sorry for calling them op/deop - too lazy for search+replace :P */ 254 272 op[0]='\0'; … … 335 353 char *flags = g_strnfill(ndeop, modeflag); 336 354 irc_write( irc, ":%s!%s@%s MODE %s -%s%s", irc->mynick, irc->mynick, irc->myhost, 337 338 339 340 355 irc->channel, flags, deop ); 356 g_free(flags); 357 } 358 341 359 return value; 342 360 } … … 370 388 return NULL; 371 389 } 390 -
set.h
r9b55485 r823de9d 44 44 typedef char *(*set_eval) ( struct set *set, char *value ); 45 45 46 extern char *SET_INVALID; 47 48 #define SET_NULL_OK 0x0100 49 46 50 typedef struct set 47 51 { … … 61 65 this (yet?). */ 62 66 63 /* Eval: Returns NULL if the value is incorrect or exactly the64 passed value variable. When returning a corrected value,67 /* Eval: Returns SET_INVALID if the value is incorrect or exactly 68 the passed value variable. When returning a corrected value, 65 69 set_setstr() should be able to free() the returned string! */ 66 70 set_eval eval; … … 88 92 int set_setint( set_t **head, char *key, int value ); 89 93 void set_del( set_t **head, char *key ); 90 voidset_reset( set_t **head, char *key );94 int set_reset( set_t **head, char *key ); 91 95 92 96 /* Two very useful generic evaluators. */ -
sock.h
r9b55485 r823de9d 16 16 #else 17 17 # include <winsock2.h> 18 # include <ws2tcpip.h> 18 # ifndef _MSC_VER 19 # include <ws2tcpip.h> 20 # endif 19 21 # if !defined(BITLBEE_CORE) && defined(_MSC_VER) 20 22 # pragma comment(lib,"bitlbee.lib") 21 23 # endif 22 24 # include <io.h> 25 # define read(a,b,c) recv(a,b,c,0) 26 # define write(a,b,c) send(a,b,c,0) 27 # define umask _umask 28 # define mode_t int 23 29 # define sock_make_nonblocking(fd) { int non_block = 1; ioctlsocket(fd, FIONBIO, &non_block); } 24 30 # define sock_make_blocking(fd) { int non_block = 0; ioctlsocket(fd, FIONBIO, &non_block); } -
storage.c
r9b55485 r823de9d 104 104 } 105 105 106 storage_status_t storage_load (const char *nick, const char *password, irc_t * irc) 107 { 108 GList *gl; 106 storage_status_t storage_load (irc_t * irc, const char *password) 107 { 108 GList *gl; 109 110 if (irc && irc->status & USTATUS_IDENTIFIED) 111 return STORAGE_OTHER_ERROR; 109 112 110 113 /* Loop until we don't get NO_SUCH_USER */ … … 113 116 storage_status_t status; 114 117 115 status = st->load( nick, password, irc);118 status = st->load(irc, password); 116 119 if (status == STORAGE_OK) { 117 irc_setpass(irc, password); 118 otr_load(irc); /* load our OTR userstate */ 120 otr_load(irc); 119 121 return status; 120 122 } 121 123 122 if (status != STORAGE_NO_SUCH_USER) {124 if (status != STORAGE_NO_SUCH_USER) 123 125 return status; 124 }125 126 } 126 127 … … 128 129 } 129 130 130 storage_status_t storage_save (irc_t *irc, int overwrite)131 storage_status_t storage_save (irc_t *irc, char *password, int overwrite) 131 132 { 132 133 storage_status_t st; 133 134 135 if (password != NULL) { 136 /* Should only use this in the "register" command. */ 137 if (irc->password || overwrite) 138 return STORAGE_OTHER_ERROR; 139 140 irc_setpass(irc, password); 141 } else if ((irc->status & USTATUS_IDENTIFIED) == 0) { 142 return STORAGE_NO_SUCH_USER; 143 } 144 134 145 otr_save(irc); 135 146 st = ((storage_t *)global.storage->data)->save(irc, overwrite); 147 148 if (password != NULL) { 149 irc_setpass(irc, NULL); 150 } 151 136 152 return st; 137 153 } … … 150 166 151 167 status = st->remove(nick, password); 152 if (status != STORAGE_NO_SUCH_USER && 153 status != STORAGE_OK) 168 if (status != STORAGE_NO_SUCH_USER && status != STORAGE_OK) 154 169 ret = status; 155 170 } … … 160 175 return ret; 161 176 } 177 178 #if 0 179 Not using this yet. Test thoroughly before adding UI hooks to this function. 162 180 163 181 storage_status_t storage_rename (const char *onick, const char *nnick, const char *password) … … 202 220 return STORAGE_OK; 203 221 } 222 #endif -
storage.h
r9b55485 r823de9d 45 45 storage_status_t (*check_pass) (const char *nick, const char *password); 46 46 47 storage_status_t (*load) ( const char *nick, const char *password, irc_t * irc);47 storage_status_t (*load) (irc_t *irc, const char *password); 48 48 storage_status_t (*save) (irc_t *irc, int overwrite); 49 49 storage_status_t (*remove) (const char *nick, const char *password); … … 55 55 storage_status_t storage_check_pass (const char *nick, const char *password); 56 56 57 storage_status_t storage_load ( const char *nick, const char *password, irc_t * irc);58 storage_status_t storage_save (irc_t *irc, int overwrite);57 storage_status_t storage_load (irc_t * irc, const char *password); 58 storage_status_t storage_save (irc_t *irc, char *password, int overwrite); 59 59 storage_status_t storage_remove (const char *nick, const char *password); 60 60 61 storage_status_t storage_rename (const char *onick, const char *nnick, const char *password); 61 /* storage_status_t storage_rename (const char *onick, const char *nnick, const char *password); */ 62 62 63 63 void register_storage_backend(storage_t *); -
storage_text.c
r9b55485 r823de9d 27 27 #include "bitlbee.h" 28 28 #include "crypting.h" 29 #ifdef _WIN3230 # define umask _umask31 # define mode_t int32 #endif33 34 #ifndef F_OK35 #define F_OK 036 #endif37 29 38 30 static void text_init (void) … … 44 36 } 45 37 46 static storage_status_t text_load ( const char *my_nick, const char* password, irc_t *irc)38 static storage_status_t text_load( irc_t *irc, const char* password ) 47 39 { 48 40 char s[512]; … … 54 46 account_t *acc, *acc_lookup[9]; 55 47 56 if( irc->status & USTATUS_IDENTIFIED ) 57 return( 1 ); 58 59 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, my_nick, ".accounts" ); 48 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" ); 60 49 fp = fopen( s, "r" ); 61 50 if( !fp ) return STORAGE_NO_SUCH_USER; … … 68 57 return STORAGE_INVALID_PASSWORD; 69 58 } 70 71 /* Do this now. If the user runs with AuthMode = Registered, the72 account command will not work otherwise. */73 irc->status |= USTATUS_IDENTIFIED;74 59 75 60 while( fscanf( fp, "%511[^\n]s", s ) > 0 ) … … 101 86 } 102 87 103 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, my_nick, ".nicks" );88 g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" ); 104 89 fp = fopen( s, "r" ); 105 90 if( !fp ) return STORAGE_NO_SUCH_USER; -
storage_xml.c
r9b55485 r823de9d 29 29 #include "arc.h" 30 30 #include "md5.h" 31 32 #if GLIB_CHECK_VERSION(2,8,0) 31 33 #include <glib/gstdio.h> 34 #else 35 /* GLib < 2.8.0 doesn't have g_access, so just use the system access(). */ 36 #include <unistd.h> 37 #define g_access access 38 #endif 32 39 33 40 #if !GLIB_CHECK_VERSION(2,8,0) … … 256 263 } 257 264 258 static storage_status_t xml_load_real( const char *my_nick, const char *password, irc_t *irc, xml_pass_st action )265 static storage_status_t xml_load_real( irc_t *irc, const char *my_nick, const char *password, xml_pass_st action ) 259 266 { 260 267 GMarkupParseContext *ctx; … … 263 270 GError *gerr = NULL; 264 271 int fd, st; 265 266 if( irc && irc->status & USTATUS_IDENTIFIED )267 return( 1 );268 272 269 273 xd = g_new0( struct xml_parsedata, 1 ); … … 318 322 return STORAGE_OK; 319 323 320 irc->status |= USTATUS_IDENTIFIED;321 322 324 return STORAGE_OK; 323 325 } 324 326 325 static storage_status_t xml_load( const char *my_nick, const char *password, irc_t *irc)326 { 327 return xml_load_real( my_nick, password, irc, XML_PASS_UNKNOWN );327 static storage_status_t xml_load( irc_t *irc, const char *password ) 328 { 329 return xml_load_real( irc, irc->nick, password, XML_PASS_UNKNOWN ); 328 330 } 329 331 … … 332 334 /* This is a little bit risky because we have to pass NULL for the 333 335 irc_t argument. This *should* be fine, if I didn't miss anything... */ 334 return xml_load_real( my_nick, password, NULL, XML_PASS_CHECK_ONLY );336 return xml_load_real( NULL, my_nick, password, XML_PASS_CHECK_ONLY ); 335 337 } 336 338 … … 367 369 md5_byte_t pass_md5[21]; 368 370 md5_state_t md5_state; 369 370 if( irc->password == NULL )371 {372 irc_usermsg( irc, "Please register yourself if you want to save your settings." );373 return STORAGE_OTHER_ERROR;374 }375 371 376 372 path2 = g_strdup( irc->nick ); -
unix.c
r9b55485 r823de9d 56 56 b_main_init(); 57 57 nogaim_init(); 58 /* Ugly Note: libotr and gnutls both use libgcrypt. libgcrypt59 has a process-global config state whose initialization happpens60 twice if libotr and gnutls are used together. libotr installs custom61 memory management functions for libgcrypt while our gnutls module62 uses the defaults. Therefore we initialize OTR after SSL. *sigh* */63 ssl_init();64 otr_init();58 /* Ugly Note: libotr and gnutls both use libgcrypt. libgcrypt 59 has a process-global config state whose initialization happpens 60 twice if libotr and gnutls are used together. libotr installs custom 61 memory management functions for libgcrypt while our gnutls module 62 uses the defaults. Therefore we initialize OTR after SSL. *sigh* */ 63 ssl_init(); 64 otr_init(); 65 65 66 66 srand( time( NULL ) ^ getpid() ); … … 223 223 return( (double) time->tv_sec + (double) time->tv_usec / 1000000 ); 224 224 } 225 226
Note: See TracChangeset
for help on using the changeset viewer.