Mercurial > pidgin.yaz
changeset 12543:09cae5fdd5b6
[gaim-migrate @ 14860]
cyrus sasl works for PLAIN now too, and it even logs!
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sat, 17 Dec 2005 22:12:15 +0000 |
parents | 038ac22dd79b |
children | b36235b2f2ec |
files | src/protocols/jabber/auth.c |
diffstat | 1 files changed, 24 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/jabber/auth.c Sat Dec 17 21:28:54 2005 +0000 +++ b/src/protocols/jabber/auth.c Sat Dec 17 22:12:15 2005 +0000 @@ -140,7 +140,7 @@ *res = js->user->node; break; case SASL_CB_USER: - *res = js->user->node; + *res = ""; break; default: return SASL_BADPARAM; @@ -192,17 +192,15 @@ /* Set up security properties and options */ secprops.min_ssf = 0; secprops.security_flags = SASL_SEC_NOANONYMOUS; + secprops.max_ssf = -1; + secprops.maxbufsize = -1; if (!js->gsc) { plaintext = gaim_account_get_bool(js->gc->account, "auth_plain_in_clear", FALSE); if (!plaintext) secprops.security_flags |= SASL_SEC_NOPLAINTEXT; - secprops.max_ssf = -1; - secprops.maxbufsize = 4096; } else { plaintext = TRUE; - secprops.max_ssf = 0; - secprops.maxbufsize = 0; } secprops.property_names = 0; secprops.property_values = 0; @@ -218,10 +216,12 @@ js->sasl_state = sasl_client_new("xmpp", js->user->domain, NULL, NULL, js->sasl_cb, 0, &js->sasl); if (js->sasl_state==SASL_OK) { sasl_setprop(js->sasl, SASL_SEC_PROPS, &secprops); + gaim_debug_info("sasl", "Mechs found: %s\n", js->sasl_mechs->str); js->sasl_state = sasl_client_start(js->sasl, js->sasl_mechs->str, NULL, &clientout, &coutlen, &mech); } switch (js->sasl_state) { /* Success */ + case SASL_OK: case SASL_CONTINUE: break; case SASL_NOMECH: @@ -253,6 +253,7 @@ /* For everything else, fail the mechanism and try again */ default: + gaim_debug_info("sasl", "sasl_state is %d, failing the mech and trying again\n", js->sasl_state); if (strlen(mech)>0) { char *pos; pos = strstr(js->sasl_mechs->str,mech); @@ -264,7 +265,7 @@ } } while (again); - if (js->sasl_state == SASL_CONTINUE) { + if (js->sasl_state == SASL_CONTINUE || js->sasl_state == SASL_OK) { auth = xmlnode_new("auth"); xmlnode_set_attrib(auth, "xmlns", "urn:ietf:params:xml:ns:xmpp-sasl"); xmlnode_set_attrib(auth,"mechanism", mech); @@ -284,6 +285,15 @@ } } +static int +jabber_sasl_cb_log(void *context, int level, const char *message) +{ + if(level <= SASL_LOG_TRACE) + gaim_debug_info("sasl", "%s\n", message); + + return SASL_OK; +} + #endif void @@ -334,7 +344,7 @@ js->auth_type = JABBER_AUTH_CYRUS; /* Set up our callbacks structure */ - js->sasl_cb = g_new0(sasl_callback_t,5); + js->sasl_cb = g_new0(sasl_callback_t,6); id = 0; js->sasl_cb[id].id = SASL_CB_GETREALM; @@ -359,6 +369,11 @@ id++; } + js->sasl_cb[id].id = SASL_CB_LOG; + js->sasl_cb[id].proc = jabber_sasl_cb_log; + js->sasl_cb[id].context = (void*)js; + id++; + js->sasl_cb[id].id = SASL_CB_LIST_END; jabber_auth_start_cyrus(js); @@ -688,7 +703,8 @@ unsigned char *dec_in; char *enc_out; const char *c_out; - unsigned int clen,declen; + unsigned int clen; + gsize declen; xmlnode *response; dec_in = gaim_base64_decode(enc_in, &declen);