]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/jabber/serv_xmpp.c
Require <bind> tag for bind attempts.
[citadel.git] / citadel / modules / jabber / serv_xmpp.c
index 00bdc19d769f6d54e88df615e6e562b7f1f5c5a0..00c08bd893facb95666de2247975a6e892f83f08 100644 (file)
@@ -89,8 +89,8 @@ void xmpp_stream_start(void *data, const char *supplied_el, const char **attr)
                /* If we're not logged in yet, offer SASL as our feature set */
                xmpp_output_auth_mechs();
 
-               /* Also offer non-SASL authentication */
-               cprintf("<auth xmlns=\"http://jabber.org/features/iq-auth\"/>");
+               /* Also offer non-SASL authentication 
+               cprintf("<auth xmlns=\"http://jabber.org/features/iq-auth\"/>"); */
        }
 
        /* Offer binding and sessions as part of our feature set */
@@ -129,6 +129,10 @@ void xmpp_xml_start(void *data, const char *supplied_el, const char **attr) {
                safestrncpy(XMPP->iq_query_xmlns, supplied_el, sizeof XMPP->iq_query_xmlns);
        }
 
+       else if (!strcasecmp(el, "bind")) {
+               XMPP->bind_requested = 1;
+       }
+
        else if (!strcasecmp(el, "iq")) {
                for (i=0; attr[i] != NULL; i+=2) {
                        if (!strcasecmp(attr[i], "type")) {
@@ -219,7 +223,12 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
                /*
                 * If this <iq> stanza was a "bind" attempt, process it ...
                 */
-               else if ( (!IsEmptyStr(XMPP->iq_id)) && (!IsEmptyStr(XMPP->iq_client_resource)) ) {
+               else if (
+                       (XMPP->bind_requested)
+                       && (!IsEmptyStr(XMPP->iq_id))
+                       && (!IsEmptyStr(XMPP->iq_client_resource))
+                       && (CC->logged_in)
+                       ) {
 
                        /* Generate the "full JID" of the client resource */
 
@@ -257,6 +266,7 @@ void xmpp_xml_end(void *data, const char *supplied_el) {
                XMPP->iq_client_resource[0] = 0;
                XMPP->iq_session = 0;
                XMPP->iq_query_xmlns[0] = 0;
+               XMPP->bind_requested = 0;
        }
 
        else if (!strcasecmp(el, "auth")) {