From 8d7429102adf8dce6844f2f3da2723d1f87c6442 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Fri, 22 Sep 2006 18:56:58 +0200 Subject: Fixed return value on incomplete write()s in write handler, protection against write()ing to sockets that are closed already, hopefully sane detection for SASL support, and only sending type=unavailable presence tag to logged in sessions. --- protocols/jabber/sasl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'protocols/jabber/sasl.c') diff --git a/protocols/jabber/sasl.c b/protocols/jabber/sasl.c index da577877..2f75e733 100644 --- a/protocols/jabber/sasl.c +++ b/protocols/jabber/sasl.c @@ -34,6 +34,15 @@ xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data ) char *s; int sup_plain = 0, sup_digest = 0; + if( !sasl_supported( gc ) ) + { + /* Should abort this now, since we should already be doing + IQ authentication. Strange things happen when you try + to do both... */ + serv_got_crap( gc, "XMPP 1.0 non-compliant server seems to support SASL, please report this as a BitlBee bug!" ); + return XT_HANDLED; + } + s = xt_find_attr( node, "xmlns" ); if( !s || strcmp( s, SASL_NS ) != 0 ) { @@ -93,6 +102,7 @@ xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data ) xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data ) { + return XT_HANDLED; } xt_status sasl_pkt_result( struct xt_node *node, gpointer data ) @@ -122,3 +132,13 @@ xt_status sasl_pkt_result( struct xt_node *node, gpointer data ) return XT_HANDLED; } + +/* This one is needed to judge if we'll do authentication using IQ or SASL. + It's done by checking if the from the server has a + version attribute. I don't know if this is the right way though... */ +gboolean sasl_supported( struct gaim_connection *gc ) +{ + struct jabber_data *jd = gc->proto_data; + + return ( jd->xt && jd->xt->root && xt_find_attr( jd->xt->root, "version" ) ) != NULL; +} -- cgit v1.2.3