Tue, 15 Apr 2008 23:46:03 +0000
Remove the "Use GSSAPI (Kerberos v5) for authentication" xmpp preference,
as it is not needed with Stu's changes in 7643bc26 which continue to the
next mechanism if GSSAPI fails.
| 7014 | 1 | /* |
| 15884 | 2 | * purple - Jabber Protocol Plugin |
| 7014 | 3 | * |
| 4 | * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> | |
| 5 | * | |
| 6 | * This program is free software; you can redistribute it and/or modify | |
| 7 | * it under the terms of the GNU General Public License as published by | |
| 8 | * the Free Software Foundation; either version 2 of the License, or | |
| 9 | * (at your option) any later version. | |
| 10 | * | |
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19852
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7014 | 19 | * |
| 20 | */ | |
| 21 | #include "internal.h" | |
| 22 | ||
|
15952
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
23 | #include "account.h" |
|
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
24 | #include "debug.h" |
|
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
25 | #include "cipher.h" |
|
20093
04f3c1dcd2cf
applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents:
19993
diff
changeset
|
26 | #include "core.h" |
|
15952
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
27 | #include "conversation.h" |
|
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
28 | #include "request.h" |
|
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
29 | #include "sslconn.h" |
|
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
30 | #include "util.h" |
|
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
31 | #include "xmlnode.h" |
|
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
32 | |
| 7014 | 33 | #include "jutil.h" |
| 34 | #include "auth.h" | |
| 35 | #include "jabber.h" | |
| 36 | #include "iq.h" | |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
37 | #include "notify.h" |
| 7014 | 38 | |
| 8397 | 39 | static void auth_old_result_cb(JabberStream *js, xmlnode *packet, |
| 40 | gpointer data); | |
| 7014 | 41 | |
| 8296 | 42 | gboolean |
| 43 | jabber_process_starttls(JabberStream *js, xmlnode *packet) | |
| 7014 | 44 | { |
| 45 | xmlnode *starttls; | |
| 46 | ||
| 7157 | 47 | if((starttls = xmlnode_get_child(packet, "starttls"))) { |
| 15884 | 48 | if(purple_ssl_is_supported()) { |
| 7157 | 49 | jabber_send_raw(js, |
| 7642 | 50 | "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>", -1); |
| 8296 | 51 | return TRUE; |
| 7157 | 52 | } else if(xmlnode_get_child(starttls, "required")) { |
| 21279 | 53 | purple_connection_error_reason (js->gc, |
| 54 | PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, | |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
55 | _("Server requires TLS/SSL for login. No TLS/SSL support found.")); |
| 8296 | 56 | return TRUE; |
| 7157 | 57 | } |
| 7014 | 58 | } |
| 59 | ||
| 8296 | 60 | return FALSE; |
| 61 | } | |
| 62 | ||
| 8397 | 63 | static void finish_plaintext_authentication(JabberStream *js) |
| 64 | { | |
| 65 | if(js->auth_type == JABBER_AUTH_PLAIN) { | |
| 66 | xmlnode *auth; | |
| 67 | GString *response; | |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
68 | gchar *enc_out; |
| 8397 | 69 | |
| 70 | auth = xmlnode_new("auth"); | |
| 13808 | 71 | xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl"); |
|
20093
04f3c1dcd2cf
applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents:
19993
diff
changeset
|
72 | |
| 15271 | 73 | xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth"); |
| 15293 | 74 | xmlnode_set_attrib(auth, "ga:client-uses-full-bind-result", "true"); |
|
20093
04f3c1dcd2cf
applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents:
19993
diff
changeset
|
75 | |
| 8397 | 76 | response = g_string_new(""); |
| 77 | response = g_string_append_len(response, "\0", 1); | |
| 78 | response = g_string_append(response, js->user->node); | |
| 79 | response = g_string_append_len(response, "\0", 1); | |
| 80 | response = g_string_append(response, | |
| 15884 | 81 | purple_connection_get_password(js->gc)); |
| 8397 | 82 | |
| 15884 | 83 | enc_out = purple_base64_encode((guchar *)response->str, response->len); |
| 8397 | 84 | |
| 85 | xmlnode_set_attrib(auth, "mechanism", "PLAIN"); | |
| 86 | xmlnode_insert_data(auth, enc_out, -1); | |
| 87 | g_free(enc_out); | |
| 88 | g_string_free(response, TRUE); | |
| 89 | ||
| 90 | jabber_send(js, auth); | |
| 91 | xmlnode_free(auth); | |
| 92 | } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) { | |
| 93 | JabberIq *iq; | |
| 94 | xmlnode *query, *x; | |
| 95 | ||
| 96 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); | |
| 97 | query = xmlnode_get_child(iq->node, "query"); | |
| 98 | x = xmlnode_new_child(query, "username"); | |
| 99 | xmlnode_insert_data(x, js->user->node, -1); | |
| 100 | x = xmlnode_new_child(query, "resource"); | |
| 101 | xmlnode_insert_data(x, js->user->resource, -1); | |
| 102 | x = xmlnode_new_child(query, "password"); | |
| 15884 | 103 | xmlnode_insert_data(x, purple_connection_get_password(js->gc), -1); |
| 8397 | 104 | jabber_iq_set_callback(iq, auth_old_result_cb, NULL); |
| 105 | jabber_iq_send(iq); | |
| 106 | } | |
| 107 | } | |
| 108 | ||
| 15884 | 109 | static void allow_plaintext_auth(PurpleAccount *account) |
| 8397 | 110 | { |
| 15884 | 111 | purple_account_set_bool(account, "auth_plain_in_clear", TRUE); |
| 8397 | 112 | |
| 113 | finish_plaintext_authentication(account->gc->proto_data); | |
| 114 | } | |
| 115 | ||
| 15884 | 116 | static void disallow_plaintext_auth(PurpleAccount *account) |
| 8397 | 117 | { |
| 21279 | 118 | purple_connection_error_reason (account->gc, |
| 119 | PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, | |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
120 | _("Server requires plaintext authentication over an unencrypted stream")); |
| 8397 | 121 | } |
| 122 | ||
| 12508 | 123 | #ifdef HAVE_CYRUS_SASL |
| 124 | ||
| 125 | static void jabber_auth_start_cyrus(JabberStream *); | |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
126 | static void jabber_sasl_build_callbacks(JabberStream *); |
| 12508 | 127 | |
| 128 | /* Callbacks for Cyrus SASL */ | |
| 129 | ||
| 130 | static int jabber_sasl_cb_realm(void *ctx, int id, const char **avail, const char **result) | |
| 131 | { | |
| 132 | JabberStream *js = (JabberStream *)ctx; | |
| 133 | ||
| 134 | if (id != SASL_CB_GETREALM || !result) return SASL_BADPARAM; | |
| 135 | ||
| 136 | *result = js->user->domain; | |
| 137 | ||
| 138 | return SASL_OK; | |
| 139 | } | |
| 140 | ||
| 141 | static int jabber_sasl_cb_simple(void *ctx, int id, const char **res, unsigned *len) | |
| 142 | { | |
| 143 | JabberStream *js = (JabberStream *)ctx; | |
| 144 | ||
| 145 | switch(id) { | |
| 146 | case SASL_CB_AUTHNAME: | |
| 147 | *res = js->user->node; | |
| 148 | break; | |
| 149 | case SASL_CB_USER: | |
| 12543 | 150 | *res = ""; |
| 12508 | 151 | break; |
| 152 | default: | |
| 153 | return SASL_BADPARAM; | |
| 154 | } | |
| 155 | if (len) *len = strlen((char *)*res); | |
| 156 | return SASL_OK; | |
| 157 | } | |
| 158 | ||
| 159 | static int jabber_sasl_cb_secret(sasl_conn_t *conn, void *ctx, int id, sasl_secret_t **secret) | |
| 160 | { | |
| 161 | JabberStream *js = (JabberStream *)ctx; | |
| 15884 | 162 | const char *pw = purple_account_get_password(js->gc->account); |
| 12508 | 163 | size_t len; |
| 164 | static sasl_secret_t *x = NULL; | |
| 165 | ||
| 166 | if (!conn || !secret || id != SASL_CB_PASS) | |
| 167 | return SASL_BADPARAM; | |
| 168 | ||
| 169 | len = strlen(pw); | |
| 170 | x = (sasl_secret_t *) realloc(x, sizeof(sasl_secret_t) + len); | |
| 171 | ||
| 172 | if (!x) | |
| 173 | return SASL_NOMEM; | |
| 174 | ||
| 175 | x->len = len; | |
| 176 | strcpy((char*)x->data, pw); | |
| 177 | ||
| 178 | *secret = x; | |
| 179 | return SASL_OK; | |
| 180 | } | |
| 181 | ||
| 15884 | 182 | static void allow_cyrus_plaintext_auth(PurpleAccount *account) |
| 12508 | 183 | { |
| 15884 | 184 | purple_account_set_bool(account, "auth_plain_in_clear", TRUE); |
| 12508 | 185 | |
| 186 | jabber_auth_start_cyrus(account->gc->proto_data); | |
| 187 | } | |
| 188 | ||
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
189 | static gboolean auth_pass_generic(JabberStream *js, PurpleRequestFields *fields) |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
190 | { |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
191 | const char *entry; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
192 | gboolean remember; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
193 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
194 | entry = purple_request_fields_get_string(fields, "password"); |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
195 | remember = purple_request_fields_get_bool(fields, "remember"); |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
196 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
197 | if (!entry || !*entry) |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
198 | { |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
199 | purple_notify_error(js->gc->account, NULL, _("Password is required to sign on."), NULL); |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
200 | return FALSE; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
201 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
202 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
203 | if (remember) |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
204 | purple_account_set_remember_password(js->gc->account, TRUE); |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
205 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
206 | purple_account_set_password(js->gc->account, entry); |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
207 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
208 | return TRUE; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
209 | } |
|
20093
04f3c1dcd2cf
applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents:
19993
diff
changeset
|
210 | |
|
19852
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
211 | static void auth_pass_cb(PurpleConnection *conn, PurpleRequestFields *fields) |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
212 | { |
|
19852
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
213 | JabberStream *js; |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
214 | |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
215 | /* The password prompt dialog doesn't get disposed if the account disconnects */ |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
216 | if (!PURPLE_CONNECTION_IS_VALID(conn)) |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
217 | return; |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
218 | |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
219 | js = conn->proto_data; |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
220 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
221 | if (!auth_pass_generic(js, fields)) |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
222 | return; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
223 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
224 | /* Rebuild our callbacks as we now have a password to offer */ |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
225 | jabber_sasl_build_callbacks(js); |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
226 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
227 | /* Restart our connection */ |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
228 | jabber_auth_start_cyrus(js); |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
229 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
230 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
231 | static void |
|
19852
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
232 | auth_old_pass_cb(PurpleConnection *conn, PurpleRequestFields *fields) |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
233 | { |
|
19852
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
234 | JabberStream *js; |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
235 | |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
236 | /* The password prompt dialog doesn't get disposed if the account disconnects */ |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
237 | if (!PURPLE_CONNECTION_IS_VALID(conn)) |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
238 | return; |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
239 | |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
240 | js = conn->proto_data; |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
241 | |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
242 | if (!auth_pass_generic(js, fields)) |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
243 | return; |
|
20093
04f3c1dcd2cf
applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents:
19993
diff
changeset
|
244 | |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
245 | /* Restart our connection */ |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
246 | jabber_auth_start_old(js); |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
247 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
248 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
249 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
250 | static void |
|
19852
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
251 | auth_no_pass_cb(PurpleConnection *conn, PurpleRequestFields *fields) |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
252 | { |
|
19852
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
253 | JabberStream *js; |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
254 | |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
255 | /* The password prompt dialog doesn't get disposed if the account disconnects */ |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
256 | if (!PURPLE_CONNECTION_IS_VALID(conn)) |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
257 | return; |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
258 | |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
259 | js = conn->proto_data; |
|
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
260 | |
|
20093
04f3c1dcd2cf
applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents:
19993
diff
changeset
|
261 | /* Disable the account as the user has canceled connecting */ |
|
04f3c1dcd2cf
applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents:
19993
diff
changeset
|
262 | purple_account_set_enabled(conn->account, purple_core_get_ui(), FALSE); |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
263 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
264 | |
| 12508 | 265 | static void jabber_auth_start_cyrus(JabberStream *js) |
| 266 | { | |
|
22800
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
267 | const char *clientout = NULL; |
| 12508 | 268 | char *enc_out; |
|
14232
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
269 | unsigned coutlen = 0; |
| 12508 | 270 | xmlnode *auth; |
| 271 | sasl_security_properties_t secprops; | |
| 272 | gboolean again; | |
| 273 | gboolean plaintext = TRUE; | |
| 274 | ||
| 275 | /* Set up security properties and options */ | |
| 276 | secprops.min_ssf = 0; | |
| 277 | secprops.security_flags = SASL_SEC_NOANONYMOUS; | |
| 278 | ||
| 279 | if (!js->gsc) { | |
| 13207 | 280 | secprops.max_ssf = -1; |
| 281 | secprops.maxbufsize = 4096; | |
| 15884 | 282 | plaintext = purple_account_get_bool(js->gc->account, "auth_plain_in_clear", FALSE); |
| 12508 | 283 | if (!plaintext) |
| 284 | secprops.security_flags |= SASL_SEC_NOPLAINTEXT; | |
| 285 | } else { | |
| 13207 | 286 | secprops.max_ssf = 0; |
| 287 | secprops.maxbufsize = 0; | |
| 12540 | 288 | plaintext = TRUE; |
| 12508 | 289 | } |
| 290 | secprops.property_names = 0; | |
| 291 | secprops.property_values = 0; | |
| 292 | ||
| 293 | do { | |
| 294 | again = FALSE; | |
| 295 | ||
|
15800
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15435
diff
changeset
|
296 | js->sasl_state = sasl_client_new("xmpp", js->serverFQDN, NULL, NULL, js->sasl_cb, 0, &js->sasl); |
| 12508 | 297 | if (js->sasl_state==SASL_OK) { |
| 298 | sasl_setprop(js->sasl, SASL_SEC_PROPS, &secprops); | |
| 15884 | 299 | purple_debug_info("sasl", "Mechs found: %s\n", js->sasl_mechs->str); |
|
22800
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
300 | js->sasl_state = sasl_client_start(js->sasl, js->sasl_mechs->str, NULL, &clientout, &coutlen, &js->current_mech); |
| 12508 | 301 | } |
| 302 | switch (js->sasl_state) { | |
| 303 | /* Success */ | |
| 12543 | 304 | case SASL_OK: |
| 12508 | 305 | case SASL_CONTINUE: |
| 306 | break; | |
| 307 | case SASL_NOMECH: | |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
308 | /* No mechanisms have offered to help */ |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
309 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
310 | /* Firstly, if we don't have a password try |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
311 | * to get one |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
312 | */ |
| 12508 | 313 | |
| 15884 | 314 | if (!purple_account_get_password(js->gc->account)) { |
|
19852
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
315 | purple_account_request_password(js->gc->account, G_CALLBACK(auth_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc); |
| 12508 | 316 | return; |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
317 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
318 | /* If we've got a password, but aren't sending |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
319 | * it in plaintext, see if we can turn on |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
320 | * plaintext auth |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
321 | */ |
| 12508 | 322 | } else if (!plaintext) { |
| 17050 | 323 | char *msg = g_strdup_printf(_("%s requires plaintext authentication over an unencrypted connection. Allow this and continue authentication?"), |
|
17070
539b9296175f
I changed my mind, this should display the whole account name
Nathan Walp <nwalp@pidgin.im>
parents:
17050
diff
changeset
|
324 | js->gc->account->username); |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
325 | purple_request_yes_no(js->gc, _("Plaintext Authentication"), |
| 12508 | 326 | _("Plaintext Authentication"), |
| 17050 | 327 | msg, |
|
22269
3fdf7b13f20a
A few more of those "default_action" fixes
Mark Doliner <markdoliner@pidgin.im>
parents:
22068
diff
changeset
|
328 | 1, js->gc->account, NULL, NULL, js->gc->account, |
| 12508 | 329 | allow_cyrus_plaintext_auth, |
| 330 | disallow_plaintext_auth); | |
| 17050 | 331 | g_free(msg); |
| 12508 | 332 | return; |
|
21966
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
333 | |
| 12508 | 334 | } else { |
|
21966
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
335 | /* We have no mechs which can work. |
|
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
336 | * Try falling back on the old jabber:iq:auth method. We get here if the server supports |
|
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
337 | * one or more sasl mechs, we are compiled with cyrus-sasl support, but we support or can connect with none of |
|
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
338 | * the offerred mechs. jabberd 2.0 w/ SASL and Apple's iChat Server 10.5 both handle and expect |
|
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
339 | * jabber:iq:auth in this situation. iChat Server in particular offers SASL GSSAPI by default, which is often |
|
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
340 | * not configured on the client side, and expects a fallback to jabber:iq:auth when it (predictably) fails. |
|
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
341 | * |
|
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
342 | * Note: xep-0078 points out that using jabber:iq:auth after a sasl failure is wrong. However, |
|
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
343 | * I believe this refers to actual authentication failure, not a simple lack of concordant mechanisms. |
|
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
344 | * Doing otherwise means that simply compiling with SASL support renders the client unable to connect to servers |
|
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
345 | * which would connect without issue otherwise. -evands |
|
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
346 | */ |
|
22329
cb93a3d50585
If falling back on the old auth method for Jabber, be sure to set js->auth_type to JABBER_AUTH_IQ_AUTH.
Evan Schoenberg <evands@pidgin.im>
parents:
22269
diff
changeset
|
347 | js->auth_type = JABBER_AUTH_IQ_AUTH; |
|
21966
4718e3134276
If no sasl mechs are appropriate, attempt a jabber:iq:auth connection. Note that this isn't the same as a failed authentication over sasl. Detailed comments in the code regarding my reasoning for this behavior.
Evan Schoenberg <evands@pidgin.im>
parents:
21630
diff
changeset
|
348 | jabber_auth_start_old(js); |
| 12508 | 349 | return; |
| 350 | } | |
| 351 | /* not reached */ | |
| 352 | break; | |
| 353 | ||
| 354 | /* Fatal errors. Give up and go home */ | |
| 355 | case SASL_BADPARAM: | |
| 356 | case SASL_NOMEM: | |
| 357 | break; | |
| 358 | ||
| 359 | /* For everything else, fail the mechanism and try again */ | |
| 360 | default: | |
| 15884 | 361 | purple_debug_info("sasl", "sasl_state is %d, failing the mech and trying again\n", js->sasl_state); |
|
14232
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
362 | |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
363 | /* |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
364 | * DAA: is this right? |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
365 | * The manpage says that "mech" will contain the chosen mechanism on success. |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
366 | * Presumably, if we get here that isn't the case and we shouldn't try again? |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
367 | * I suspect that this never happens. |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
368 | */ |
|
15800
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15435
diff
changeset
|
369 | /* |
|
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15435
diff
changeset
|
370 | * SXW: Yes, this is right. What this handles is the situation where a |
|
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15435
diff
changeset
|
371 | * mechanism, say GSSAPI, is tried. If that mechanism fails, it may be |
|
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15435
diff
changeset
|
372 | * due to mechanism specific issues, so we want to try one of the other |
|
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15435
diff
changeset
|
373 | * supported mechanisms. This code handles that case |
|
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15435
diff
changeset
|
374 | */ |
|
22800
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
375 | if (js->current_mech && strlen(js->current_mech) > 0) { |
| 12508 | 376 | char *pos; |
|
22800
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
377 | if ((pos = strstr(js->sasl_mechs->str, js->current_mech))) { |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
378 | g_string_erase(js->sasl_mechs, pos-js->sasl_mechs->str, strlen(js->current_mech)); |
|
14232
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
379 | } |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
380 | again = TRUE; |
| 12508 | 381 | } |
|
14232
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
382 | |
| 12508 | 383 | sasl_dispose(&js->sasl); |
| 384 | } | |
| 385 | } while (again); | |
| 386 | ||
| 12543 | 387 | if (js->sasl_state == SASL_CONTINUE || js->sasl_state == SASL_OK) { |
| 12508 | 388 | auth = xmlnode_new("auth"); |
| 13808 | 389 | xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl"); |
|
22800
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
390 | xmlnode_set_attrib(auth, "mechanism", js->current_mech); |
| 12508 | 391 | if (clientout) { |
| 392 | if (coutlen == 0) { | |
| 393 | xmlnode_insert_data(auth, "=", -1); | |
| 394 | } else { | |
| 15884 | 395 | enc_out = purple_base64_encode((unsigned char*)clientout, coutlen); |
| 12508 | 396 | xmlnode_insert_data(auth, enc_out, -1); |
| 397 | g_free(enc_out); | |
| 398 | } | |
| 399 | } | |
| 400 | jabber_send(js, auth); | |
| 401 | xmlnode_free(auth); | |
| 402 | } else { | |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
403 | purple_connection_error_reason (js->gc, |
| 21279 | 404 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
405 | "SASL authentication failed\n"); |
| 12508 | 406 | } |
| 407 | } | |
| 408 | ||
| 12543 | 409 | static int |
| 410 | jabber_sasl_cb_log(void *context, int level, const char *message) | |
| 411 | { | |
| 412 | if(level <= SASL_LOG_TRACE) | |
| 15884 | 413 | purple_debug_info("sasl", "%s\n", message); |
| 12543 | 414 | |
| 415 | return SASL_OK; | |
| 416 | } | |
| 417 | ||
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
418 | void |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
419 | jabber_sasl_build_callbacks(JabberStream *js) |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
420 | { |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
421 | int id; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
422 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
423 | /* Set up our callbacks structure */ |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
424 | if (js->sasl_cb == NULL) |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
425 | js->sasl_cb = g_new0(sasl_callback_t,6); |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
426 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
427 | id = 0; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
428 | js->sasl_cb[id].id = SASL_CB_GETREALM; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
429 | js->sasl_cb[id].proc = jabber_sasl_cb_realm; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
430 | js->sasl_cb[id].context = (void *)js; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
431 | id++; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
432 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
433 | js->sasl_cb[id].id = SASL_CB_AUTHNAME; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
434 | js->sasl_cb[id].proc = jabber_sasl_cb_simple; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
435 | js->sasl_cb[id].context = (void *)js; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
436 | id++; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
437 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
438 | js->sasl_cb[id].id = SASL_CB_USER; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
439 | js->sasl_cb[id].proc = jabber_sasl_cb_simple; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
440 | js->sasl_cb[id].context = (void *)js; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
441 | id++; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
442 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
443 | if (purple_account_get_password(js->gc->account) != NULL ) { |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
444 | js->sasl_cb[id].id = SASL_CB_PASS; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
445 | js->sasl_cb[id].proc = jabber_sasl_cb_secret; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
446 | js->sasl_cb[id].context = (void *)js; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
447 | id++; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
448 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
449 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
450 | js->sasl_cb[id].id = SASL_CB_LOG; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
451 | js->sasl_cb[id].proc = jabber_sasl_cb_log; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
452 | js->sasl_cb[id].context = (void*)js; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
453 | id++; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
454 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
455 | js->sasl_cb[id].id = SASL_CB_LIST_END; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
456 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
457 | |
| 12508 | 458 | #endif |
| 459 | ||
| 8296 | 460 | void |
| 461 | jabber_auth_start(JabberStream *js, xmlnode *packet) | |
| 462 | { | |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
463 | #ifndef HAVE_CYRUS_SASL |
| 12508 | 464 | gboolean digest_md5 = FALSE, plain=FALSE; |
| 465 | #endif | |
| 8296 | 466 | |
| 12508 | 467 | xmlnode *mechs, *mechnode; |
| 8296 | 468 | |
| 469 | ||
| 8016 | 470 | if(js->registration) { |
| 471 | jabber_register_start(js); | |
| 472 | return; | |
| 473 | } | |
| 474 | ||
| 7014 | 475 | mechs = xmlnode_get_child(packet, "mechanisms"); |
| 476 | ||
| 477 | if(!mechs) { | |
| 21279 | 478 | purple_connection_error_reason (js->gc, |
| 479 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
480 | _("Invalid response from server.")); |
| 7014 | 481 | return; |
| 482 | } | |
| 483 | ||
| 12508 | 484 | #ifdef HAVE_CYRUS_SASL |
| 485 | js->sasl_mechs = g_string_new(""); | |
| 486 | #endif | |
| 487 | ||
| 8135 | 488 | for(mechnode = xmlnode_get_child(mechs, "mechanism"); mechnode; |
| 489 | mechnode = xmlnode_get_next_twin(mechnode)) | |
| 7014 | 490 | { |
| 8135 | 491 | char *mech_name = xmlnode_get_data(mechnode); |
| 12508 | 492 | #ifdef HAVE_CYRUS_SASL |
| 493 | g_string_append(js->sasl_mechs, mech_name); | |
|
14232
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
494 | g_string_append_c(js->sasl_mechs, ' '); |
| 12508 | 495 | #else |
| 8135 | 496 | if(mech_name && !strcmp(mech_name, "DIGEST-MD5")) |
| 497 | digest_md5 = TRUE; | |
| 498 | else if(mech_name && !strcmp(mech_name, "PLAIN")) | |
| 499 | plain = TRUE; | |
| 12508 | 500 | #endif |
| 8135 | 501 | g_free(mech_name); |
| 7014 | 502 | } |
| 503 | ||
| 12508 | 504 | #ifdef HAVE_CYRUS_SASL |
| 505 | js->auth_type = JABBER_AUTH_CYRUS; | |
| 506 | ||
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
507 | jabber_sasl_build_callbacks(js); |
| 12508 | 508 | |
| 509 | jabber_auth_start_cyrus(js); | |
| 510 | #else | |
| 7703 | 511 | |
| 7645 | 512 | if(digest_md5) { |
| 8397 | 513 | xmlnode *auth; |
| 514 | ||
| 515 | js->auth_type = JABBER_AUTH_DIGEST_MD5; | |
| 516 | auth = xmlnode_new("auth"); | |
| 13808 | 517 | xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl"); |
| 7291 | 518 | xmlnode_set_attrib(auth, "mechanism", "DIGEST-MD5"); |
| 8397 | 519 | |
| 520 | jabber_send(js, auth); | |
| 521 | xmlnode_free(auth); | |
| 8086 | 522 | } else if(plain) { |
| 8397 | 523 | js->auth_type = JABBER_AUTH_PLAIN; |
| 7703 | 524 | |
| 15884 | 525 | if(js->gsc == NULL && !purple_account_get_bool(js->gc->account, "auth_plain_in_clear", FALSE)) { |
| 17050 | 526 | char *msg = g_strdup_printf(_("%s requires plaintext authentication over an unencrypted connection. Allow this and continue authentication?"), |
|
17070
539b9296175f
I changed my mind, this should display the whole account name
Nathan Walp <nwalp@pidgin.im>
parents:
17050
diff
changeset
|
527 | js->gc->account->username); |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
528 | purple_request_yes_no(js->gc, _("Plaintext Authentication"), |
| 8397 | 529 | _("Plaintext Authentication"), |
| 17050 | 530 | msg, |
|
22269
3fdf7b13f20a
A few more of those "default_action" fixes
Mark Doliner <markdoliner@pidgin.im>
parents:
22068
diff
changeset
|
531 | 1, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16395
diff
changeset
|
532 | purple_connection_get_account(js->gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
533 | purple_connection_get_account(js->gc), allow_plaintext_auth, |
|
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
534 | disallow_plaintext_auth); |
| 17050 | 535 | g_free(msg); |
| 8086 | 536 | return; |
| 537 | } | |
| 8397 | 538 | finish_plaintext_authentication(js); |
| 7014 | 539 | } else { |
| 21279 | 540 | purple_connection_error_reason (js->gc, |
| 541 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, | |
| 7014 | 542 | _("Server does not use any supported authentication method")); |
| 543 | } | |
| 12508 | 544 | #endif |
| 7014 | 545 | } |
| 546 | ||
| 7395 | 547 | static void auth_old_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
| 7014 | 548 | { |
| 549 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 550 | ||
| 7730 | 551 | if(type && !strcmp(type, "result")) { |
| 552 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
| 553 | } else { | |
| 21279 | 554 | PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
21150
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
20882
diff
changeset
|
555 | char *msg = jabber_parse_error(js, packet, &reason); |
| 8401 | 556 | xmlnode *error; |
| 557 | const char *err_code; | |
| 7014 | 558 | |
|
21150
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
20882
diff
changeset
|
559 | /* FIXME: Why is this not in jabber_parse_error? */ |
| 8401 | 560 | if((error = xmlnode_get_child(packet, "error")) && |
| 561 | (err_code = xmlnode_get_attrib(error, "code")) && | |
| 562 | !strcmp(err_code, "401")) { | |
| 21279 | 563 | reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; |
|
19993
867bd1dfe680
Clear the password when we get an auth. error and we're not saving passwords so that you don't need to go into the account settings to reset it. Fix #3083.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
564 | /* Clear the pasword if it isn't being saved */ |
|
867bd1dfe680
Clear the password when we get an auth. error and we're not saving passwords so that you don't need to go into the account settings to reset it. Fix #3083.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
565 | if (!purple_account_get_remember_password(js->gc->account)) |
|
867bd1dfe680
Clear the password when we get an auth. error and we're not saving passwords so that you don't need to go into the account settings to reset it. Fix #3083.
Daniel Atallah <datallah@pidgin.im>
parents:
19859
diff
changeset
|
566 | purple_account_set_password(js->gc->account, NULL); |
| 7730 | 567 | } |
| 7014 | 568 | |
|
20855
d263076a39f8
Sprinkle gc->wants_to_die = TRUE liberally around connection errors that really
Will Thompson <resiak@pidgin.im>
parents:
20853
diff
changeset
|
569 | purple_connection_error_reason (js->gc, reason, msg); |
| 8401 | 570 | g_free(msg); |
| 7014 | 571 | } |
| 572 | } | |
| 573 | ||
|
21967
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
574 | /*! |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
575 | * @brief Given the server challenge (message) and the key (password), calculate the HMAC-MD5 digest |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
576 | * |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
577 | * This is the crammd5 response. Inspired by cyrus-sasl's _sasl_hmac_md5() |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
578 | */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
579 | static void |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
580 | auth_hmac_md5(const char *challenge, size_t challenge_len, const char *key, size_t key_len, guchar *digest) |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
581 | { |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
582 | PurpleCipher *cipher; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
583 | PurpleCipherContext *context; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
584 | int i; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
585 | /* inner padding - key XORd with ipad */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
586 | unsigned char k_ipad[65]; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
587 | /* outer padding - key XORd with opad */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
588 | unsigned char k_opad[65]; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
589 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
590 | cipher = purple_ciphers_find_cipher("md5"); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
591 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
592 | /* if key is longer than 64 bytes reset it to key=MD5(key) */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
593 | if (strlen(key) > 64) { |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
594 | guchar keydigest[16]; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
595 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
596 | context = purple_cipher_context_new(cipher, NULL); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
597 | purple_cipher_context_append(context, (const guchar *)key, strlen(key)); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
598 | purple_cipher_context_digest(context, 16, keydigest, NULL); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
599 | purple_cipher_context_destroy(context); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
600 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
601 | key = (char *)keydigest; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
602 | key_len = 16; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
603 | } |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
604 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
605 | /* |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
606 | * the HMAC_MD5 transform looks like: |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
607 | * |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
608 | * MD5(K XOR opad, MD5(K XOR ipad, text)) |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
609 | * |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
610 | * where K is an n byte key |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
611 | * ipad is the byte 0x36 repeated 64 times |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
612 | * opad is the byte 0x5c repeated 64 times |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
613 | * and text is the data being protected |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
614 | */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
615 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
616 | /* start out by storing key in pads */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
617 | memset(k_ipad, '\0', sizeof k_ipad); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
618 | memset(k_opad, '\0', sizeof k_opad); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
619 | memcpy(k_ipad, (void *)key, key_len); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
620 | memcpy(k_opad, (void *)key, key_len); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
621 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
622 | /* XOR key with ipad and opad values */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
623 | for (i=0; i<64; i++) { |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
624 | k_ipad[i] ^= 0x36; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
625 | k_opad[i] ^= 0x5c; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
626 | } |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
627 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
628 | /* perform inner MD5 */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
629 | context = purple_cipher_context_new(cipher, NULL); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
630 | purple_cipher_context_append(context, k_ipad, 64); /* start with inner pad */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
631 | purple_cipher_context_append(context, (const guchar *)challenge, challenge_len); /* then text of datagram */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
632 | purple_cipher_context_digest(context, 16, digest, NULL); /* finish up 1st pass */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
633 | purple_cipher_context_destroy(context); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
634 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
635 | /* perform outer MD5 */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
636 | context = purple_cipher_context_new(cipher, NULL); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
637 | purple_cipher_context_append(context, k_opad, 64); /* start with outer pad */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
638 | purple_cipher_context_append(context, digest, 16); /* then results of 1st hash */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
639 | purple_cipher_context_digest(context, 16, digest, NULL); /* finish up 2nd pass */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
640 | purple_cipher_context_destroy(context); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
641 | } |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
642 | |
| 7395 | 643 | static void auth_old_cb(JabberStream *js, xmlnode *packet, gpointer data) |
| 7014 | 644 | { |
| 645 | JabberIq *iq; | |
| 646 | xmlnode *query, *x; | |
| 7514 | 647 | const char *type = xmlnode_get_attrib(packet, "type"); |
| 15884 | 648 | const char *pw = purple_connection_get_password(js->gc); |
| 7014 | 649 | |
| 7514 | 650 | if(!type) { |
| 21279 | 651 | purple_connection_error_reason (js->gc, |
| 652 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
653 | _("Invalid response from server.")); |
| 7014 | 654 | return; |
| 7515 | 655 | } else if(!strcmp(type, "error")) { |
| 21279 | 656 | PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
21150
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
20882
diff
changeset
|
657 | char *msg = jabber_parse_error(js, packet, &reason); |
|
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
20882
diff
changeset
|
658 | purple_connection_error_reason (js->gc, reason, msg); |
| 8401 | 659 | g_free(msg); |
| 7515 | 660 | } else if(!strcmp(type, "result")) { |
| 7514 | 661 | query = xmlnode_get_child(packet, "query"); |
| 662 | if(js->stream_id && xmlnode_get_child(query, "digest")) { | |
| 663 | unsigned char hashval[20]; | |
| 664 | char *s, h[41], *p; | |
| 665 | int i; | |
| 7014 | 666 | |
| 8397 | 667 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); |
| 668 | query = xmlnode_get_child(iq->node, "query"); | |
| 669 | x = xmlnode_new_child(query, "username"); | |
| 670 | xmlnode_insert_data(x, js->user->node, -1); | |
| 671 | x = xmlnode_new_child(query, "resource"); | |
| 672 | xmlnode_insert_data(x, js->user->resource, -1); | |
| 673 | ||
| 7514 | 674 | x = xmlnode_new_child(query, "digest"); |
| 675 | s = g_strdup_printf("%s%s", js->stream_id, pw); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10496
diff
changeset
|
676 | |
| 15884 | 677 | purple_cipher_digest_region("sha1", (guchar *)s, strlen(s), |
| 10687 | 678 | sizeof(hashval), hashval, NULL); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10496
diff
changeset
|
679 | |
| 7514 | 680 | p = h; |
| 681 | for(i=0; i<20; i++, p+=2) | |
| 682 | snprintf(p, 3, "%02x", hashval[i]); | |
| 683 | xmlnode_insert_data(x, h, -1); | |
| 684 | g_free(s); | |
| 8397 | 685 | jabber_iq_set_callback(iq, auth_old_result_cb, NULL); |
| 686 | jabber_iq_send(iq); | |
| 687 | ||
|
21967
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
688 | } else if(js->stream_id && xmlnode_get_child(query, "crammd5")) { |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
689 | const char *challenge; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
690 | guchar digest[16]; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
691 | char h[17], *p; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
692 | int i; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
693 | |
|
21969
9386fcc30b22
Last minute 'cleanup' actually resulted in breakage on my cram-md5 commit. Fixed it.
Evan Schoenberg <evands@pidgin.im>
parents:
21967
diff
changeset
|
694 | challenge = xmlnode_get_attrib(xmlnode_get_child(query, "crammd5"), "challenge"); |
|
22040
d1583c2b25e1
Daniel pointed out that this should be digest, not &digest, because auth_hmac_md5 takes a guchar* rather than a guchar**
Evan Schoenberg <evands@pidgin.im>
parents:
21969
diff
changeset
|
695 | auth_hmac_md5(challenge, strlen(challenge), pw, strlen(pw), digest); |
|
21969
9386fcc30b22
Last minute 'cleanup' actually resulted in breakage on my cram-md5 commit. Fixed it.
Evan Schoenberg <evands@pidgin.im>
parents:
21967
diff
changeset
|
696 | |
|
9386fcc30b22
Last minute 'cleanup' actually resulted in breakage on my cram-md5 commit. Fixed it.
Evan Schoenberg <evands@pidgin.im>
parents:
21967
diff
changeset
|
697 | /* Create the response query */ |
|
21967
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
698 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
699 | query = xmlnode_get_child(iq->node, "query"); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
700 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
701 | x = xmlnode_new_child(query, "username"); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
702 | xmlnode_insert_data(x, js->user->node, -1); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
703 | x = xmlnode_new_child(query, "resource"); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
704 | xmlnode_insert_data(x, js->user->resource, -1); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
705 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
706 | x = xmlnode_new_child(query, "crammd5"); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
707 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
708 | /* Translate the digest to a hexadecimal notation */ |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
709 | p = h; |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
710 | for(i=0; i<16; i++, p+=2) |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
711 | snprintf(p, 3, "%02x", digest[i]); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
712 | xmlnode_insert_data(x, h, -1); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
713 | |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
714 | jabber_iq_set_callback(iq, auth_old_result_cb, NULL); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
715 | jabber_iq_send(iq); |
|
3f1c1518a7e1
Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents:
21966
diff
changeset
|
716 | |
| 8397 | 717 | } else if(xmlnode_get_child(query, "password")) { |
| 15884 | 718 | if(js->gsc == NULL && !purple_account_get_bool(js->gc->account, |
| 8397 | 719 | "auth_plain_in_clear", FALSE)) { |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
720 | purple_request_yes_no(js->gc, _("Plaintext Authentication"), |
| 8397 | 721 | _("Plaintext Authentication"), |
| 722 | _("This server requires plaintext authentication over an unencrypted connection. Allow this and continue authentication?"), | |
|
22269
3fdf7b13f20a
A few more of those "default_action" fixes
Mark Doliner <markdoliner@pidgin.im>
parents:
22068
diff
changeset
|
723 | 1, |
|
16490
68c22924d66b
Added account, who, and conversation parameters to the request API calls, and updated all code to match. I can't compile the Perl module, so I'd appreciate it if someone who knows it would verify that this doesn't break Perl.
Evan Schoenberg <evands@pidgin.im>
parents:
16395
diff
changeset
|
724 | purple_connection_get_account(js->gc), NULL, NULL, |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
725 | purple_connection_get_account(js->gc), allow_plaintext_auth, |
|
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
726 | disallow_plaintext_auth); |
| 8397 | 727 | return; |
| 728 | } | |
| 729 | finish_plaintext_authentication(js); | |
| 7514 | 730 | } else { |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
731 | purple_connection_error_reason (js->gc, |
| 21279 | 732 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
733 | _("Server does not use any supported authentication method")); |
| 8397 | 734 | return; |
| 7514 | 735 | } |
| 7014 | 736 | } |
| 737 | } | |
| 738 | ||
| 739 | void jabber_auth_start_old(JabberStream *js) | |
| 740 | { | |
| 741 | JabberIq *iq; | |
| 742 | xmlnode *query, *username; | |
| 743 | ||
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
744 | #ifdef HAVE_CYRUS_SASL |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
745 | /* If we have Cyrus SASL, then passwords will have been set |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
746 | * to OPTIONAL for this protocol. So, we need to do our own |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
747 | * password prompting here |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
748 | */ |
|
20093
04f3c1dcd2cf
applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents:
19993
diff
changeset
|
749 | |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
750 | if (!purple_account_get_password(js->gc->account)) { |
|
19852
4810415cdcfb
The cyrus SASL password prompt dialogs don't get disposed if the account disconnects. This fixes the callbacks not to assume that the connection is still valid.
Daniel Atallah <datallah@pidgin.im>
parents:
19337
diff
changeset
|
751 | purple_account_request_password(js->gc->account, G_CALLBACK(auth_old_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc); |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
752 | return; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
753 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
754 | #endif |
| 7014 | 755 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:auth"); |
| 756 | ||
| 757 | query = xmlnode_get_child(iq->node, "query"); | |
| 758 | username = xmlnode_new_child(query, "username"); | |
| 759 | xmlnode_insert_data(username, js->user->node, -1); | |
| 760 | ||
| 7395 | 761 | jabber_iq_set_callback(iq, auth_old_cb, NULL); |
| 7014 | 762 | |
| 763 | jabber_iq_send(iq); | |
| 764 | } | |
| 765 | ||
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
766 | /* Parts of this algorithm are inspired by stuff in libgsasl */ |
| 7014 | 767 | static GHashTable* parse_challenge(const char *challenge) |
| 768 | { | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
769 | const char *token_start, *val_start, *val_end, *cur; |
| 7014 | 770 | GHashTable *ret = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 771 | g_free, g_free); | |
| 772 | ||
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
773 | cur = challenge; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
774 | while(*cur != '\0') { |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
775 | /* Find the end of the token */ |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
776 | gboolean in_quotes = FALSE; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
777 | char *name, *value = NULL; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
778 | token_start = cur; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
779 | while(*cur != '\0' && (in_quotes || (!in_quotes && *cur != ','))) { |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
780 | if (*cur == '"') |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
781 | in_quotes = !in_quotes; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
782 | cur++; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
783 | } |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
784 | |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
785 | /* Find start of value. */ |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
786 | val_start = strchr(token_start, '='); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
787 | if (val_start == NULL || val_start > cur) |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
788 | val_start = cur; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
789 | |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
790 | if (token_start != val_start) { |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
791 | name = g_strndup(token_start, val_start - token_start); |
| 7014 | 792 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
793 | if (val_start != cur) { |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
794 | val_start++; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
795 | while (val_start != cur && (*val_start == ' ' || *val_start == '\t' |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
796 | || *val_start == '\r' || *val_start == '\n' |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
797 | || *val_start == '"')) |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
798 | val_start++; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
799 | |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
800 | val_end = cur; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
801 | while (val_end != val_start && (*val_end == ' ' || *val_end == ',' || *val_end == '\t' |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
802 | || *val_end == '\r' || *val_start == '\n' |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
803 | || *val_end == '"')) |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
804 | val_end--; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
805 | |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
806 | if (val_start != val_end) |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
807 | value = g_strndup(val_start, val_end - val_start + 1); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
808 | } |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
809 | |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
810 | g_hash_table_replace(ret, name, value); |
| 7014 | 811 | } |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
812 | |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
813 | /* Find the start of the next token, if there is one */ |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
814 | if (*cur != '\0') { |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
815 | cur++; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
816 | while (*cur == ' ' || *cur == ',' || *cur == '\t' |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
817 | || *cur == '\r' || *cur == '\n') |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
818 | cur++; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
819 | } |
| 7014 | 820 | } |
| 821 | ||
| 822 | return ret; | |
| 823 | } | |
| 824 | ||
|
11163
7fe2cec8e9e6
[gaim-migrate @ 13264]
Mark Doliner <markdoliner@pidgin.im>
parents:
11137
diff
changeset
|
825 | static char * |
| 7014 | 826 | generate_response_value(JabberID *jid, const char *passwd, const char *nonce, |
| 7267 | 827 | const char *cnonce, const char *a2, const char *realm) |
| 7014 | 828 | { |
| 15884 | 829 | PurpleCipher *cipher; |
| 830 | PurpleCipherContext *context; | |
|
11137
cf40226ddff7
[gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
831 | guchar result[16]; |
| 10136 | 832 | size_t a1len; |
| 7014 | 833 | |
| 12549 | 834 | gchar *a1, *convnode=NULL, *convpasswd = NULL, *ha1, *ha2, *kd, *x, *z; |
| 7014 | 835 | |
|
19337
68471e68386a
Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <datallah@pidgin.im>
parents:
19223
diff
changeset
|
836 | if((convnode = g_convert(jid->node, -1, "iso-8859-1", "utf-8", |
| 10136 | 837 | NULL, NULL, NULL)) == NULL) { |
| 838 | convnode = g_strdup(jid->node); | |
| 839 | } | |
|
19337
68471e68386a
Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <datallah@pidgin.im>
parents:
19223
diff
changeset
|
840 | if(passwd && ((convpasswd = g_convert(passwd, -1, "iso-8859-1", |
| 12549 | 841 | "utf-8", NULL, NULL, NULL)) == NULL)) { |
| 10136 | 842 | convpasswd = g_strdup(passwd); |
| 843 | } | |
| 844 | ||
| 15884 | 845 | cipher = purple_ciphers_find_cipher("md5"); |
| 846 | context = purple_cipher_context_new(cipher, NULL); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10496
diff
changeset
|
847 | |
| 12549 | 848 | x = g_strdup_printf("%s:%s:%s", convnode, realm, convpasswd ? convpasswd : ""); |
| 15884 | 849 | purple_cipher_context_append(context, (const guchar *)x, strlen(x)); |
| 850 | purple_cipher_context_digest(context, sizeof(result), result, NULL); | |
| 7014 | 851 | |
| 10136 | 852 | a1 = g_strdup_printf("xxxxxxxxxxxxxxxx:%s:%s", nonce, cnonce); |
| 853 | a1len = strlen(a1); | |
| 854 | g_memmove(a1, result, 16); | |
| 7014 | 855 | |
| 15884 | 856 | purple_cipher_context_reset(context, NULL); |
| 857 | purple_cipher_context_append(context, (const guchar *)a1, a1len); | |
| 858 | purple_cipher_context_digest(context, sizeof(result), result, NULL); | |
| 7014 | 859 | |
| 15884 | 860 | ha1 = purple_base16_encode(result, 16); |
| 7014 | 861 | |
| 15884 | 862 | purple_cipher_context_reset(context, NULL); |
| 863 | purple_cipher_context_append(context, (const guchar *)a2, strlen(a2)); | |
| 864 | purple_cipher_context_digest(context, sizeof(result), result, NULL); | |
| 7014 | 865 | |
| 15884 | 866 | ha2 = purple_base16_encode(result, 16); |
| 7014 | 867 | |
| 868 | kd = g_strdup_printf("%s:%s:00000001:%s:auth:%s", ha1, nonce, cnonce, ha2); | |
| 869 | ||
| 15884 | 870 | purple_cipher_context_reset(context, NULL); |
| 871 | purple_cipher_context_append(context, (const guchar *)kd, strlen(kd)); | |
| 872 | purple_cipher_context_digest(context, sizeof(result), result, NULL); | |
| 873 | purple_cipher_context_destroy(context); | |
| 7014 | 874 | |
| 15884 | 875 | z = purple_base16_encode(result, 16); |
| 7014 | 876 | |
| 10136 | 877 | g_free(convnode); |
| 878 | g_free(convpasswd); | |
| 7014 | 879 | g_free(x); |
| 880 | g_free(a1); | |
| 881 | g_free(ha1); | |
| 882 | g_free(ha2); | |
| 883 | g_free(kd); | |
| 884 | ||
| 885 | return z; | |
| 886 | } | |
| 887 | ||
| 888 | void | |
| 889 | jabber_auth_handle_challenge(JabberStream *js, xmlnode *packet) | |
| 890 | { | |
| 891 | ||
| 7703 | 892 | if(js->auth_type == JABBER_AUTH_DIGEST_MD5) { |
| 7291 | 893 | char *enc_in = xmlnode_get_data(packet); |
| 894 | char *dec_in; | |
| 895 | char *enc_out; | |
| 896 | GHashTable *parts; | |
| 7014 | 897 | |
| 7395 | 898 | if(!enc_in) { |
| 21279 | 899 | purple_connection_error_reason (js->gc, |
| 900 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
901 | _("Invalid response from server.")); |
| 7395 | 902 | return; |
| 903 | } | |
| 904 | ||
| 15884 | 905 | dec_in = (char *)purple_base64_decode(enc_in, NULL); |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22329
diff
changeset
|
906 | purple_debug(PURPLE_DEBUG_MISC, "jabber", "decoded challenge (%" |
|
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22329
diff
changeset
|
907 | G_GSIZE_FORMAT "): %s\n", strlen(dec_in), dec_in); |
| 7291 | 908 | |
| 909 | parts = parse_challenge(dec_in); | |
| 7014 | 910 | |
| 911 | ||
| 7291 | 912 | if (g_hash_table_lookup(parts, "rspauth")) { |
| 913 | char *rspauth = g_hash_table_lookup(parts, "rspauth"); | |
| 7014 | 914 | |
| 915 | ||
| 7291 | 916 | if(rspauth && js->expected_rspauth && |
| 917 | !strcmp(rspauth, js->expected_rspauth)) { | |
| 918 | jabber_send_raw(js, | |
| 7642 | 919 | "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />", |
| 920 | -1); | |
| 7291 | 921 | } else { |
| 21279 | 922 | purple_connection_error_reason (js->gc, |
| 923 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
924 | _("Invalid challenge from server")); |
| 7291 | 925 | } |
| 926 | g_free(js->expected_rspauth); | |
| 927 | } else { | |
| 928 | /* assemble a response, and send it */ | |
| 929 | /* see RFC 2831 */ | |
| 930 | char *realm; | |
| 931 | char *nonce; | |
| 7014 | 932 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
933 | /* Make sure the auth string contains everything that should be there. |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
934 | This isn't everything in RFC2831, but it is what we need. */ |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
935 | |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
936 | nonce = g_hash_table_lookup(parts, "nonce"); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
937 | |
| 7291 | 938 | /* we're actually supposed to prompt the user for a realm if |
| 939 | * the server doesn't send one, but that really complicates things, | |
| 940 | * so i'm not gonna worry about it until is poses a problem to | |
| 941 | * someone, or I get really bored */ | |
| 942 | realm = g_hash_table_lookup(parts, "realm"); | |
| 943 | if(!realm) | |
| 944 | realm = js->user->domain; | |
| 7014 | 945 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
946 | if (nonce == NULL || realm == NULL) |
| 21279 | 947 | purple_connection_error_reason (js->gc, |
| 948 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
949 | _("Invalid challenge from server")); |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
950 | else { |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
951 | GString *response = g_string_new(""); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
952 | char *a2; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
953 | char *auth_resp; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
954 | char *buf; |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
955 | char *cnonce; |
| 7014 | 956 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
957 | cnonce = g_strdup_printf("%x%u%x", g_random_int(), (int)time(NULL), |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
958 | g_random_int()); |
| 7291 | 959 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
960 | a2 = g_strdup_printf("AUTHENTICATE:xmpp/%s", realm); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
961 | auth_resp = generate_response_value(js->user, |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
962 | purple_connection_get_password(js->gc), nonce, cnonce, a2, realm); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
963 | g_free(a2); |
| 7291 | 964 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
965 | a2 = g_strdup_printf(":xmpp/%s", realm); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
966 | js->expected_rspauth = generate_response_value(js->user, |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
967 | purple_connection_get_password(js->gc), nonce, cnonce, a2, realm); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
968 | g_free(a2); |
| 7291 | 969 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
970 | g_string_append_printf(response, "username=\"%s\"", js->user->node); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
971 | g_string_append_printf(response, ",realm=\"%s\"", realm); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
972 | g_string_append_printf(response, ",nonce=\"%s\"", nonce); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
973 | g_string_append_printf(response, ",cnonce=\"%s\"", cnonce); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
974 | g_string_append_printf(response, ",nc=00000001"); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
975 | g_string_append_printf(response, ",qop=auth"); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
976 | g_string_append_printf(response, ",digest-uri=\"xmpp/%s\"", realm); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
977 | g_string_append_printf(response, ",response=%s", auth_resp); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
978 | g_string_append_printf(response, ",charset=utf-8"); |
| 7291 | 979 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
980 | g_free(auth_resp); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
981 | g_free(cnonce); |
| 7291 | 982 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
983 | enc_out = purple_base64_encode((guchar *)response->str, response->len); |
| 7291 | 984 | |
|
22622
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22329
diff
changeset
|
985 | purple_debug_misc("jabber", "decoded response (%" |
|
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22329
diff
changeset
|
986 | G_GSIZE_FORMAT "): %s\n", |
|
1ecb840b5101
Fix a bunch of compiler warnings caused by my addition of G_GNUC_PRINTF()
Mark Doliner <markdoliner@pidgin.im>
parents:
22329
diff
changeset
|
987 | response->len, response->str); |
| 7291 | 988 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
989 | buf = g_strdup_printf("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>%s</response>", enc_out); |
| 7291 | 990 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
991 | jabber_send_raw(js, buf, -1); |
| 7291 | 992 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
993 | g_free(buf); |
| 7291 | 994 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
995 | g_free(enc_out); |
| 7291 | 996 | |
|
17270
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
997 | g_string_free(response, TRUE); |
|
a995cb90663a
Added more robust parsing of the xmpp digest challenge and add validation that some required challenge fields are present. Fixes #1024
Daniel Atallah <datallah@pidgin.im>
parents:
17070
diff
changeset
|
998 | } |
| 7014 | 999 | } |
| 7291 | 1000 | |
| 1001 | g_free(enc_in); | |
| 1002 | g_free(dec_in); | |
| 1003 | g_hash_table_destroy(parts); | |
| 7014 | 1004 | } |
| 12508 | 1005 | #ifdef HAVE_CYRUS_SASL |
| 1006 | else if (js->auth_type == JABBER_AUTH_CYRUS) { | |
| 1007 | char *enc_in = xmlnode_get_data(packet); | |
| 1008 | unsigned char *dec_in; | |
| 1009 | char *enc_out; | |
| 1010 | const char *c_out; | |
| 12543 | 1011 | unsigned int clen; |
| 1012 | gsize declen; | |
| 12508 | 1013 | xmlnode *response; |
| 1014 | ||
| 15884 | 1015 | dec_in = purple_base64_decode(enc_in, &declen); |
| 12508 | 1016 | |
| 1017 | js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen, | |
| 1018 | NULL, &c_out, &clen); | |
| 15170 | 1019 | g_free(enc_in); |
| 12508 | 1020 | g_free(dec_in); |
| 1021 | if (js->sasl_state != SASL_CONTINUE && js->sasl_state != SASL_OK) { | |
| 15884 | 1022 | purple_debug_error("jabber", "Error is %d : %s\n",js->sasl_state,sasl_errdetail(js->sasl)); |
| 21279 | 1023 | purple_connection_error_reason (js->gc, |
| 1024 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
1025 | _("SASL error")); |
| 12508 | 1026 | return; |
| 1027 | } else { | |
| 1028 | response = xmlnode_new("response"); | |
| 13808 | 1029 | xmlnode_set_namespace(response, "urn:ietf:params:xml:ns:xmpp-sasl"); |
|
16724
724e0f6df95d
Don't try to base64 encode and then append an empty string
Mark Doliner <markdoliner@pidgin.im>
parents:
16564
diff
changeset
|
1030 | if (clen > 0) { |
| 15884 | 1031 | enc_out = purple_base64_encode((unsigned char*)c_out, clen); |
| 12508 | 1032 | xmlnode_insert_data(response, enc_out, -1); |
| 1033 | g_free(enc_out); | |
| 1034 | } | |
| 1035 | jabber_send(js, response); | |
| 1036 | xmlnode_free(response); | |
| 1037 | } | |
| 1038 | } | |
| 1039 | #endif | |
| 7014 | 1040 | } |
| 1041 | ||
| 1042 | void jabber_auth_handle_success(JabberStream *js, xmlnode *packet) | |
| 1043 | { | |
| 13808 | 1044 | const char *ns = xmlnode_get_namespace(packet); |
| 12508 | 1045 | #ifdef HAVE_CYRUS_SASL |
|
16395
f6df845a2956
Get rid of two really minor warnings
Mark Doliner <markdoliner@pidgin.im>
parents:
16180
diff
changeset
|
1046 | const void *x; |
| 12508 | 1047 | #endif |
| 7014 | 1048 | |
| 1049 | if(!ns || strcmp(ns, "urn:ietf:params:xml:ns:xmpp-sasl")) { | |
| 21279 | 1050 | purple_connection_error_reason (js->gc, |
| 1051 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
1052 | _("Invalid response from server.")); |
| 7014 | 1053 | return; |
| 1054 | } | |
| 1055 | ||
|
12520
3ec49915efd8
[gaim-migrate @ 14832]
Richard Laager <rlaager@pidgin.im>
parents:
12508
diff
changeset
|
1056 | #ifdef HAVE_CYRUS_SASL |
| 12508 | 1057 | /* The SASL docs say that if the client hasn't returned OK yet, we |
| 1058 | * should try one more round against it | |
| 1059 | */ | |
| 1060 | if (js->sasl_state != SASL_OK) { | |
| 15170 | 1061 | char *enc_in = xmlnode_get_data(packet); |
| 1062 | unsigned char *dec_in = NULL; | |
|
15112
cf00caa09ed4
[gaim-migrate @ 17834]
Mark Doliner <markdoliner@pidgin.im>
parents:
14660
diff
changeset
|
1063 | const char *c_out; |
|
cf00caa09ed4
[gaim-migrate @ 17834]
Mark Doliner <markdoliner@pidgin.im>
parents:
14660
diff
changeset
|
1064 | unsigned int clen; |
| 15170 | 1065 | gsize declen = 0; |
| 1066 | ||
| 1067 | if(enc_in != NULL) | |
| 15884 | 1068 | dec_in = purple_base64_decode(enc_in, &declen); |
| 15170 | 1069 | |
| 1070 | js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen, NULL, &c_out, &clen); | |
| 1071 | ||
| 1072 | g_free(enc_in); | |
| 1073 | g_free(dec_in); | |
| 1074 | ||
| 12508 | 1075 | if (js->sasl_state != SASL_OK) { |
| 1076 | /* This should never happen! */ | |
| 21279 | 1077 | purple_connection_error_reason (js->gc, |
| 1078 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
1079 | _("Invalid response from server.")); |
| 12508 | 1080 | } |
| 1081 | } | |
| 1082 | /* If we've negotiated a security layer, we need to enable it */ | |
|
22068
5157ec7a2b6f
Ensure js->sasl is not NULL before using it in jabber_auth_handle_success(). This was, I believe, the source of the crash stu reported when my DIGEST-MD5 hack was in place; while js->sasl will probably be non-NULL whenever we reach this code point now, it's more robust to verify it here since that's an assumption originating in another function.
Evan Schoenberg <evands@pidgin.im>
parents:
22057
diff
changeset
|
1083 | if (js->sasl) { |
|
5157ec7a2b6f
Ensure js->sasl is not NULL before using it in jabber_auth_handle_success(). This was, I believe, the source of the crash stu reported when my DIGEST-MD5 hack was in place; while js->sasl will probably be non-NULL whenever we reach this code point now, it's more robust to verify it here since that's an assumption originating in another function.
Evan Schoenberg <evands@pidgin.im>
parents:
22057
diff
changeset
|
1084 | sasl_getprop(js->sasl, SASL_SSF, &x); |
|
5157ec7a2b6f
Ensure js->sasl is not NULL before using it in jabber_auth_handle_success(). This was, I believe, the source of the crash stu reported when my DIGEST-MD5 hack was in place; while js->sasl will probably be non-NULL whenever we reach this code point now, it's more robust to verify it here since that's an assumption originating in another function.
Evan Schoenberg <evands@pidgin.im>
parents:
22057
diff
changeset
|
1085 | if (*(int *)x > 0) { |
|
5157ec7a2b6f
Ensure js->sasl is not NULL before using it in jabber_auth_handle_success(). This was, I believe, the source of the crash stu reported when my DIGEST-MD5 hack was in place; while js->sasl will probably be non-NULL whenever we reach this code point now, it's more robust to verify it here since that's an assumption originating in another function.
Evan Schoenberg <evands@pidgin.im>
parents:
22057
diff
changeset
|
1086 | sasl_getprop(js->sasl, SASL_MAXOUTBUF, &x); |
|
5157ec7a2b6f
Ensure js->sasl is not NULL before using it in jabber_auth_handle_success(). This was, I believe, the source of the crash stu reported when my DIGEST-MD5 hack was in place; while js->sasl will probably be non-NULL whenever we reach this code point now, it's more robust to verify it here since that's an assumption originating in another function.
Evan Schoenberg <evands@pidgin.im>
parents:
22057
diff
changeset
|
1087 | js->sasl_maxbuf = *(int *)x; |
|
5157ec7a2b6f
Ensure js->sasl is not NULL before using it in jabber_auth_handle_success(). This was, I believe, the source of the crash stu reported when my DIGEST-MD5 hack was in place; while js->sasl will probably be non-NULL whenever we reach this code point now, it's more robust to verify it here since that's an assumption originating in another function.
Evan Schoenberg <evands@pidgin.im>
parents:
22057
diff
changeset
|
1088 | } |
| 12508 | 1089 | } |
| 1090 | #endif | |
| 1091 | ||
| 7014 | 1092 | jabber_stream_set_state(js, JABBER_STREAM_REINITIALIZING); |
| 1093 | } | |
| 1094 | ||
| 1095 | void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet) | |
| 1096 | { | |
| 21279 | 1097 | PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
|
22800
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1098 | char *msg; |
| 7014 | 1099 | |
|
22800
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1100 | #ifdef HAVE_CYRUS_SASL |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1101 | if(js->auth_fail_count++ < 5) { |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1102 | if (js->current_mech && strlen(js->current_mech) > 0) { |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1103 | char *pos; |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1104 | if ((pos = strstr(js->sasl_mechs->str, js->current_mech))) { |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1105 | g_string_erase(js->sasl_mechs, pos-js->sasl_mechs->str, strlen(js->current_mech)); |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1106 | } |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1107 | } |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1108 | |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1109 | sasl_dispose(&js->sasl); |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1110 | |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1111 | jabber_auth_start_cyrus(js); |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1112 | return; |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1113 | } |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1114 | #endif |
|
0288a22eb85a
The next version of RFC 3920, the draft of which can be found at http://www.xmpp.org/internet-drafts/draft-saintandre-rfc3920bis-04.html, and subsequent email clarifications with Peter Saint-Andre and Alexey Melnikov indicate that we should be trying the next mechanism in line after one mechanism fails. We should also be ensuring that the mech list is sorted in order of descending security, which we don't do yet; however, servers are supposed to send us a sorted list, as well, so this isn't a major issue.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22667
diff
changeset
|
1115 | msg = jabber_parse_error(js, packet, &reason); |
| 8401 | 1116 | if(!msg) { |
| 21279 | 1117 | purple_connection_error_reason (js->gc, |
| 1118 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
20445
c900767c024b
Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents:
19993
diff
changeset
|
1119 | _("Invalid response from server.")); |
| 8401 | 1120 | } else { |
|
21150
bedd1215fb5e
Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents:
20882
diff
changeset
|
1121 | purple_connection_error_reason (js->gc, reason, msg); |
| 8401 | 1122 | g_free(msg); |
| 7014 | 1123 | } |
| 1124 | } |