Sun, 12 Aug 2007 02:11:05 +0000
Use -1 as length with g_convert() functions instead of strlen()
| 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 | |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 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" |
|
c087855dc551
Re-arrange #includes so 'make check' stands a chance of passing during
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
26 | #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
|
27 | #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
|
28 | #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
|
29 | #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
|
30 | #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
|
31 | |
| 7014 | 32 | #include "jutil.h" |
| 33 | #include "auth.h" | |
| 34 | #include "jabber.h" | |
| 35 | #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
|
36 | #include "notify.h" |
| 7014 | 37 | |
| 8397 | 38 | static void auth_old_result_cb(JabberStream *js, xmlnode *packet, |
| 39 | gpointer data); | |
| 7014 | 40 | |
| 8296 | 41 | gboolean |
| 42 | jabber_process_starttls(JabberStream *js, xmlnode *packet) | |
| 7014 | 43 | { |
| 44 | xmlnode *starttls; | |
| 45 | ||
| 7157 | 46 | if((starttls = xmlnode_get_child(packet, "starttls"))) { |
| 15884 | 47 | if(purple_ssl_is_supported()) { |
| 7157 | 48 | jabber_send_raw(js, |
| 7642 | 49 | "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>", -1); |
| 8296 | 50 | return TRUE; |
| 7157 | 51 | } else if(xmlnode_get_child(starttls, "required")) { |
| 15884 | 52 | purple_connection_error(js->gc, _("Server requires TLS/SSL for login. No TLS/SSL support found.")); |
| 8296 | 53 | return TRUE; |
| 7157 | 54 | } |
| 7014 | 55 | } |
| 56 | ||
| 8296 | 57 | return FALSE; |
| 58 | } | |
| 59 | ||
| 8397 | 60 | static void finish_plaintext_authentication(JabberStream *js) |
| 61 | { | |
| 62 | if(js->auth_type == JABBER_AUTH_PLAIN) { | |
| 63 | xmlnode *auth; | |
| 64 | GString *response; | |
|
11127
5e539d9d26a4
[gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
65 | gchar *enc_out; |
| 8397 | 66 | |
| 67 | auth = xmlnode_new("auth"); | |
| 13808 | 68 | xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl"); |
|
17185
aee12ae11898
disapproval of revision '19aafbb84554440d2958772085c5f77498589904'
Daniel Atallah <datallah@pidgin.im>
parents:
17184
diff
changeset
|
69 | |
| 15271 | 70 | xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth"); |
| 15293 | 71 | xmlnode_set_attrib(auth, "ga:client-uses-full-bind-result", "true"); |
|
17185
aee12ae11898
disapproval of revision '19aafbb84554440d2958772085c5f77498589904'
Daniel Atallah <datallah@pidgin.im>
parents:
17184
diff
changeset
|
72 | |
| 8397 | 73 | response = g_string_new(""); |
| 74 | response = g_string_append_len(response, "\0", 1); | |
| 75 | response = g_string_append(response, js->user->node); | |
| 76 | response = g_string_append_len(response, "\0", 1); | |
| 77 | response = g_string_append(response, | |
| 15884 | 78 | purple_connection_get_password(js->gc)); |
| 8397 | 79 | |
| 15884 | 80 | enc_out = purple_base64_encode((guchar *)response->str, response->len); |
| 8397 | 81 | |
| 82 | xmlnode_set_attrib(auth, "mechanism", "PLAIN"); | |
| 83 | xmlnode_insert_data(auth, enc_out, -1); | |
| 84 | g_free(enc_out); | |
| 85 | g_string_free(response, TRUE); | |
| 86 | ||
| 87 | jabber_send(js, auth); | |
| 88 | xmlnode_free(auth); | |
| 89 | } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) { | |
| 90 | JabberIq *iq; | |
| 91 | xmlnode *query, *x; | |
| 92 | ||
| 93 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); | |
| 94 | query = xmlnode_get_child(iq->node, "query"); | |
| 95 | x = xmlnode_new_child(query, "username"); | |
| 96 | xmlnode_insert_data(x, js->user->node, -1); | |
| 97 | x = xmlnode_new_child(query, "resource"); | |
| 98 | xmlnode_insert_data(x, js->user->resource, -1); | |
| 99 | x = xmlnode_new_child(query, "password"); | |
| 15884 | 100 | xmlnode_insert_data(x, purple_connection_get_password(js->gc), -1); |
| 8397 | 101 | jabber_iq_set_callback(iq, auth_old_result_cb, NULL); |
| 102 | jabber_iq_send(iq); | |
| 103 | } | |
| 104 | } | |
| 105 | ||
| 15884 | 106 | static void allow_plaintext_auth(PurpleAccount *account) |
| 8397 | 107 | { |
| 15884 | 108 | purple_account_set_bool(account, "auth_plain_in_clear", TRUE); |
| 8397 | 109 | |
| 110 | finish_plaintext_authentication(account->gc->proto_data); | |
| 111 | } | |
| 112 | ||
| 15884 | 113 | static void disallow_plaintext_auth(PurpleAccount *account) |
| 8397 | 114 | { |
| 15884 | 115 | purple_connection_error(account->gc, _("Server requires plaintext authentication over an unencrypted stream")); |
| 8397 | 116 | } |
| 117 | ||
| 12508 | 118 | #ifdef HAVE_CYRUS_SASL |
| 119 | ||
| 120 | 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
|
121 | static void jabber_sasl_build_callbacks(JabberStream *); |
| 12508 | 122 | |
| 123 | /* Callbacks for Cyrus SASL */ | |
| 124 | ||
| 125 | static int jabber_sasl_cb_realm(void *ctx, int id, const char **avail, const char **result) | |
| 126 | { | |
| 127 | JabberStream *js = (JabberStream *)ctx; | |
| 128 | ||
| 129 | if (id != SASL_CB_GETREALM || !result) return SASL_BADPARAM; | |
| 130 | ||
| 131 | *result = js->user->domain; | |
| 132 | ||
| 133 | return SASL_OK; | |
| 134 | } | |
| 135 | ||
| 136 | static int jabber_sasl_cb_simple(void *ctx, int id, const char **res, unsigned *len) | |
| 137 | { | |
| 138 | JabberStream *js = (JabberStream *)ctx; | |
| 139 | ||
| 140 | switch(id) { | |
| 141 | case SASL_CB_AUTHNAME: | |
| 142 | *res = js->user->node; | |
| 143 | break; | |
| 144 | case SASL_CB_USER: | |
| 12543 | 145 | *res = ""; |
| 12508 | 146 | break; |
| 147 | default: | |
| 148 | return SASL_BADPARAM; | |
| 149 | } | |
| 150 | if (len) *len = strlen((char *)*res); | |
| 151 | return SASL_OK; | |
| 152 | } | |
| 153 | ||
| 154 | static int jabber_sasl_cb_secret(sasl_conn_t *conn, void *ctx, int id, sasl_secret_t **secret) | |
| 155 | { | |
| 156 | JabberStream *js = (JabberStream *)ctx; | |
| 15884 | 157 | const char *pw = purple_account_get_password(js->gc->account); |
| 12508 | 158 | size_t len; |
| 159 | static sasl_secret_t *x = NULL; | |
| 160 | ||
| 161 | if (!conn || !secret || id != SASL_CB_PASS) | |
| 162 | return SASL_BADPARAM; | |
| 163 | ||
| 164 | len = strlen(pw); | |
| 165 | x = (sasl_secret_t *) realloc(x, sizeof(sasl_secret_t) + len); | |
| 166 | ||
| 167 | if (!x) | |
| 168 | return SASL_NOMEM; | |
| 169 | ||
| 170 | x->len = len; | |
| 171 | strcpy((char*)x->data, pw); | |
| 172 | ||
| 173 | *secret = x; | |
| 174 | return SASL_OK; | |
| 175 | } | |
| 176 | ||
| 15884 | 177 | static void allow_cyrus_plaintext_auth(PurpleAccount *account) |
| 12508 | 178 | { |
| 15884 | 179 | purple_account_set_bool(account, "auth_plain_in_clear", TRUE); |
| 12508 | 180 | |
| 181 | jabber_auth_start_cyrus(account->gc->proto_data); | |
| 182 | } | |
| 183 | ||
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
184 | 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
|
185 | { |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
186 | const char *entry; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
187 | gboolean remember; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
188 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
189 | 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
|
190 | 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
|
191 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
192 | if (!entry || !*entry) |
|
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 | 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
|
195 | return FALSE; |
|
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 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
198 | if (remember) |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
199 | 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
|
200 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
201 | 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
|
202 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
203 | return TRUE; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
204 | } |
|
17185
aee12ae11898
disapproval of revision '19aafbb84554440d2958772085c5f77498589904'
Daniel Atallah <datallah@pidgin.im>
parents:
17184
diff
changeset
|
205 | |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
206 | static void auth_pass_cb(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
|
207 | { |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
208 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
209 | 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
|
210 | return; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
211 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
212 | /* 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
|
213 | 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
|
214 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
215 | /* Restart our connection */ |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
216 | 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
|
217 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
218 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
219 | static void |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
220 | auth_old_pass_cb(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
|
221 | { |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
222 | 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
|
223 | return; |
|
17185
aee12ae11898
disapproval of revision '19aafbb84554440d2958772085c5f77498589904'
Daniel Atallah <datallah@pidgin.im>
parents:
17184
diff
changeset
|
224 | |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
225 | /* Restart our connection */ |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
226 | 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
|
227 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
228 | |
|
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 | static void |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
231 | auth_no_pass_cb(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
|
232 | { |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
233 | purple_connection_error(js->gc, _("Password is required to sign on.")); |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
234 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
235 | |
| 12508 | 236 | static void jabber_auth_start_cyrus(JabberStream *js) |
| 237 | { | |
|
14232
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
238 | const char *clientout = NULL, *mech = NULL; |
| 12508 | 239 | char *enc_out; |
|
14232
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
240 | unsigned coutlen = 0; |
| 12508 | 241 | xmlnode *auth; |
| 242 | sasl_security_properties_t secprops; | |
| 243 | gboolean again; | |
| 244 | gboolean plaintext = TRUE; | |
| 245 | ||
| 246 | /* Set up security properties and options */ | |
| 247 | secprops.min_ssf = 0; | |
| 248 | secprops.security_flags = SASL_SEC_NOANONYMOUS; | |
| 249 | ||
| 250 | if (!js->gsc) { | |
| 13207 | 251 | secprops.max_ssf = -1; |
| 252 | secprops.maxbufsize = 4096; | |
| 15884 | 253 | plaintext = purple_account_get_bool(js->gc->account, "auth_plain_in_clear", FALSE); |
| 12508 | 254 | if (!plaintext) |
| 255 | secprops.security_flags |= SASL_SEC_NOPLAINTEXT; | |
| 256 | } else { | |
| 13207 | 257 | secprops.max_ssf = 0; |
| 258 | secprops.maxbufsize = 0; | |
| 12540 | 259 | plaintext = TRUE; |
| 12508 | 260 | } |
| 261 | secprops.property_names = 0; | |
| 262 | secprops.property_values = 0; | |
| 263 | ||
| 264 | do { | |
| 265 | again = FALSE; | |
| 266 | ||
|
15800
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15435
diff
changeset
|
267 | js->sasl_state = sasl_client_new("xmpp", js->serverFQDN, NULL, NULL, js->sasl_cb, 0, &js->sasl); |
| 12508 | 268 | if (js->sasl_state==SASL_OK) { |
| 269 | sasl_setprop(js->sasl, SASL_SEC_PROPS, &secprops); | |
| 15884 | 270 | purple_debug_info("sasl", "Mechs found: %s\n", js->sasl_mechs->str); |
| 12508 | 271 | js->sasl_state = sasl_client_start(js->sasl, js->sasl_mechs->str, NULL, &clientout, &coutlen, &mech); |
| 272 | } | |
| 273 | switch (js->sasl_state) { | |
| 274 | /* Success */ | |
| 12543 | 275 | case SASL_OK: |
| 12508 | 276 | case SASL_CONTINUE: |
| 277 | break; | |
| 278 | 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
|
279 | /* 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
|
280 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
281 | /* 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
|
282 | * to get one |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
283 | */ |
| 12508 | 284 | |
| 15884 | 285 | if (!purple_account_get_password(js->gc->account)) { |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
286 | purple_account_request_password(js->gc->account, G_CALLBACK(auth_pass_cb), G_CALLBACK(auth_no_pass_cb), js); |
| 12508 | 287 | return; |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
288 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
289 | /* 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
|
290 | * 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
|
291 | * plaintext auth |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
292 | */ |
| 12508 | 293 | } else if (!plaintext) { |
| 17050 | 294 | 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
|
295 | js->gc->account->username); |
| 15884 | 296 | purple_request_yes_no(js->gc, _("Plaintext Authentication"), |
| 12508 | 297 | _("Plaintext Authentication"), |
| 17050 | 298 | msg, |
|
19223
786ca9a60e85
Fix null pointer deref when confirming authentication over unencrypted connection. Fixes #2493.
Daniel Atallah <datallah@pidgin.im>
parents:
17272
diff
changeset
|
299 | 2, js->gc->account, NULL, NULL, js->gc->account, |
| 12508 | 300 | allow_cyrus_plaintext_auth, |
| 301 | disallow_plaintext_auth); | |
| 17050 | 302 | g_free(msg); |
| 12508 | 303 | return; |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
304 | /* Everything else has failed, so fail the |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
305 | * connection. Should probably have a better |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
306 | * error here. |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
307 | */ |
| 12508 | 308 | } else { |
| 15884 | 309 | purple_connection_error(js->gc, _("Server does not use any supported authentication method")); |
| 12508 | 310 | return; |
| 311 | } | |
| 312 | /* not reached */ | |
| 313 | break; | |
| 314 | ||
| 315 | /* Fatal errors. Give up and go home */ | |
| 316 | case SASL_BADPARAM: | |
| 317 | case SASL_NOMEM: | |
| 318 | break; | |
| 319 | ||
| 320 | /* For everything else, fail the mechanism and try again */ | |
| 321 | default: | |
| 15884 | 322 | 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
|
323 | |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
324 | /* |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
325 | * DAA: is this right? |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
326 | * 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
|
327 | * 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
|
328 | * I suspect that this never happens. |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
329 | */ |
|
15800
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15435
diff
changeset
|
330 | /* |
|
2d0ec4fe2681
pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents:
15435
diff
changeset
|
331 | * 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
|
332 | * 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
|
333 | * 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
|
334 | * 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
|
335 | */ |
|
14232
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
336 | if (mech && strlen(mech) > 0) { |
| 12508 | 337 | char *pos; |
|
14237
e5ce1ba029f9
[gaim-migrate @ 16825]
Daniel Atallah <datallah@pidgin.im>
parents:
14232
diff
changeset
|
338 | if ((pos = strstr(js->sasl_mechs->str, mech))) { |
|
14232
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
339 | g_string_erase(js->sasl_mechs, pos-js->sasl_mechs->str, strlen(mech)); |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
340 | } |
|
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
341 | again = TRUE; |
| 12508 | 342 | } |
|
14232
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
343 | |
| 12508 | 344 | sasl_dispose(&js->sasl); |
| 345 | } | |
| 346 | } while (again); | |
| 347 | ||
| 12543 | 348 | if (js->sasl_state == SASL_CONTINUE || js->sasl_state == SASL_OK) { |
| 12508 | 349 | auth = xmlnode_new("auth"); |
| 13808 | 350 | xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl"); |
|
14232
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
351 | xmlnode_set_attrib(auth, "mechanism", mech); |
| 12508 | 352 | if (clientout) { |
| 353 | if (coutlen == 0) { | |
| 354 | xmlnode_insert_data(auth, "=", -1); | |
| 355 | } else { | |
| 15884 | 356 | enc_out = purple_base64_encode((unsigned char*)clientout, coutlen); |
| 12508 | 357 | xmlnode_insert_data(auth, enc_out, -1); |
| 358 | g_free(enc_out); | |
| 359 | } | |
| 360 | } | |
| 361 | jabber_send(js, auth); | |
| 362 | xmlnode_free(auth); | |
| 363 | } else { | |
| 15884 | 364 | purple_connection_error(js->gc, "SASL authentication failed\n"); |
| 12508 | 365 | } |
| 366 | } | |
| 367 | ||
| 12543 | 368 | static int |
| 369 | jabber_sasl_cb_log(void *context, int level, const char *message) | |
| 370 | { | |
| 371 | if(level <= SASL_LOG_TRACE) | |
| 15884 | 372 | purple_debug_info("sasl", "%s\n", message); |
| 12543 | 373 | |
| 374 | return SASL_OK; | |
| 375 | } | |
| 376 | ||
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
377 | void |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
378 | 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
|
379 | { |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
380 | int id; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
381 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
382 | /* 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
|
383 | 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
|
384 | 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
|
385 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
386 | id = 0; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
387 | 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
|
388 | 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
|
389 | 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
|
390 | id++; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
391 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
392 | 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
|
393 | 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
|
394 | 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
|
395 | id++; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
396 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
397 | 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
|
398 | 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
|
399 | 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
|
400 | id++; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
401 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
402 | 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
|
403 | 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
|
404 | 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
|
405 | 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
|
406 | id++; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
407 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
408 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
409 | 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
|
410 | 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
|
411 | 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
|
412 | id++; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
413 | |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
414 | 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
|
415 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
416 | |
| 12508 | 417 | #endif |
| 418 | ||
| 8296 | 419 | void |
| 420 | jabber_auth_start(JabberStream *js, xmlnode *packet) | |
| 421 | { | |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
422 | #ifndef HAVE_CYRUS_SASL |
| 12508 | 423 | gboolean digest_md5 = FALSE, plain=FALSE; |
| 424 | #endif | |
| 8296 | 425 | |
| 12508 | 426 | xmlnode *mechs, *mechnode; |
| 8296 | 427 | |
| 428 | ||
| 8016 | 429 | if(js->registration) { |
| 430 | jabber_register_start(js); | |
| 431 | return; | |
| 432 | } | |
| 433 | ||
| 7014 | 434 | mechs = xmlnode_get_child(packet, "mechanisms"); |
| 435 | ||
| 436 | if(!mechs) { | |
| 15884 | 437 | purple_connection_error(js->gc, _("Invalid response from server.")); |
| 7014 | 438 | return; |
| 439 | } | |
| 440 | ||
| 12508 | 441 | #ifdef HAVE_CYRUS_SASL |
| 442 | js->sasl_mechs = g_string_new(""); | |
| 443 | #endif | |
| 444 | ||
| 8135 | 445 | for(mechnode = xmlnode_get_child(mechs, "mechanism"); mechnode; |
| 446 | mechnode = xmlnode_get_next_twin(mechnode)) | |
| 7014 | 447 | { |
| 8135 | 448 | char *mech_name = xmlnode_get_data(mechnode); |
| 12508 | 449 | #ifdef HAVE_CYRUS_SASL |
| 450 | g_string_append(js->sasl_mechs, mech_name); | |
|
14232
331b5d0a2fd4
[gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
451 | g_string_append_c(js->sasl_mechs, ' '); |
| 12508 | 452 | #else |
| 8135 | 453 | if(mech_name && !strcmp(mech_name, "DIGEST-MD5")) |
| 454 | digest_md5 = TRUE; | |
| 455 | else if(mech_name && !strcmp(mech_name, "PLAIN")) | |
| 456 | plain = TRUE; | |
| 12508 | 457 | #endif |
| 8135 | 458 | g_free(mech_name); |
| 7014 | 459 | } |
| 460 | ||
| 12508 | 461 | #ifdef HAVE_CYRUS_SASL |
| 462 | js->auth_type = JABBER_AUTH_CYRUS; | |
| 463 | ||
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
464 | jabber_sasl_build_callbacks(js); |
| 12508 | 465 | |
| 466 | jabber_auth_start_cyrus(js); | |
| 467 | #else | |
| 7703 | 468 | |
| 7645 | 469 | if(digest_md5) { |
| 8397 | 470 | xmlnode *auth; |
| 471 | ||
| 472 | js->auth_type = JABBER_AUTH_DIGEST_MD5; | |
| 473 | auth = xmlnode_new("auth"); | |
| 13808 | 474 | xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl"); |
| 7291 | 475 | xmlnode_set_attrib(auth, "mechanism", "DIGEST-MD5"); |
| 8397 | 476 | |
| 477 | jabber_send(js, auth); | |
| 478 | xmlnode_free(auth); | |
| 8086 | 479 | } else if(plain) { |
| 8397 | 480 | js->auth_type = JABBER_AUTH_PLAIN; |
| 7703 | 481 | |
| 15884 | 482 | if(js->gsc == NULL && !purple_account_get_bool(js->gc->account, "auth_plain_in_clear", FALSE)) { |
| 17050 | 483 | 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
|
484 | js->gc->account->username); |
| 15884 | 485 | purple_request_yes_no(js->gc, _("Plaintext Authentication"), |
| 8397 | 486 | _("Plaintext Authentication"), |
| 17050 | 487 | msg, |
|
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
|
488 | 2, |
|
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
|
489 | purple_connection_get_account(js->gc), NULL, NULL, |
|
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
|
490 | purple_connection_get_account(js->gc), allow_plaintext_auth, |
| 8397 | 491 | disallow_plaintext_auth); |
| 17050 | 492 | g_free(msg); |
| 8086 | 493 | return; |
| 494 | } | |
| 8397 | 495 | finish_plaintext_authentication(js); |
| 7014 | 496 | } else { |
| 15884 | 497 | purple_connection_error(js->gc, |
| 7014 | 498 | _("Server does not use any supported authentication method")); |
| 499 | } | |
| 12508 | 500 | #endif |
| 7014 | 501 | } |
| 502 | ||
| 7395 | 503 | static void auth_old_result_cb(JabberStream *js, xmlnode *packet, gpointer data) |
| 7014 | 504 | { |
| 505 | const char *type = xmlnode_get_attrib(packet, "type"); | |
| 506 | ||
| 7730 | 507 | if(type && !strcmp(type, "result")) { |
| 508 | jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
| 509 | } else { | |
| 8401 | 510 | char *msg = jabber_parse_error(js, packet); |
| 511 | xmlnode *error; | |
| 512 | const char *err_code; | |
| 7014 | 513 | |
| 8401 | 514 | if((error = xmlnode_get_child(packet, "error")) && |
| 515 | (err_code = xmlnode_get_attrib(error, "code")) && | |
| 516 | !strcmp(err_code, "401")) { | |
| 517 | js->gc->wants_to_die = TRUE; | |
| 7730 | 518 | } |
| 7014 | 519 | |
| 15884 | 520 | purple_connection_error(js->gc, msg); |
| 8401 | 521 | g_free(msg); |
| 7014 | 522 | } |
| 523 | } | |
| 524 | ||
| 7395 | 525 | static void auth_old_cb(JabberStream *js, xmlnode *packet, gpointer data) |
| 7014 | 526 | { |
| 527 | JabberIq *iq; | |
| 528 | xmlnode *query, *x; | |
| 7514 | 529 | const char *type = xmlnode_get_attrib(packet, "type"); |
| 15884 | 530 | const char *pw = purple_connection_get_password(js->gc); |
| 7014 | 531 | |
| 7514 | 532 | if(!type) { |
| 15884 | 533 | purple_connection_error(js->gc, _("Invalid response from server.")); |
| 7014 | 534 | return; |
| 7515 | 535 | } else if(!strcmp(type, "error")) { |
| 8401 | 536 | char *msg = jabber_parse_error(js, packet); |
| 15884 | 537 | purple_connection_error(js->gc, msg); |
| 8401 | 538 | g_free(msg); |
| 7515 | 539 | } else if(!strcmp(type, "result")) { |
| 7514 | 540 | query = xmlnode_get_child(packet, "query"); |
| 541 | if(js->stream_id && xmlnode_get_child(query, "digest")) { | |
| 542 | unsigned char hashval[20]; | |
| 543 | char *s, h[41], *p; | |
| 544 | int i; | |
| 7014 | 545 | |
| 8397 | 546 | iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth"); |
| 547 | query = xmlnode_get_child(iq->node, "query"); | |
| 548 | x = xmlnode_new_child(query, "username"); | |
| 549 | xmlnode_insert_data(x, js->user->node, -1); | |
| 550 | x = xmlnode_new_child(query, "resource"); | |
| 551 | xmlnode_insert_data(x, js->user->resource, -1); | |
| 552 | ||
| 7514 | 553 | x = xmlnode_new_child(query, "digest"); |
| 554 | s = g_strdup_printf("%s%s", js->stream_id, pw); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10496
diff
changeset
|
555 | |
| 15884 | 556 | purple_cipher_digest_region("sha1", (guchar *)s, strlen(s), |
| 10687 | 557 | sizeof(hashval), hashval, NULL); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10496
diff
changeset
|
558 | |
| 7514 | 559 | p = h; |
| 560 | for(i=0; i<20; i++, p+=2) | |
| 561 | snprintf(p, 3, "%02x", hashval[i]); | |
| 562 | xmlnode_insert_data(x, h, -1); | |
| 563 | g_free(s); | |
| 8397 | 564 | jabber_iq_set_callback(iq, auth_old_result_cb, NULL); |
| 565 | jabber_iq_send(iq); | |
| 566 | ||
| 567 | } else if(xmlnode_get_child(query, "password")) { | |
| 15884 | 568 | if(js->gsc == NULL && !purple_account_get_bool(js->gc->account, |
| 8397 | 569 | "auth_plain_in_clear", FALSE)) { |
| 15884 | 570 | purple_request_yes_no(js->gc, _("Plaintext Authentication"), |
| 8397 | 571 | _("Plaintext Authentication"), |
| 572 | _("This server requires plaintext authentication over an unencrypted connection. Allow this and continue authentication?"), | |
|
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
|
573 | 2, |
|
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
|
574 | purple_connection_get_account(js->gc), NULL, NULL, |
|
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
|
575 | purple_connection_get_account(js->gc), allow_plaintext_auth, |
| 8397 | 576 | disallow_plaintext_auth); |
| 577 | return; | |
| 578 | } | |
| 579 | finish_plaintext_authentication(js); | |
| 7514 | 580 | } else { |
| 15884 | 581 | purple_connection_error(js->gc, |
| 8397 | 582 | _("Server does not use any supported authentication method")); |
| 583 | return; | |
| 7514 | 584 | } |
| 7014 | 585 | } |
| 586 | } | |
| 587 | ||
| 588 | void jabber_auth_start_old(JabberStream *js) | |
| 589 | { | |
| 590 | JabberIq *iq; | |
| 591 | xmlnode *query, *username; | |
| 592 | ||
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
593 | #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
|
594 | /* 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
|
595 | * 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
|
596 | * password prompting here |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
597 | */ |
|
17185
aee12ae11898
disapproval of revision '19aafbb84554440d2958772085c5f77498589904'
Daniel Atallah <datallah@pidgin.im>
parents:
17184
diff
changeset
|
598 | |
|
16180
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
599 | if (!purple_account_get_password(js->gc->account)) { |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
600 | purple_account_request_password(js->gc->account, G_CALLBACK(auth_old_pass_cb), G_CALLBACK(auth_no_pass_cb), js); |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
601 | return; |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
602 | } |
|
82761882c366
patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents:
15952
diff
changeset
|
603 | #endif |
| 7014 | 604 | iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:auth"); |
| 605 | ||
| 606 | query = xmlnode_get_child(iq->node, "query"); | |
| 607 | username = xmlnode_new_child(query, "username"); | |
| 608 | xmlnode_insert_data(username, js->user->node, -1); | |
| 609 | ||
| 7395 | 610 | jabber_iq_set_callback(iq, auth_old_cb, NULL); |
| 7014 | 611 | |
| 612 | jabber_iq_send(iq); | |
| 613 | } | |
| 614 | ||
|
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
|
615 | /* Parts of this algorithm are inspired by stuff in libgsasl */ |
| 7014 | 616 | static GHashTable* parse_challenge(const char *challenge) |
| 617 | { | |
|
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
|
618 | const char *token_start, *val_start, *val_end, *cur; |
| 7014 | 619 | GHashTable *ret = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 620 | g_free, g_free); | |
| 621 | ||
|
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
|
622 | 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
|
623 | 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
|
624 | /* 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
|
625 | 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
|
626 | 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
|
627 | 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
|
628 | 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
|
629 | 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
|
630 | 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
|
631 | 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
|
632 | } |
|
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
|
633 | |
|
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
|
634 | /* 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
|
635 | 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
|
636 | 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
|
637 | 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
|
638 | |
|
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
|
639 | 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
|
640 | name = g_strndup(token_start, val_start - token_start); |
| 7014 | 641 | |
|
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
|
642 | 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
|
643 | 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
|
644 | 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
|
645 | || *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
|
646 | || *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
|
647 | 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
|
648 | |
|
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
|
649 | 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
|
650 | 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
|
651 | || *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
|
652 | || *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
|
653 | 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
|
654 | |
|
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
|
655 | 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
|
656 | 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
|
657 | } |
|
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
|
658 | |
|
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
|
659 | g_hash_table_replace(ret, name, value); |
| 7014 | 660 | } |
|
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
|
661 | |
|
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
|
662 | /* 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
|
663 | 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
|
664 | 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
|
665 | 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
|
666 | || *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
|
667 | 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
|
668 | } |
| 7014 | 669 | } |
| 670 | ||
| 671 | return ret; | |
| 672 | } | |
| 673 | ||
|
11163
7fe2cec8e9e6
[gaim-migrate @ 13264]
Mark Doliner <markdoliner@pidgin.im>
parents:
11137
diff
changeset
|
674 | static char * |
| 7014 | 675 | generate_response_value(JabberID *jid, const char *passwd, const char *nonce, |
| 7267 | 676 | const char *cnonce, const char *a2, const char *realm) |
| 7014 | 677 | { |
| 15884 | 678 | PurpleCipher *cipher; |
| 679 | PurpleCipherContext *context; | |
|
11137
cf40226ddff7
[gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents:
11127
diff
changeset
|
680 | guchar result[16]; |
| 10136 | 681 | size_t a1len; |
| 7014 | 682 | |
| 12549 | 683 | gchar *a1, *convnode=NULL, *convpasswd = NULL, *ha1, *ha2, *kd, *x, *z; |
| 7014 | 684 | |
|
19337
68471e68386a
Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <datallah@pidgin.im>
parents:
19223
diff
changeset
|
685 | if((convnode = g_convert(jid->node, -1, "iso-8859-1", "utf-8", |
| 10136 | 686 | NULL, NULL, NULL)) == NULL) { |
| 687 | convnode = g_strdup(jid->node); | |
| 688 | } | |
|
19337
68471e68386a
Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <datallah@pidgin.im>
parents:
19223
diff
changeset
|
689 | if(passwd && ((convpasswd = g_convert(passwd, -1, "iso-8859-1", |
| 12549 | 690 | "utf-8", NULL, NULL, NULL)) == NULL)) { |
| 10136 | 691 | convpasswd = g_strdup(passwd); |
| 692 | } | |
| 693 | ||
| 15884 | 694 | cipher = purple_ciphers_find_cipher("md5"); |
| 695 | context = purple_cipher_context_new(cipher, NULL); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10496
diff
changeset
|
696 | |
| 12549 | 697 | x = g_strdup_printf("%s:%s:%s", convnode, realm, convpasswd ? convpasswd : ""); |
| 15884 | 698 | purple_cipher_context_append(context, (const guchar *)x, strlen(x)); |
| 699 | purple_cipher_context_digest(context, sizeof(result), result, NULL); | |
| 7014 | 700 | |
| 10136 | 701 | a1 = g_strdup_printf("xxxxxxxxxxxxxxxx:%s:%s", nonce, cnonce); |
| 702 | a1len = strlen(a1); | |
| 703 | g_memmove(a1, result, 16); | |
| 7014 | 704 | |
| 15884 | 705 | purple_cipher_context_reset(context, NULL); |
| 706 | purple_cipher_context_append(context, (const guchar *)a1, a1len); | |
| 707 | purple_cipher_context_digest(context, sizeof(result), result, NULL); | |
| 7014 | 708 | |
| 15884 | 709 | ha1 = purple_base16_encode(result, 16); |
| 7014 | 710 | |
| 15884 | 711 | purple_cipher_context_reset(context, NULL); |
| 712 | purple_cipher_context_append(context, (const guchar *)a2, strlen(a2)); | |
| 713 | purple_cipher_context_digest(context, sizeof(result), result, NULL); | |
| 7014 | 714 | |
| 15884 | 715 | ha2 = purple_base16_encode(result, 16); |
| 7014 | 716 | |
| 717 | kd = g_strdup_printf("%s:%s:00000001:%s:auth:%s", ha1, nonce, cnonce, ha2); | |
| 718 | ||
| 15884 | 719 | purple_cipher_context_reset(context, NULL); |
| 720 | purple_cipher_context_append(context, (const guchar *)kd, strlen(kd)); | |
| 721 | purple_cipher_context_digest(context, sizeof(result), result, NULL); | |
| 722 | purple_cipher_context_destroy(context); | |
| 7014 | 723 | |
| 15884 | 724 | z = purple_base16_encode(result, 16); |
| 7014 | 725 | |
| 10136 | 726 | g_free(convnode); |
| 727 | g_free(convpasswd); | |
| 7014 | 728 | g_free(x); |
| 729 | g_free(a1); | |
| 730 | g_free(ha1); | |
| 731 | g_free(ha2); | |
| 732 | g_free(kd); | |
| 733 | ||
| 734 | return z; | |
| 735 | } | |
| 736 | ||
| 737 | void | |
| 738 | jabber_auth_handle_challenge(JabberStream *js, xmlnode *packet) | |
| 739 | { | |
| 740 | ||
| 7703 | 741 | if(js->auth_type == JABBER_AUTH_DIGEST_MD5) { |
| 7291 | 742 | char *enc_in = xmlnode_get_data(packet); |
| 743 | char *dec_in; | |
| 744 | char *enc_out; | |
| 745 | GHashTable *parts; | |
| 7014 | 746 | |
| 7395 | 747 | if(!enc_in) { |
| 15884 | 748 | purple_connection_error(js->gc, _("Invalid response from server.")); |
| 7395 | 749 | return; |
| 750 | } | |
| 751 | ||
| 15884 | 752 | dec_in = (char *)purple_base64_decode(enc_in, NULL); |
| 753 | purple_debug(PURPLE_DEBUG_MISC, "jabber", "decoded challenge (%d): %s\n", | |
| 7395 | 754 | strlen(dec_in), dec_in); |
| 7291 | 755 | |
| 756 | parts = parse_challenge(dec_in); | |
| 7014 | 757 | |
| 758 | ||
| 7291 | 759 | if (g_hash_table_lookup(parts, "rspauth")) { |
| 760 | char *rspauth = g_hash_table_lookup(parts, "rspauth"); | |
| 7014 | 761 | |
| 762 | ||
| 7291 | 763 | if(rspauth && js->expected_rspauth && |
| 764 | !strcmp(rspauth, js->expected_rspauth)) { | |
| 765 | jabber_send_raw(js, | |
| 7642 | 766 | "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />", |
| 767 | -1); | |
| 7291 | 768 | } else { |
| 15884 | 769 | purple_connection_error(js->gc, _("Invalid challenge from server")); |
| 7291 | 770 | } |
| 771 | g_free(js->expected_rspauth); | |
| 772 | } else { | |
| 773 | /* assemble a response, and send it */ | |
| 774 | /* see RFC 2831 */ | |
| 775 | char *realm; | |
| 776 | char *nonce; | |
| 7014 | 777 | |
|
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
|
778 | /* 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
|
779 | 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
|
780 | |
|
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 | 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
|
782 | |
| 7291 | 783 | /* we're actually supposed to prompt the user for a realm if |
| 784 | * the server doesn't send one, but that really complicates things, | |
| 785 | * so i'm not gonna worry about it until is poses a problem to | |
| 786 | * someone, or I get really bored */ | |
| 787 | realm = g_hash_table_lookup(parts, "realm"); | |
| 788 | if(!realm) | |
| 789 | realm = js->user->domain; | |
| 7014 | 790 | |
|
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
|
791 | if (nonce == NULL || realm == 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
|
792 | purple_connection_error(js->gc, _("Invalid challenge from server")); |
|
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 | 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
|
794 | 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
|
795 | 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
|
796 | 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
|
797 | 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
|
798 | char *cnonce; |
| 7014 | 799 | |
|
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
|
800 | 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
|
801 | g_random_int()); |
| 7291 | 802 | |
|
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
|
803 | 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
|
804 | 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
|
805 | 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
|
806 | g_free(a2); |
| 7291 | 807 | |
|
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
|
808 | 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
|
809 | 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
|
810 | 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
|
811 | g_free(a2); |
| 7291 | 812 | |
|
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
|
813 | 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
|
814 | 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
|
815 | 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
|
816 | 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
|
817 | 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
|
818 | 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
|
819 | 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
|
820 | 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
|
821 | g_string_append_printf(response, ",charset=utf-8"); |
| 7291 | 822 | |
|
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
|
823 | 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
|
824 | g_free(cnonce); |
| 7291 | 825 | |
|
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
|
826 | enc_out = purple_base64_encode((guchar *)response->str, response->len); |
| 7291 | 827 | |
|
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
|
828 | purple_debug(PURPLE_DEBUG_MISC, "jabber", "decoded response (%d): %s\n", response->len, response->str); |
| 7291 | 829 | |
|
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
|
830 | buf = g_strdup_printf("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>%s</response>", enc_out); |
| 7291 | 831 | |
|
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
|
832 | jabber_send_raw(js, buf, -1); |
| 7291 | 833 | |
|
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
|
834 | g_free(buf); |
| 7291 | 835 | |
|
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
|
836 | g_free(enc_out); |
| 7291 | 837 | |
|
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
|
838 | 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
|
839 | } |
| 7014 | 840 | } |
| 7291 | 841 | |
| 842 | g_free(enc_in); | |
| 843 | g_free(dec_in); | |
| 844 | g_hash_table_destroy(parts); | |
| 7014 | 845 | } |
| 12508 | 846 | #ifdef HAVE_CYRUS_SASL |
| 847 | else if (js->auth_type == JABBER_AUTH_CYRUS) { | |
| 848 | char *enc_in = xmlnode_get_data(packet); | |
| 849 | unsigned char *dec_in; | |
| 850 | char *enc_out; | |
| 851 | const char *c_out; | |
| 12543 | 852 | unsigned int clen; |
| 853 | gsize declen; | |
| 12508 | 854 | xmlnode *response; |
| 855 | ||
| 15884 | 856 | dec_in = purple_base64_decode(enc_in, &declen); |
| 12508 | 857 | |
| 858 | js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen, | |
| 859 | NULL, &c_out, &clen); | |
| 15170 | 860 | g_free(enc_in); |
| 12508 | 861 | g_free(dec_in); |
| 862 | if (js->sasl_state != SASL_CONTINUE && js->sasl_state != SASL_OK) { | |
| 15884 | 863 | purple_debug_error("jabber", "Error is %d : %s\n",js->sasl_state,sasl_errdetail(js->sasl)); |
| 864 | purple_connection_error(js->gc, _("SASL error")); | |
| 12508 | 865 | return; |
| 866 | } else { | |
| 867 | response = xmlnode_new("response"); | |
| 13808 | 868 | 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
|
869 | if (clen > 0) { |
| 15884 | 870 | enc_out = purple_base64_encode((unsigned char*)c_out, clen); |
| 12508 | 871 | xmlnode_insert_data(response, enc_out, -1); |
| 872 | g_free(enc_out); | |
| 873 | } | |
| 874 | jabber_send(js, response); | |
| 875 | xmlnode_free(response); | |
| 876 | } | |
| 877 | } | |
| 878 | #endif | |
| 7014 | 879 | } |
| 880 | ||
| 881 | void jabber_auth_handle_success(JabberStream *js, xmlnode *packet) | |
| 882 | { | |
| 13808 | 883 | const char *ns = xmlnode_get_namespace(packet); |
| 12508 | 884 | #ifdef HAVE_CYRUS_SASL |
|
16395
f6df845a2956
Get rid of two really minor warnings
Mark Doliner <markdoliner@pidgin.im>
parents:
16180
diff
changeset
|
885 | const void *x; |
| 12508 | 886 | #endif |
| 7014 | 887 | |
| 888 | if(!ns || strcmp(ns, "urn:ietf:params:xml:ns:xmpp-sasl")) { | |
| 15884 | 889 | purple_connection_error(js->gc, _("Invalid response from server.")); |
| 7014 | 890 | return; |
| 891 | } | |
| 892 | ||
|
12520
3ec49915efd8
[gaim-migrate @ 14832]
Richard Laager <rlaager@pidgin.im>
parents:
12508
diff
changeset
|
893 | #ifdef HAVE_CYRUS_SASL |
| 12508 | 894 | /* The SASL docs say that if the client hasn't returned OK yet, we |
| 895 | * should try one more round against it | |
| 896 | */ | |
| 897 | if (js->sasl_state != SASL_OK) { | |
| 15170 | 898 | char *enc_in = xmlnode_get_data(packet); |
| 899 | unsigned char *dec_in = NULL; | |
|
15112
cf00caa09ed4
[gaim-migrate @ 17834]
Mark Doliner <markdoliner@pidgin.im>
parents:
14660
diff
changeset
|
900 | const char *c_out; |
|
cf00caa09ed4
[gaim-migrate @ 17834]
Mark Doliner <markdoliner@pidgin.im>
parents:
14660
diff
changeset
|
901 | unsigned int clen; |
| 15170 | 902 | gsize declen = 0; |
| 903 | ||
| 904 | if(enc_in != NULL) | |
| 15884 | 905 | dec_in = purple_base64_decode(enc_in, &declen); |
| 15170 | 906 | |
| 907 | js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen, NULL, &c_out, &clen); | |
| 908 | ||
| 909 | g_free(enc_in); | |
| 910 | g_free(dec_in); | |
| 911 | ||
| 12508 | 912 | if (js->sasl_state != SASL_OK) { |
| 913 | /* This should never happen! */ | |
| 15884 | 914 | purple_connection_error(js->gc, _("Invalid response from server.")); |
| 12508 | 915 | } |
| 916 | } | |
| 917 | /* If we've negotiated a security layer, we need to enable it */ | |
|
15143
37451143f5c4
[gaim-migrate @ 17867]
Mark Doliner <markdoliner@pidgin.im>
parents:
15112
diff
changeset
|
918 | sasl_getprop(js->sasl, SASL_SSF, &x); |
|
16395
f6df845a2956
Get rid of two really minor warnings
Mark Doliner <markdoliner@pidgin.im>
parents:
16180
diff
changeset
|
919 | if (*(int *)x > 0) { |
|
15143
37451143f5c4
[gaim-migrate @ 17867]
Mark Doliner <markdoliner@pidgin.im>
parents:
15112
diff
changeset
|
920 | sasl_getprop(js->sasl, SASL_MAXOUTBUF, &x); |
|
16395
f6df845a2956
Get rid of two really minor warnings
Mark Doliner <markdoliner@pidgin.im>
parents:
16180
diff
changeset
|
921 | js->sasl_maxbuf = *(int *)x; |
| 12508 | 922 | } |
| 923 | #endif | |
| 924 | ||
| 7014 | 925 | jabber_stream_set_state(js, JABBER_STREAM_REINITIALIZING); |
| 926 | } | |
| 927 | ||
| 928 | void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet) | |
| 929 | { | |
| 8401 | 930 | char *msg = jabber_parse_error(js, packet); |
| 7014 | 931 | |
| 8401 | 932 | if(!msg) { |
| 15884 | 933 | purple_connection_error(js->gc, _("Invalid response from server.")); |
| 8401 | 934 | } else { |
| 15884 | 935 | purple_connection_error(js->gc, msg); |
| 8401 | 936 | g_free(msg); |
| 7014 | 937 | } |
| 938 | } |