libpurple/protocols/jabber/auth.c

Tue, 23 Jun 2009 06:45:21 +0000

author
Paul Aurich <darkrain42@pidgin.im>
date
Tue, 23 Jun 2009 06:45:21 +0000
changeset 27379
eb193d927190
parent 27261
4abec3f2e24f
child 27632
0da289638ff4
permissions
-rw-r--r--

Only append ,charset=utf-8 for DIGEST-MD5. This should fix comment 2 on Adium#12429.

7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /*
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
2 * purple - Jabber Protocol Plugin
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
9 * (at your option) any later version.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * GNU General Public License for more details.
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 *
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 */
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 #include "internal.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
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
26671
3970019332c8 Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <darkrain42@pidgin.im>
parents: 26669
diff changeset
33 #include "auth.h"
3970019332c8 Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <darkrain42@pidgin.im>
parents: 26669
diff changeset
34 #include "disco.h"
3970019332c8 Make the last one compile (add disco.h) and alphabetize.
Paul Aurich <darkrain42@pidgin.im>
parents: 26669
diff changeset
35 #include "jabber.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36 #include "jutil.h"
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 #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
38 #include "notify.h"
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
40 static void auth_old_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
41 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
42 xmlnode *packet, gpointer data);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
44 gboolean
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
45 jabber_process_starttls(JabberStream *js, xmlnode *packet)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 xmlnode *starttls;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48
7157
aad2cacc9238 [gaim-migrate @ 7724]
Nathan Walp <nwalp@pidgin.im>
parents: 7147
diff changeset
49 if((starttls = xmlnode_get_child(packet, "starttls"))) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
50 if(purple_ssl_is_supported()) {
7157
aad2cacc9238 [gaim-migrate @ 7724]
Nathan Walp <nwalp@pidgin.im>
parents: 7147
diff changeset
51 jabber_send_raw(js,
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
52 "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>", -1);
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
53 return TRUE;
7157
aad2cacc9238 [gaim-migrate @ 7724]
Nathan Walp <nwalp@pidgin.im>
parents: 7147
diff changeset
54 } else if(xmlnode_get_child(starttls, "required")) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
55 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
56 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
57 _("Server requires TLS/SSL for login. No TLS/SSL support found."));
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
58 return TRUE;
22948
431888a82777 When an XMPP account is set to require TLS, but libpurple doesn't have SSL
Daniel Atallah <datallah@pidgin.im>
parents: 22815
diff changeset
59 } else if(purple_account_get_bool(js->gc->account, "require_tls", FALSE)) {
431888a82777 When an XMPP account is set to require TLS, but libpurple doesn't have SSL
Daniel Atallah <datallah@pidgin.im>
parents: 22815
diff changeset
60 purple_connection_error_reason (js->gc,
431888a82777 When an XMPP account is set to require TLS, but libpurple doesn't have SSL
Daniel Atallah <datallah@pidgin.im>
parents: 22815
diff changeset
61 PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT,
431888a82777 When an XMPP account is set to require TLS, but libpurple doesn't have SSL
Daniel Atallah <datallah@pidgin.im>
parents: 22815
diff changeset
62 _("You require encryption, but no TLS/SSL support found."));
431888a82777 When an XMPP account is set to require TLS, but libpurple doesn't have SSL
Daniel Atallah <datallah@pidgin.im>
parents: 22815
diff changeset
63 return TRUE;
7157
aad2cacc9238 [gaim-migrate @ 7724]
Nathan Walp <nwalp@pidgin.im>
parents: 7147
diff changeset
64 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
65 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
66
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
67 return FALSE;
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
68 }
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
69
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
70 static void finish_plaintext_authentication(JabberStream *js)
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
71 {
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
72 if(js->auth_type == JABBER_AUTH_PLAIN) {
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
73 xmlnode *auth;
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
74 GString *response;
11127
5e539d9d26a4 [gaim-migrate @ 13183]
Mark Doliner <markdoliner@pidgin.im>
parents: 10740
diff changeset
75 gchar *enc_out;
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
76
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
77 auth = xmlnode_new("auth");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13207
diff changeset
78 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
79
15271
d0fe65427f76 [gaim-migrate @ 17999]
Sean Egan <seanegan@pidgin.im>
parents: 15170
diff changeset
80 xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth");
15293
6e1d6e29cd99 [gaim-migrate @ 18021]
Sean Egan <seanegan@pidgin.im>
parents: 15271
diff changeset
81 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
82
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
83 response = g_string_new("");
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
84 response = g_string_append_len(response, "\0", 1);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
85 response = g_string_append(response, js->user->node);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
86 response = g_string_append_len(response, "\0", 1);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
87 response = g_string_append(response,
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
88 purple_connection_get_password(js->gc));
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
89
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
90 enc_out = purple_base64_encode((guchar *)response->str, response->len);
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
91
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
92 xmlnode_set_attrib(auth, "mechanism", "PLAIN");
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
93 xmlnode_insert_data(auth, enc_out, -1);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
94 g_free(enc_out);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
95 g_string_free(response, TRUE);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
96
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
97 jabber_send(js, auth);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
98 xmlnode_free(auth);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
99 } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) {
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
100 JabberIq *iq;
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
101 xmlnode *query, *x;
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
102
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
103 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth");
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
104 query = xmlnode_get_child(iq->node, "query");
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
105 x = xmlnode_new_child(query, "username");
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
106 xmlnode_insert_data(x, js->user->node, -1);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
107 x = xmlnode_new_child(query, "resource");
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
108 xmlnode_insert_data(x, js->user->resource, -1);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
109 x = xmlnode_new_child(query, "password");
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
110 xmlnode_insert_data(x, purple_connection_get_password(js->gc), -1);
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
111 jabber_iq_set_callback(iq, auth_old_result_cb, NULL);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
112 jabber_iq_send(iq);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
113 }
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
114 }
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
115
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
116 static void allow_plaintext_auth(PurpleAccount *account)
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
117 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
118 purple_account_set_bool(account, "auth_plain_in_clear", TRUE);
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
119
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
120 finish_plaintext_authentication(account->gc->proto_data);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
121 }
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
122
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
123 static void disallow_plaintext_auth(PurpleAccount *account)
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
124 {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
125 purple_connection_error_reason (account->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
126 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
127 _("Server requires plaintext authentication over an unencrypted stream"));
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
128 }
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
129
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
130 #ifdef HAVE_CYRUS_SASL
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
131
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
132 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
133 static void jabber_sasl_build_callbacks(JabberStream *);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
134
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
135 /* Callbacks for Cyrus SASL */
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
136
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
137 static int jabber_sasl_cb_realm(void *ctx, int id, const char **avail, const char **result)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
138 {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
139 JabberStream *js = (JabberStream *)ctx;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
140
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
141 if (id != SASL_CB_GETREALM || !result) return SASL_BADPARAM;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
142
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
143 *result = js->user->domain;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
144
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
145 return SASL_OK;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
146 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
147
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
148 static int jabber_sasl_cb_simple(void *ctx, int id, const char **res, unsigned *len)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
149 {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
150 JabberStream *js = (JabberStream *)ctx;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
151
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
152 switch(id) {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
153 case SASL_CB_AUTHNAME:
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
154 *res = js->user->node;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
155 break;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
156 case SASL_CB_USER:
12543
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
157 *res = "";
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
158 break;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
159 default:
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
160 return SASL_BADPARAM;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
161 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
162 if (len) *len = strlen((char *)*res);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
163 return SASL_OK;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
164 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
165
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
166 static int jabber_sasl_cb_secret(sasl_conn_t *conn, void *ctx, int id, sasl_secret_t **secret)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
167 {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
168 JabberStream *js = (JabberStream *)ctx;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
169 const char *pw = purple_account_get_password(js->gc->account);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
170 size_t len;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
171 static sasl_secret_t *x = NULL;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
172
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
173 if (!conn || !secret || id != SASL_CB_PASS)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
174 return SASL_BADPARAM;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
175
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
176 len = strlen(pw);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
177 x = (sasl_secret_t *) realloc(x, sizeof(sasl_secret_t) + len);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
178
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
179 if (!x)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
180 return SASL_NOMEM;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
181
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
182 x->len = len;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
183 strcpy((char*)x->data, pw);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
184
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
185 *secret = x;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
186 return SASL_OK;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
187 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
188
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
189 static void allow_cyrus_plaintext_auth(PurpleAccount *account)
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
190 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
191 purple_account_set_bool(account, "auth_plain_in_clear", TRUE);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
192
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
193 jabber_auth_start_cyrus(account->gc->proto_data);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
194 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
195
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
196 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
197 {
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
198 const char *entry;
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
199 gboolean remember;
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 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
202 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
203
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
204 if (!entry || !*entry)
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_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
207 return FALSE;
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
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
210 if (remember)
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
211 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
212
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
213 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
214
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
215 return TRUE;
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
216 }
20093
04f3c1dcd2cf applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents: 19993
diff changeset
217
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
218 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
219 {
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
220 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
221
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
222 /* 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
223 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
224 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
225
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
226 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
227
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
228 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
229 return;
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 /* 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
232 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
233
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
234 /* Restart our connection */
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
235 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
236 }
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
237
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
238 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
239 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
240 {
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
241 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
242
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
243 /* 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
244 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
245 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
246
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
247 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
248
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
249 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
250 return;
20093
04f3c1dcd2cf applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents: 19993
diff changeset
251
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
252 /* Restart our connection */
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
253 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
254 }
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
255
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
256
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
257 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
258 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
259 {
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
260 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
261
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
262 /* 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
263 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
264 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
265
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
266 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
267
20093
04f3c1dcd2cf applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents: 19993
diff changeset
268 /* Disable the account as the user has canceled connecting */
04f3c1dcd2cf applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents: 19993
diff changeset
269 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
270 }
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
271
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
272 static void jabber_auth_start_cyrus(JabberStream *js)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
273 {
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
274 const char *clientout = NULL;
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
275 char *enc_out;
14232
331b5d0a2fd4 [gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
276 unsigned coutlen = 0;
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
277 xmlnode *auth;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
278 sasl_security_properties_t secprops;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
279 gboolean again;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
280 gboolean plaintext = TRUE;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
281
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
282 /* Set up security properties and options */
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
283 secprops.min_ssf = 0;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
284 secprops.security_flags = SASL_SEC_NOANONYMOUS;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
285
26533
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
286 if (!jabber_stream_is_ssl(js)) {
13207
46462c13cb1b [gaim-migrate @ 15569]
Nathan Walp <nwalp@pidgin.im>
parents: 12549
diff changeset
287 secprops.max_ssf = -1;
46462c13cb1b [gaim-migrate @ 15569]
Nathan Walp <nwalp@pidgin.im>
parents: 12549
diff changeset
288 secprops.maxbufsize = 4096;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
289 plaintext = purple_account_get_bool(js->gc->account, "auth_plain_in_clear", FALSE);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
290 if (!plaintext)
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
291 secprops.security_flags |= SASL_SEC_NOPLAINTEXT;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
292 } else {
13207
46462c13cb1b [gaim-migrate @ 15569]
Nathan Walp <nwalp@pidgin.im>
parents: 12549
diff changeset
293 secprops.max_ssf = 0;
46462c13cb1b [gaim-migrate @ 15569]
Nathan Walp <nwalp@pidgin.im>
parents: 12549
diff changeset
294 secprops.maxbufsize = 0;
12540
5efb9b4f2752 [gaim-migrate @ 14853]
Nathan Walp <nwalp@pidgin.im>
parents: 12520
diff changeset
295 plaintext = TRUE;
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
296 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
297 secprops.property_names = 0;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
298 secprops.property_values = 0;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
299
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
300 do {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
301 again = FALSE;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
302
15800
2d0ec4fe2681 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15435
diff changeset
303 js->sasl_state = sasl_client_new("xmpp", js->serverFQDN, NULL, NULL, js->sasl_cb, 0, &js->sasl);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
304 if (js->sasl_state==SASL_OK) {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
305 sasl_setprop(js->sasl, SASL_SEC_PROPS, &secprops);
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
306 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
307 js->sasl_state = sasl_client_start(js->sasl, js->sasl_mechs->str, NULL, &clientout, &coutlen, &js->current_mech);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
308 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
309 switch (js->sasl_state) {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
310 /* Success */
12543
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
311 case SASL_OK:
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
312 case SASL_CONTINUE:
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
313 break;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
314 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
315 /* 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
316
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
317 /* 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
318 * to get one
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
319 */
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
320
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
321 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
322 purple_account_request_password(js->gc->account, G_CALLBACK(auth_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
323 return;
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
324
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
325 /* 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
326 * 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
327 * plaintext auth
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
328 */
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
329 } else if (!plaintext) {
17050
a41a4e5820d0 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16724
diff changeset
330 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
331 js->gc->account->username);
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
332 purple_request_yes_no(js->gc, _("Plaintext Authentication"),
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
333 _("Plaintext Authentication"),
17050
a41a4e5820d0 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16724
diff changeset
334 msg,
22269
3fdf7b13f20a A few more of those "default_action" fixes
Mark Doliner <markdoliner@pidgin.im>
parents: 22068
diff changeset
335 1, js->gc->account, NULL, NULL, js->gc->account,
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
336 allow_cyrus_plaintext_auth,
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
337 disallow_plaintext_auth);
17050
a41a4e5820d0 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16724
diff changeset
338 g_free(msg);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
339 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
340
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
341 } 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
342 /* 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
343 * 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
344 * 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
345 * 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
346 * 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
347 * 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
348 *
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
349 * 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
350 * 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
351 * 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
352 * 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
353 */
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
354 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
355 jabber_auth_start_old(js);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
356 return;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
357 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
358 /* not reached */
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
359 break;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
360
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
361 /* Fatal errors. Give up and go home */
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
362 case SASL_BADPARAM:
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
363 case SASL_NOMEM:
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
364 break;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
365
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
366 /* For everything else, fail the mechanism and try again */
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
367 default:
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
368 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
369
331b5d0a2fd4 [gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
370 /*
331b5d0a2fd4 [gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
371 * DAA: is this right?
331b5d0a2fd4 [gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
372 * 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
373 * 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
374 * I suspect that this never happens.
331b5d0a2fd4 [gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
375 */
15800
2d0ec4fe2681 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15435
diff changeset
376 /*
2d0ec4fe2681 pass the correct domain to cyrus sasl (sf patch 1663064)
Nathan Walp <nwalp@pidgin.im>
parents: 15435
diff changeset
377 * 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
378 * 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
379 * 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
380 * 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
381 */
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
382 if (js->current_mech && strlen(js->current_mech) > 0) {
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
383 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
384 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
385 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
386 }
22913
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
387 /* Remove space which separated this mech from the next */
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
388 if (strlen(js->sasl_mechs->str) > 0 && ((js->sasl_mechs->str)[0] == ' ')) {
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25452
diff changeset
389 g_string_erase(js->sasl_mechs, 0, 1);
22913
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
390 }
14232
331b5d0a2fd4 [gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
391 again = TRUE;
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
392 }
14232
331b5d0a2fd4 [gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
393
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
394 sasl_dispose(&js->sasl);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
395 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
396 } while (again);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
397
12543
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
398 if (js->sasl_state == SASL_CONTINUE || js->sasl_state == SASL_OK) {
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
399 auth = xmlnode_new("auth");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13207
diff changeset
400 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
401 xmlnode_set_attrib(auth, "mechanism", js->current_mech);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25452
diff changeset
402
24830
2bde0b68abb6 Send the "client-accepts-full-bind-result" attribute for Google Talk when
Paul Aurich <darkrain42@pidgin.im>
parents: 23532
diff changeset
403 xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth");
2bde0b68abb6 Send the "client-accepts-full-bind-result" attribute for Google Talk when
Paul Aurich <darkrain42@pidgin.im>
parents: 23532
diff changeset
404 xmlnode_set_attrib(auth, "ga:client-uses-full-bind-result", "true");
2bde0b68abb6 Send the "client-accepts-full-bind-result" attribute for Google Talk when
Paul Aurich <darkrain42@pidgin.im>
parents: 23532
diff changeset
405
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
406 if (clientout) {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
407 if (coutlen == 0) {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
408 xmlnode_insert_data(auth, "=", -1);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
409 } else {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
410 enc_out = purple_base64_encode((unsigned char*)clientout, coutlen);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
411 xmlnode_insert_data(auth, enc_out, -1);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
412 g_free(enc_out);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
413 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
414 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
415 jabber_send(js, auth);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
416 xmlnode_free(auth);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
417 } else {
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
418 purple_connection_error_reason (js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
419 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
420 "SASL authentication failed\n");
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
421 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
422 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
423
12543
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
424 static int
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
425 jabber_sasl_cb_log(void *context, int level, const char *message)
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
426 {
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
427 if(level <= SASL_LOG_TRACE)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
428 purple_debug_info("sasl", "%s\n", message);
12543
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
429
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
430 return SASL_OK;
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
431 }
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
432
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
433 void
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
434 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
435 {
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
436 int 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 /* 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
439 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
440 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
441
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
442 id = 0;
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
443 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
444 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
445 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
446 id++;
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
447
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
448 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
449 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
450 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
451 id++;
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
452
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
453 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
454 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
455 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
456 id++;
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
457
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
458 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
459 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
460 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
461 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
462 id++;
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
463 }
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
464
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
465 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
466 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
467 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
468 id++;
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
469
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
470 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
471 }
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
472
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
473 #endif
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
474
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
475 void
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
476 jabber_auth_start(JabberStream *js, xmlnode *packet)
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
477 {
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
478 #ifndef HAVE_CYRUS_SASL
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
479 gboolean digest_md5 = FALSE, plain=FALSE;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
480 #endif
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
481
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
482 xmlnode *mechs, *mechnode;
8296
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
483
089b639ebd8f [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8223
diff changeset
484
8016
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 7981
diff changeset
485 if(js->registration) {
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 7981
diff changeset
486 jabber_register_start(js);
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 7981
diff changeset
487 return;
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 7981
diff changeset
488 }
d75a4e86f7c3 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 7981
diff changeset
489
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
490 mechs = xmlnode_get_child(packet, "mechanisms");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
491
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
492 if(!mechs) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
493 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
494 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
495 _("Invalid response from server."));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
496 return;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
497 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
498
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
499 #ifdef HAVE_CYRUS_SASL
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
500 js->sasl_mechs = g_string_new("");
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
501 #endif
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
502
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8110
diff changeset
503 for(mechnode = xmlnode_get_child(mechs, "mechanism"); mechnode;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8110
diff changeset
504 mechnode = xmlnode_get_next_twin(mechnode))
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
505 {
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8110
diff changeset
506 char *mech_name = xmlnode_get_data(mechnode);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
507 #ifdef HAVE_CYRUS_SASL
23242
141db4dc5978 Skip the X-GOOGLE-TOKEN mech (given us by Google Talk when connecting with
Evan Schoenberg <evands@pidgin.im>
parents: 22967
diff changeset
508 /* Don't include Google Talk's X-GOOGLE-TOKEN mechanism, as we will not
141db4dc5978 Skip the X-GOOGLE-TOKEN mech (given us by Google Talk when connecting with
Evan Schoenberg <evands@pidgin.im>
parents: 22967
diff changeset
509 * support it and including it gives a false fall-back to other mechs offerred,
141db4dc5978 Skip the X-GOOGLE-TOKEN mech (given us by Google Talk when connecting with
Evan Schoenberg <evands@pidgin.im>
parents: 22967
diff changeset
510 * leading to incorrect error handling.
141db4dc5978 Skip the X-GOOGLE-TOKEN mech (given us by Google Talk when connecting with
Evan Schoenberg <evands@pidgin.im>
parents: 22967
diff changeset
511 */
23247
57957b699391 Plug leak.
Daniel Atallah <datallah@pidgin.im>
parents: 23242
diff changeset
512 if (mech_name && !strcmp(mech_name, "X-GOOGLE-TOKEN")) {
57957b699391 Plug leak.
Daniel Atallah <datallah@pidgin.im>
parents: 23242
diff changeset
513 g_free(mech_name);
23242
141db4dc5978 Skip the X-GOOGLE-TOKEN mech (given us by Google Talk when connecting with
Evan Schoenberg <evands@pidgin.im>
parents: 22967
diff changeset
514 continue;
23247
57957b699391 Plug leak.
Daniel Atallah <datallah@pidgin.im>
parents: 23242
diff changeset
515 }
23242
141db4dc5978 Skip the X-GOOGLE-TOKEN mech (given us by Google Talk when connecting with
Evan Schoenberg <evands@pidgin.im>
parents: 22967
diff changeset
516
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
517 g_string_append(js->sasl_mechs, mech_name);
14232
331b5d0a2fd4 [gaim-migrate @ 16820]
Daniel Atallah <datallah@pidgin.im>
parents: 13808
diff changeset
518 g_string_append_c(js->sasl_mechs, ' ');
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
519 #else
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8110
diff changeset
520 if(mech_name && !strcmp(mech_name, "DIGEST-MD5"))
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8110
diff changeset
521 digest_md5 = TRUE;
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8110
diff changeset
522 else if(mech_name && !strcmp(mech_name, "PLAIN"))
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8110
diff changeset
523 plain = TRUE;
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
524 #endif
8135
d4df7d1821a5 [gaim-migrate @ 8840]
Nathan Walp <nwalp@pidgin.im>
parents: 8110
diff changeset
525 g_free(mech_name);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
526 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
527
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
528 #ifdef HAVE_CYRUS_SASL
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
529 js->auth_type = JABBER_AUTH_CYRUS;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
530
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
531 jabber_sasl_build_callbacks(js);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
532
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
533 jabber_auth_start_cyrus(js);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
534 #else
7703
118ef0876fe6 [gaim-migrate @ 8348]
Nathan Walp <nwalp@pidgin.im>
parents: 7645
diff changeset
535
7645
d625eeab3b75 [gaim-migrate @ 8288]
Nathan Walp <nwalp@pidgin.im>
parents: 7644
diff changeset
536 if(digest_md5) {
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
537 xmlnode *auth;
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
538
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
539 js->auth_type = JABBER_AUTH_DIGEST_MD5;
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
540 auth = xmlnode_new("auth");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13207
diff changeset
541 xmlnode_set_namespace(auth, "urn:ietf:params:xml:ns:xmpp-sasl");
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
542 xmlnode_set_attrib(auth, "mechanism", "DIGEST-MD5");
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
543
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
544 jabber_send(js, auth);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
545 xmlnode_free(auth);
8086
7ac5092091f0 [gaim-migrate @ 8785]
Nathan Walp <nwalp@pidgin.im>
parents: 8084
diff changeset
546 } else if(plain) {
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
547 js->auth_type = JABBER_AUTH_PLAIN;
7703
118ef0876fe6 [gaim-migrate @ 8348]
Nathan Walp <nwalp@pidgin.im>
parents: 7645
diff changeset
548
26533
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
549 if(!jabber_stream_is_ssl(js) && !purple_account_get_bool(js->gc->account, "auth_plain_in_clear", FALSE)) {
17050
a41a4e5820d0 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16724
diff changeset
550 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
551 js->gc->account->username);
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
552 purple_request_yes_no(js->gc, _("Plaintext Authentication"),
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
553 _("Plaintext Authentication"),
17050
a41a4e5820d0 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16724
diff changeset
554 msg,
22269
3fdf7b13f20a A few more of those "default_action" fixes
Mark Doliner <markdoliner@pidgin.im>
parents: 22068
diff changeset
555 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
556 purple_connection_get_account(js->gc), NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
557 purple_connection_get_account(js->gc), allow_plaintext_auth,
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
558 disallow_plaintext_auth);
17050
a41a4e5820d0 fixes #763
Nathan Walp <nwalp@pidgin.im>
parents: 16724
diff changeset
559 g_free(msg);
8086
7ac5092091f0 [gaim-migrate @ 8785]
Nathan Walp <nwalp@pidgin.im>
parents: 8084
diff changeset
560 return;
7ac5092091f0 [gaim-migrate @ 8785]
Nathan Walp <nwalp@pidgin.im>
parents: 8084
diff changeset
561 }
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
562 finish_plaintext_authentication(js);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
563 } else {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
564 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
565 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
566 _("Server does not use any supported authentication method"));
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
567 }
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
568 #endif
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
569 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
570
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
571 static void auth_old_result_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
572 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
573 xmlnode *packet, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
574 {
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
575 if (type == JABBER_IQ_RESULT) {
26669
eabe41a84e13 Fix login process for older servers using IQ-auth.
Paul Aurich <darkrain42@pidgin.im>
parents: 26533
diff changeset
576 jabber_disco_items_server(js);
7730
b7280ceae395 [gaim-migrate @ 8375]
Nathan Walp <nwalp@pidgin.im>
parents: 7704
diff changeset
577 } else {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
578 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
579 char *msg = jabber_parse_error(js, packet, &reason);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
580 xmlnode *error;
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
581 const char *err_code;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
582
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
583 /* FIXME: Why is this not in jabber_parse_error? */
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
584 if((error = xmlnode_get_child(packet, "error")) &&
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
585 (err_code = xmlnode_get_attrib(error, "code")) &&
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
586 !strcmp(err_code, "401")) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
587 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
588 /* 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
589 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
590 purple_account_set_password(js->gc->account, NULL);
7730
b7280ceae395 [gaim-migrate @ 8375]
Nathan Walp <nwalp@pidgin.im>
parents: 7704
diff changeset
591 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
592
20855
d263076a39f8 Sprinkle gc->wants_to_die = TRUE liberally around connection errors that really
Will Thompson <resiak@pidgin.im>
parents: 20853
diff changeset
593 purple_connection_error_reason (js->gc, reason, msg);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
594 g_free(msg);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
595 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
596 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
597
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
598 static void auth_old_cb(JabberStream *js, const char *from,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
599 JabberIqType type, const char *id,
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
600 xmlnode *packet, gpointer data)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
601 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
602 JabberIq *iq;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
603 xmlnode *query, *x;
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
604 const char *pw = purple_connection_get_password(js->gc);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
605
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
606 if (type == JABBER_IQ_ERROR) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
607 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
608 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
609 purple_connection_error_reason (js->gc, reason, msg);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
610 g_free(msg);
26687
1e799151fabe Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
611 } else if (type == JABBER_IQ_RESULT) {
7514
bfea1665a240 [gaim-migrate @ 8127]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
612 query = xmlnode_get_child(packet, "query");
bfea1665a240 [gaim-migrate @ 8127]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
613 if(js->stream_id && xmlnode_get_child(query, "digest")) {
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24830
diff changeset
614 char *s, *hash;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
615
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
616 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:auth");
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
617 query = xmlnode_get_child(iq->node, "query");
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
618 x = xmlnode_new_child(query, "username");
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
619 xmlnode_insert_data(x, js->user->node, -1);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
620 x = xmlnode_new_child(query, "resource");
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
621 xmlnode_insert_data(x, js->user->resource, -1);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
622
7514
bfea1665a240 [gaim-migrate @ 8127]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
623 x = xmlnode_new_child(query, "digest");
bfea1665a240 [gaim-migrate @ 8127]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
624 s = g_strdup_printf("%s%s", js->stream_id, pw);
25110
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24830
diff changeset
625 hash = jabber_calculate_data_sha1sum(s, strlen(s));
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24830
diff changeset
626 xmlnode_insert_data(x, hash, -1);
40b3fffdb00b Fix up the XMPP User Avatar SHA1 hashing so that we don't mess up the checksum
Paul Aurich <darkrain42@pidgin.im>
parents: 24830
diff changeset
627 g_free(hash);
7514
bfea1665a240 [gaim-migrate @ 8127]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
628 g_free(s);
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
629 jabber_iq_set_callback(iq, auth_old_result_cb, NULL);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
630 jabber_iq_send(iq);
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
631
23407
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
632 } else if(js->stream_id && (x = xmlnode_get_child(query, "crammd5"))) {
21967
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
633 const char *challenge;
23407
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
634 gchar digest[33];
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
635 PurpleCipherContext *hmac;
21967
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
636
23407
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
637 /* Calculate the MHAC-MD5 digest */
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
638 challenge = xmlnode_get_attrib(x, "challenge");
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
639 hmac = purple_cipher_context_new_by_name("hmac", NULL);
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
640 purple_cipher_context_set_option(hmac, "hash", "md5");
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
641 purple_cipher_context_set_key(hmac, (guchar *)pw);
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
642 purple_cipher_context_append(hmac, (guchar *)challenge, strlen(challenge));
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
643 purple_cipher_context_digest_to_str(hmac, 33, digest, NULL);
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
644 purple_cipher_context_destroy(hmac);
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
645
9386fcc30b22 Last minute 'cleanup' actually resulted in breakage on my cram-md5 commit. Fixed it.
Evan Schoenberg <evands@pidgin.im>
parents: 21967
diff changeset
646 /* 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
647 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
648 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
649
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
650 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
651 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
652 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
653 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
654
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
655 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
656
23407
6f89ce4acd7a A patch from QuLogic to eliminate duplicated HMAC-MD5 code in the Jabber
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 23399
diff changeset
657 xmlnode_insert_data(x, digest, 32);
21967
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
658
3f1c1518a7e1 Added support for authentication via CRAM-MD5 when using jabber:iq:auth.
Evan Schoenberg <evands@pidgin.im>
parents: 21966
diff changeset
659 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
660 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
661
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
662 } else if(xmlnode_get_child(query, "password")) {
26533
5c74696c34d1 BOSH: For authentication purposes, HTTPS is equivalent to a secured JabberStream.
Paul Aurich <darkrain42@pidgin.im>
parents: 26042
diff changeset
663 if(!jabber_stream_is_ssl(js) && !purple_account_get_bool(js->gc->account,
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
664 "auth_plain_in_clear", FALSE)) {
22815
a352aba19309 The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evands@pidgin.im>
parents: 22802
diff changeset
665 char *msg = g_strdup_printf(_("%s requires plaintext authentication over an unencrypted connection. Allow this and continue authentication?"),
a352aba19309 The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evands@pidgin.im>
parents: 22802
diff changeset
666 js->gc->account->username);
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
667 purple_request_yes_no(js->gc, _("Plaintext Authentication"),
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
668 _("Plaintext Authentication"),
22815
a352aba19309 The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evands@pidgin.im>
parents: 22802
diff changeset
669 msg,
22269
3fdf7b13f20a A few more of those "default_action" fixes
Mark Doliner <markdoliner@pidgin.im>
parents: 22068
diff changeset
670 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
671 purple_connection_get_account(js->gc), NULL, NULL,
21175
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
672 purple_connection_get_account(js->gc), allow_plaintext_auth,
c6d76b49c206 disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents: 21174
diff changeset
673 disallow_plaintext_auth);
22815
a352aba19309 The warning string for plaintext auth over an unencrypted connection is found
Evan Schoenberg <evands@pidgin.im>
parents: 22802
diff changeset
674 g_free(msg);
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
675 return;
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
676 }
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
677 finish_plaintext_authentication(js);
7514
bfea1665a240 [gaim-migrate @ 8127]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
678 } else {
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
679 purple_connection_error_reason (js->gc,
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
680 PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
681 _("Server does not use any supported authentication method"));
8397
fdb63587b4db [gaim-migrate @ 9126]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
682 return;
7514
bfea1665a240 [gaim-migrate @ 8127]
Nathan Walp <nwalp@pidgin.im>
parents: 7425
diff changeset
683 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
684 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
685 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
686
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
687 void jabber_auth_start_old(JabberStream *js)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
688 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
689 JabberIq *iq;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
690 xmlnode *query, *username;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
691
27170
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
692 /* We can end up here without encryption if the server doesn't support
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
693 * <stream:features/> and we're not using old-style SSL. If the user
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
694 * is requiring SSL/TLS, we need to enforce it.
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
695 */
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
696 if (!jabber_stream_is_ssl(js) &&
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
697 purple_account_get_bool(purple_connection_get_account(js->gc), "require_tls", FALSE)) {
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
698 purple_connection_error_reason (js->gc,
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
699 PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR,
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
700 _("You require encryption, but it is not available on this server."));
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
701 return;
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
702 }
447ef31d038a Require SSL when trying IQ-auth via parser.c (no stream:features). Fixes #8131.
Paul Aurich <darkrain42@pidgin.im>
parents: 26707
diff changeset
703
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
704 #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
705 /* 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
706 * 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
707 * password prompting here
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
708 */
20093
04f3c1dcd2cf applied changes from 5fda75104115d0a95c1e214b6b3ca18c4dc86a0c
Richard Laager <rlaager@pidgin.im>
parents: 19993
diff changeset
709
16180
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
710 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
711 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
712 return;
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
713 }
82761882c366 patch from Simon Wilkinson to support Jabber/XMPP w/o passwords
Nathan Walp <nwalp@pidgin.im>
parents: 15952
diff changeset
714 #endif
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
715 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:auth");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
716
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
717 query = xmlnode_get_child(iq->node, "query");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
718 username = xmlnode_new_child(query, "username");
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
719 xmlnode_insert_data(username, js->user->node, -1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
720
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
721 jabber_iq_set_callback(iq, auth_old_cb, NULL);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
722
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
723 jabber_iq_send(iq);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
724 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
725
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
726 /* Parts of this algorithm are inspired by stuff in libgsasl */
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
727 static GHashTable* parse_challenge(const char *challenge)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
728 {
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
729 const char *token_start, *val_start, *val_end, *cur;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
730 GHashTable *ret = g_hash_table_new_full(g_str_hash, g_str_equal,
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
731 g_free, g_free);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
732
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
733 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
734 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
735 /* 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
736 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
737 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
738 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
739 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
740 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
741 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
742 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
743 }
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
744
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
745 /* 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
746 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
747 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
748 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
749
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
750 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
751 name = g_strndup(token_start, val_start - token_start);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
752
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
753 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
754 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
755 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
756 || *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
757 || *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
758 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
759
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
760 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
761 while (val_end != val_start && (*val_end == ' ' || *val_end == ',' || *val_end == '\t'
25452
3ab68fa7657e Two patches from Yann Kerherve submitted to pidgin-devl. This fixes XMPP
Evan Schoenberg <evands@pidgin.im>
parents: 25110
diff changeset
762 || *val_end == '\r' || *val_end == '\n'
3ab68fa7657e Two patches from Yann Kerherve submitted to pidgin-devl. This fixes XMPP
Evan Schoenberg <evands@pidgin.im>
parents: 25110
diff changeset
763 || *val_end == '"' || *val_end == '\0'))
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
764 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
765
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 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
767 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
768 }
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
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
770 g_hash_table_replace(ret, name, value);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
771 }
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
772
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 /* 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
774 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
775 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
776 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
777 || *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
778 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 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
780 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
781
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
782 return ret;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
783 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
784
11163
7fe2cec8e9e6 [gaim-migrate @ 13264]
Mark Doliner <markdoliner@pidgin.im>
parents: 11137
diff changeset
785 static char *
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
786 generate_response_value(JabberID *jid, const char *passwd, const char *nonce,
27233
998e51892e71 disapproval of revision 'a9a3e03b1399ac5465372781d925c7f2fb021ea0'
Paul Aurich <darkrain42@pidgin.im>
parents: 27232
diff changeset
787 const char *cnonce, const char *a2, const char *realm)
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
788 {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
789 PurpleCipher *cipher;
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
790 PurpleCipherContext *context;
11137
cf40226ddff7 [gaim-migrate @ 13201]
Mark Doliner <markdoliner@pidgin.im>
parents: 11127
diff changeset
791 guchar result[16];
10136
080d718279c9 [gaim-migrate @ 11204]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
792 size_t a1len;
27233
998e51892e71 disapproval of revision 'a9a3e03b1399ac5465372781d925c7f2fb021ea0'
Paul Aurich <darkrain42@pidgin.im>
parents: 27232
diff changeset
793
27232
a9a3e03b1399 jabber digest-md5: Only specify the charset as UTF-8 if conversion to ISO-8859-1 was not successful.
Paul Aurich <darkrain42@pidgin.im>
parents: 27170
diff changeset
794 gchar *a1, *convnode=NULL, *convpasswd = NULL, *ha1, *ha2, *kd, *x, *z;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
795
19337
68471e68386a Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <datallah@pidgin.im>
parents: 19223
diff changeset
796 if((convnode = g_convert(jid->node, -1, "iso-8859-1", "utf-8",
10136
080d718279c9 [gaim-migrate @ 11204]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
797 NULL, NULL, NULL)) == NULL) {
080d718279c9 [gaim-migrate @ 11204]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
798 convnode = g_strdup(jid->node);
080d718279c9 [gaim-migrate @ 11204]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
799 }
19337
68471e68386a Use -1 as length with g_convert() functions instead of strlen()
Daniel Atallah <datallah@pidgin.im>
parents: 19223
diff changeset
800 if(passwd && ((convpasswd = g_convert(passwd, -1, "iso-8859-1",
12549
0fc163c4927a [gaim-migrate @ 14867]
Nathan Walp <nwalp@pidgin.im>
parents: 12543
diff changeset
801 "utf-8", NULL, NULL, NULL)) == NULL)) {
10136
080d718279c9 [gaim-migrate @ 11204]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
802 convpasswd = g_strdup(passwd);
080d718279c9 [gaim-migrate @ 11204]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
803 }
080d718279c9 [gaim-migrate @ 11204]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
804
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
805 cipher = purple_ciphers_find_cipher("md5");
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
806 context = purple_cipher_context_new(cipher, NULL);
10684
0325b164a7eb [gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents: 10496
diff changeset
807
12549
0fc163c4927a [gaim-migrate @ 14867]
Nathan Walp <nwalp@pidgin.im>
parents: 12543
diff changeset
808 x = g_strdup_printf("%s:%s:%s", convnode, realm, convpasswd ? convpasswd : "");
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
809 purple_cipher_context_append(context, (const guchar *)x, strlen(x));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
810 purple_cipher_context_digest(context, sizeof(result), result, NULL);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
811
10136
080d718279c9 [gaim-migrate @ 11204]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
812 a1 = g_strdup_printf("xxxxxxxxxxxxxxxx:%s:%s", nonce, cnonce);
080d718279c9 [gaim-migrate @ 11204]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
813 a1len = strlen(a1);
080d718279c9 [gaim-migrate @ 11204]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
814 g_memmove(a1, result, 16);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
815
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
816 purple_cipher_context_reset(context, NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
817 purple_cipher_context_append(context, (const guchar *)a1, a1len);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
818 purple_cipher_context_digest(context, sizeof(result), result, NULL);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
819
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
820 ha1 = purple_base16_encode(result, 16);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
821
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
822 purple_cipher_context_reset(context, NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
823 purple_cipher_context_append(context, (const guchar *)a2, strlen(a2));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
824 purple_cipher_context_digest(context, sizeof(result), result, NULL);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
825
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
826 ha2 = purple_base16_encode(result, 16);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
827
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
828 kd = g_strdup_printf("%s:%s:00000001:%s:auth:%s", ha1, nonce, cnonce, ha2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
829
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
830 purple_cipher_context_reset(context, NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
831 purple_cipher_context_append(context, (const guchar *)kd, strlen(kd));
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
832 purple_cipher_context_digest(context, sizeof(result), result, NULL);
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
833 purple_cipher_context_destroy(context);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
834
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
835 z = purple_base16_encode(result, 16);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
836
10136
080d718279c9 [gaim-migrate @ 11204]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
837 g_free(convnode);
080d718279c9 [gaim-migrate @ 11204]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
838 g_free(convpasswd);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
839 g_free(x);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
840 g_free(a1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
841 g_free(ha1);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
842 g_free(ha2);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
843 g_free(kd);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
844
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
845 return z;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
846 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
847
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
848 void
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
849 jabber_auth_handle_challenge(JabberStream *js, xmlnode *packet)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
850 {
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
851
7703
118ef0876fe6 [gaim-migrate @ 8348]
Nathan Walp <nwalp@pidgin.im>
parents: 7645
diff changeset
852 if(js->auth_type == JABBER_AUTH_DIGEST_MD5) {
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
853 char *enc_in = xmlnode_get_data(packet);
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
854 char *dec_in;
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
855 char *enc_out;
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
856 GHashTable *parts;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
857
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
858 if(!enc_in) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
859 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
860 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
861 _("Invalid response from server."));
7395
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
862 return;
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
863 }
e5595e8e13e4 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
864
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
865 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
866 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
867 G_GSIZE_FORMAT "): %s\n", strlen(dec_in), dec_in);
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
868
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
869 parts = parse_challenge(dec_in);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
870
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
871
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
872 if (g_hash_table_lookup(parts, "rspauth")) {
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
873 char *rspauth = g_hash_table_lookup(parts, "rspauth");
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
874
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
875
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
876 if(rspauth && js->expected_rspauth &&
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
877 !strcmp(rspauth, js->expected_rspauth)) {
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
878 jabber_send_raw(js,
7642
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
879 "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl' />",
4e1735a499f5 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
880 -1);
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
881 } else {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
882 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
883 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
884 _("Invalid challenge from server"));
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
885 }
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
886 g_free(js->expected_rspauth);
23265
c7359dde8a1b NULL out js->expected_rspauth, so it doesn't get double-freed in jabber_close().
Will Thompson <resiak@pidgin.im>
parents: 23247
diff changeset
887 js->expected_rspauth = NULL;
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
888 } else {
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
889 /* assemble a response, and send it */
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
890 /* see RFC 2831 */
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
891 char *realm;
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
892 char *nonce;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
893
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
894 /* 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
895 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
896
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
897 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
898
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
899 /* we're actually supposed to prompt the user for a realm if
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
900 * the server doesn't send one, but that really complicates things,
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
901 * so i'm not gonna worry about it until is poses a problem to
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
902 * someone, or I get really bored */
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
903 realm = g_hash_table_lookup(parts, "realm");
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
904 if(!realm)
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
905 realm = js->user->domain;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
906
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
907 if (nonce == NULL || realm == NULL)
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
908 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
909 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
910 _("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
911 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
912 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
913 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
914 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
915 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
916 char *cnonce;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
917
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
918 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
919 g_random_int());
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
920
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
921 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
922 auth_resp = generate_response_value(js->user,
27233
998e51892e71 disapproval of revision 'a9a3e03b1399ac5465372781d925c7f2fb021ea0'
Paul Aurich <darkrain42@pidgin.im>
parents: 27232
diff changeset
923 purple_connection_get_password(js->gc), nonce, cnonce, a2, realm);
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
924 g_free(a2);
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
925
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
926 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
927 js->expected_rspauth = generate_response_value(js->user,
27233
998e51892e71 disapproval of revision 'a9a3e03b1399ac5465372781d925c7f2fb021ea0'
Paul Aurich <darkrain42@pidgin.im>
parents: 27232
diff changeset
928 purple_connection_get_password(js->gc), nonce, cnonce, a2, realm);
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
929 g_free(a2);
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
930
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
931 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
932 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
933 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
934 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
935 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
936 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
937 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
938 g_string_append_printf(response, ",response=%s", auth_resp);
27233
998e51892e71 disapproval of revision 'a9a3e03b1399ac5465372781d925c7f2fb021ea0'
Paul Aurich <darkrain42@pidgin.im>
parents: 27232
diff changeset
939 g_string_append_printf(response, ",charset=utf-8");
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
940
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
941 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
942 g_free(cnonce);
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
943
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
944 enc_out = purple_base64_encode((guchar *)response->str, response->len);
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
945
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
946 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
947 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
948 response->len, response->str);
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
949
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 buf = g_strdup_printf("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>%s</response>", enc_out);
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
951
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
952 jabber_send_raw(js, buf, -1);
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
953
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
954 g_free(buf);
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
955
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
956 g_free(enc_out);
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
957
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
958 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
959 }
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
960 }
7291
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
961
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
962 g_free(enc_in);
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
963 g_free(dec_in);
3d8a237f36cb [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7267
diff changeset
964 g_hash_table_destroy(parts);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
965 }
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
966 #ifdef HAVE_CYRUS_SASL
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
967 else if (js->auth_type == JABBER_AUTH_CYRUS) {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
968 char *enc_in = xmlnode_get_data(packet);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
969 unsigned char *dec_in;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
970 char *enc_out;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
971 const char *c_out;
12543
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
972 unsigned int clen;
8b13b94e4178 [gaim-migrate @ 14860]
Nathan Walp <nwalp@pidgin.im>
parents: 12540
diff changeset
973 gsize declen;
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
974 xmlnode *response;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
975
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
976 dec_in = purple_base64_decode(enc_in, &declen);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
977
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
978 js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen,
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
979 NULL, &c_out, &clen);
15170
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
980 g_free(enc_in);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
981 g_free(dec_in);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
982 if (js->sasl_state != SASL_CONTINUE && js->sasl_state != SASL_OK) {
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
983 purple_debug_error("jabber", "Error is %d : %s\n",js->sasl_state,sasl_errdetail(js->sasl));
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
984 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
985 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
986 _("SASL error"));
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
987 return;
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
988 } else {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
989 response = xmlnode_new("response");
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13207
diff changeset
990 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
991 if (clen > 0) {
27257
bfa8ca28afd6 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27233
diff changeset
992 /* Cyrus SASL 2.1.22 appears to contain code to add the charset
27379
eb193d927190 Only append ,charset=utf-8 for DIGEST-MD5. This should fix comment 2 on Adium#12429.
Paul Aurich <darkrain42@pidgin.im>
parents: 27261
diff changeset
993 * to the response for DIGEST-MD5 but there is no possibility
eb193d927190 Only append ,charset=utf-8 for DIGEST-MD5. This should fix comment 2 on Adium#12429.
Paul Aurich <darkrain42@pidgin.im>
parents: 27261
diff changeset
994 * it will be executed.
eb193d927190 Only append ,charset=utf-8 for DIGEST-MD5. This should fix comment 2 on Adium#12429.
Paul Aurich <darkrain42@pidgin.im>
parents: 27261
diff changeset
995 *
27257
bfa8ca28afd6 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27233
diff changeset
996 * My reading of the digestmd5 plugin indicates the username and
bfa8ca28afd6 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27233
diff changeset
997 * realm are always encoded in UTF-8 (they seem to be the values
bfa8ca28afd6 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27233
diff changeset
998 * we pass in), so we need to ensure charset=utf-8 is set.
bfa8ca28afd6 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27233
diff changeset
999 */
27379
eb193d927190 Only append ,charset=utf-8 for DIGEST-MD5. This should fix comment 2 on Adium#12429.
Paul Aurich <darkrain42@pidgin.im>
parents: 27261
diff changeset
1000 if (!js->current_mech || !g_str_equal(js->current_mech, "DIGEST-MD5") ||
eb193d927190 Only append ,charset=utf-8 for DIGEST-MD5. This should fix comment 2 on Adium#12429.
Paul Aurich <darkrain42@pidgin.im>
parents: 27261
diff changeset
1001 strstr(c_out, ",charset="))
eb193d927190 Only append ,charset=utf-8 for DIGEST-MD5. This should fix comment 2 on Adium#12429.
Paul Aurich <darkrain42@pidgin.im>
parents: 27261
diff changeset
1002 /* If we're not using DIGEST-MD5 or Cyrus SASL is fixed */
27257
bfa8ca28afd6 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27233
diff changeset
1003 enc_out = purple_base64_encode((unsigned char*)c_out, clen);
bfa8ca28afd6 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27233
diff changeset
1004 else {
bfa8ca28afd6 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27233
diff changeset
1005 char *tmp = g_strdup_printf("%s,charset=utf-8", c_out);
27261
Paul Aurich <darkrain42@pidgin.im>
parents: 27257
diff changeset
1006 enc_out = purple_base64_encode((unsigned char*)tmp, clen + 14);
27257
bfa8ca28afd6 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27233
diff changeset
1007 g_free(tmp);
bfa8ca28afd6 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27233
diff changeset
1008 }
bfa8ca28afd6 Set charset=utf-8 when cyrus sasl doesn't include it.
Paul Aurich <darkrain42@pidgin.im>
parents: 27233
diff changeset
1009
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1010 xmlnode_insert_data(response, enc_out, -1);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1011 g_free(enc_out);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1012 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1013 jabber_send(js, response);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1014 xmlnode_free(response);
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1015 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1016 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1017 #endif
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1018 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1019
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1020 void jabber_auth_handle_success(JabberStream *js, xmlnode *packet)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1021 {
13808
411ee56da344 [gaim-migrate @ 16229]
Sean Egan <seanegan@pidgin.im>
parents: 13207
diff changeset
1022 const char *ns = xmlnode_get_namespace(packet);
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1023 #ifdef HAVE_CYRUS_SASL
16395
f6df845a2956 Get rid of two really minor warnings
Mark Doliner <markdoliner@pidgin.im>
parents: 16180
diff changeset
1024 const void *x;
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1025 #endif
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1026
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1027 if(!ns || strcmp(ns, "urn:ietf:params:xml:ns:xmpp-sasl")) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
1028 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
1029 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
1030 _("Invalid response from server."));
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1031 return;
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1032 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1033
12520
3ec49915efd8 [gaim-migrate @ 14832]
Richard Laager <rlaager@pidgin.im>
parents: 12508
diff changeset
1034 #ifdef HAVE_CYRUS_SASL
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1035 /* The SASL docs say that if the client hasn't returned OK yet, we
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1036 * should try one more round against it
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1037 */
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1038 if (js->sasl_state != SASL_OK) {
15170
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
1039 char *enc_in = xmlnode_get_data(packet);
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
1040 unsigned char *dec_in = NULL;
15112
cf00caa09ed4 [gaim-migrate @ 17834]
Mark Doliner <markdoliner@pidgin.im>
parents: 14660
diff changeset
1041 const char *c_out;
cf00caa09ed4 [gaim-migrate @ 17834]
Mark Doliner <markdoliner@pidgin.im>
parents: 14660
diff changeset
1042 unsigned int clen;
15170
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
1043 gsize declen = 0;
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
1044
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
1045 if(enc_in != NULL)
15884
4de1981757fc sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@pidgin.im>
parents: 15800
diff changeset
1046 dec_in = purple_base64_decode(enc_in, &declen);
15170
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
1047
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
1048 js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen, NULL, &c_out, &clen);
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
1049
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
1050 g_free(enc_in);
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
1051 g_free(dec_in);
2a272f828453 [gaim-migrate @ 17894]
Nathan Walp <nwalp@pidgin.im>
parents: 15143
diff changeset
1052
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1053 if (js->sasl_state != SASL_OK) {
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1054 /* This should never happen! */
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
1055 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
1056 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
1057 _("Invalid response from server."));
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1058 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1059 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1060 /* 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
1061 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
1062 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
1063 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
1064 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
1065 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
1066 }
12508
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1067 }
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1068 #endif
32f6f8bf3a57 [gaim-migrate @ 14820]
Simon Wilkinson
parents: 11183
diff changeset
1069
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1070 jabber_stream_set_state(js, JABBER_STREAM_REINITIALIZING);
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1071 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1072
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1073 void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet)
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1074 {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
1075 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
1076 char *msg;
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1077
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
1078 #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
1079 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
1080 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
1081 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
1082 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
1083 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
1084 }
22913
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
1085 /* Remove space which separated this mech from the next */
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
1086 if (strlen(js->sasl_mechs->str) > 0 && ((js->sasl_mechs->str)[0] == ' ')) {
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25452
diff changeset
1087 g_string_erase(js->sasl_mechs, 0, 1);
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25452
diff changeset
1088 }
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
1089 }
22913
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
1090 if (strlen(js->sasl_mechs->str)) {
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
1091 /* If we have remaining mechs to try, do so */
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
1092 sasl_dispose(&js->sasl);
26042
4dabdb5fe213 Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25452
diff changeset
1093
22913
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
1094 jabber_auth_start_cyrus(js);
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
1095 return;
d0ecc309dc42 After trying the available SASL mechs, jabber_auth_handle_failure() now
Evan Schoenberg <evands@pidgin.im>
parents: 22815
diff changeset
1096 }
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
1097 }
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 #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
1099 msg = jabber_parse_error(js, packet, &reason);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
1100 if(!msg) {
21279
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
1101 purple_connection_error_reason (js->gc,
40685e1f50ca Rename:
Will Thompson <resiak@pidgin.im>
parents: 21151
diff changeset
1102 PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
20445
c900767c024b Use PurpleDisconnectReasons in prpl-jabber.
Will Thompson <resiak@pidgin.im>
parents: 19993
diff changeset
1103 _("Invalid response from server."));
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
1104 } else {
21150
bedd1215fb5e Stop jabber setting wants_to_die itself. This involved plumbing disconnection
Will Thompson <resiak@pidgin.im>
parents: 20882
diff changeset
1105 purple_connection_error_reason (js->gc, reason, msg);
8401
9fe6cadf2581 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8397
diff changeset
1106 g_free(msg);
7014
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1107 }
11471fae7ba0 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1108 }

mercurial