Changeset 0da65d5 for protocols/jabber/sasl.c
- Timestamp:
- 2007-03-31T05:40:45Z (17 years ago)
- Branches:
- master
- Children:
- aef4828
- Parents:
- fa29d093
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/sasl.c
rfa29d093 r0da65d5 27 27 xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data ) 28 28 { 29 struct gaim_connection *gc = data;30 struct jabber_data *jd = gc->proto_data;29 struct im_connection *ic = data; 30 struct jabber_data *jd = ic->proto_data; 31 31 struct xt_node *c, *reply; 32 32 char *s; 33 33 int sup_plain = 0, sup_digest = 0; 34 34 35 if( !sasl_supported( gc ) )35 if( !sasl_supported( ic ) ) 36 36 { 37 37 /* Should abort this now, since we should already be doing 38 38 IQ authentication. Strange things happen when you try 39 39 to do both... */ 40 serv_got_crap( gc, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" );40 serv_got_crap( ic, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" ); 41 41 return XT_HANDLED; 42 42 } … … 45 45 if( !s || strcmp( s, XMLNS_SASL ) != 0 ) 46 46 { 47 signoff( gc );47 signoff( ic ); 48 48 return XT_ABORT; 49 49 } … … 62 62 if( !sup_plain && !sup_digest ) 63 63 { 64 hide_login_progress( gc, "No known SASL authentication schemes supported" );65 signoff( gc );64 hide_login_progress( ic, "No known SASL authentication schemes supported" ); 65 signoff( ic ); 66 66 return XT_ABORT; 67 67 } … … 83 83 84 84 /* With SASL PLAIN in XMPP, the text should be b64(\0user\0pass) */ 85 len = strlen( jd->username ) + strlen( gc->acc->pass ) + 2;85 len = strlen( jd->username ) + strlen( ic->acc->pass ) + 2; 86 86 s = g_malloc( len + 1 ); 87 87 s[0] = 0; 88 88 strcpy( s + 1, jd->username ); 89 strcpy( s + 2 + strlen( jd->username ), gc->acc->pass );89 strcpy( s + 2 + strlen( jd->username ), ic->acc->pass ); 90 90 reply->text = base64_encode( s, len ); 91 91 reply->text_len = strlen( reply->text ); … … 93 93 } 94 94 95 if( !jabber_write_packet( gc, reply ) )95 if( !jabber_write_packet( ic, reply ) ) 96 96 { 97 97 xt_free_node( reply ); … … 181 181 xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data ) 182 182 { 183 struct gaim_connection *gc = data;184 struct jabber_data *jd = gc->proto_data;183 struct im_connection *ic = data; 184 struct jabber_data *jd = ic->proto_data; 185 185 struct xt_node *reply = NULL; 186 186 char *nonce = NULL, *realm = NULL, *cnonce = NULL, cnonce_bin[30]; … … 222 222 I decided to call it H. */ 223 223 md5_init( &H ); 224 s = g_strdup_printf( "%s:%s:%s", jd->username, realm, gc->acc->pass );224 s = g_strdup_printf( "%s:%s:%s", jd->username, realm, ic->acc->pass ); 225 225 md5_append( &H, (unsigned char *) s, strlen( s ) ); 226 226 g_free( s ); … … 272 272 xt_add_attr( reply, "xmlns", XMLNS_SASL ); 273 273 274 if( !jabber_write_packet( gc, reply ) )274 if( !jabber_write_packet( ic, reply ) ) 275 275 goto silent_error; 276 276 … … 279 279 280 280 error: 281 hide_login_progress( gc, "Incorrect SASL challenge received" );282 signoff( gc );281 hide_login_progress( ic, "Incorrect SASL challenge received" ); 282 signoff( ic ); 283 283 284 284 silent_error: … … 296 296 xt_status sasl_pkt_result( struct xt_node *node, gpointer data ) 297 297 { 298 struct gaim_connection *gc = data;299 struct jabber_data *jd = gc->proto_data;298 struct im_connection *ic = data; 299 struct jabber_data *jd = ic->proto_data; 300 300 char *s; 301 301 … … 303 303 if( !s || strcmp( s, XMLNS_SASL ) != 0 ) 304 304 { 305 signoff( gc );305 signoff( ic ); 306 306 return XT_ABORT; 307 307 } … … 309 309 if( strcmp( node->name, "success" ) == 0 ) 310 310 { 311 set_login_progress( gc, 1, "Authentication finished" );311 set_login_progress( ic, 1, "Authentication finished" ); 312 312 jd->flags |= JFLAG_AUTHENTICATED | JFLAG_STREAM_RESTART; 313 313 } 314 314 else if( strcmp( node->name, "failure" ) == 0 ) 315 315 { 316 hide_login_progress( gc, "Authentication failure" );317 signoff( gc );316 hide_login_progress( ic, "Authentication failure" ); 317 signoff( ic ); 318 318 return XT_ABORT; 319 319 } … … 325 325 It's done by checking if the <stream:stream> from the server has a 326 326 version attribute. I don't know if this is the right way though... */ 327 gboolean sasl_supported( struct gaim_connection *gc )328 { 329 struct jabber_data *jd = gc->proto_data;327 gboolean sasl_supported( struct im_connection *ic ) 328 { 329 struct jabber_data *jd = ic->proto_data; 330 330 331 331 return ( (void*) ( jd->xt && jd->xt->root && xt_find_attr( jd->xt->root, "version" ) ) ) != NULL;
Note: See TracChangeset
for help on using the changeset viewer.