Ignore:
Timestamp:
2006-09-22T18:39:31Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
d8e0484
Parents:
8d74291
Message:

Better detection of successful IQ authentication (using packet caching),
properly working SASL authentication (although only PLAIN so far).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    r8d74291 rfe7a554  
    2828        struct gaim_connection *gc = data;
    2929        struct jabber_data *jd = gc->proto_data;
    30         struct xt_node *query, *reply = NULL;
     30        struct xt_node *query, *reply = NULL, *orig = NULL;
    3131        char *s, *type, *xmlns;
    3232        int st;
     
    3939       
    4040        xmlns = xt_find_attr( query, "xmlns" );
     41       
     42        if( ( s = xt_find_attr( node, "id" ) ) )
     43                orig = jabber_packet_from_cache( gc, s );
    4144       
    4245        if( strcmp( type, "result" ) == 0 && xmlns && strcmp( xmlns, "jabber:iq:auth" ) == 0 )
     
    8285               
    8386                reply = jabber_make_packet( "iq", "set", NULL, reply );
     87                jabber_cache_packet( gc, reply );
    8488                st = jabber_write_packet( gc, reply );
    85                 xt_free_node( reply );
    8689               
    8790                return st ? XT_HANDLED : XT_ABORT;
     
    106109                presence_announce( gc );
    107110        }
    108         else if( strcmp( type, "result" ) == 0 )
     111        else if( strcmp( type, "result" ) == 0 && orig )
    109112        {
    110                 /* If we weren't authenticated yet, let's assume we are now.
    111                    There are cleaner ways to do this, probably, but well.. */
    112                 if( !( jd->flags & JFLAG_AUTHENTICATED ) )
     113                struct xt_node *node;
     114               
     115                if( !( jd->flags & JFLAG_AUTHENTICATED ) &&
     116                    ( node = xt_find_node( orig->children, "query" ) ) &&
     117                    ( node = xt_find_node( node->children, "username" ) ) &&
     118                    node->text_len )
    113119                {
     120                        /* This happens when we just successfully authenticated
     121                           the old (non-SASL) way. */
    114122                        jd->flags |= JFLAG_AUTHENTICATED;
    115123                        if( !jabber_get_roster( gc ) )
    116124                                return XT_ABORT;
     125                }
     126                else if( ( node = xt_find_node( orig->children, "bind" ) ) ||
     127                         ( node = xt_find_node( orig->children, "session" ) ) )
     128                {
     129                        if( strcmp( node->name, "bind" ) == 0 )
     130                                jd->flags &= ~JFLAG_WAIT_BIND;
     131                        else if( strcmp( node->name, "session" ) == 0 )
     132                                jd->flags &= ~JFLAG_WAIT_SESSION;
     133                       
     134                        if( ( jd->flags & ( JFLAG_WAIT_BIND | JFLAG_WAIT_SESSION ) ) == 0 )
     135                        {
     136                                if( !jabber_get_roster( gc ) )
     137                                        return XT_ABORT;
     138                        }
    117139                }
    118140        }
Note: See TracChangeset for help on using the changeset viewer.