Thu, 01 Jun 2017 19:59:58 -0500
Remove purple_base64_encode/decode() wrappers
The utility functions purple_base64_encode() & purple_base64_decode()
are but thin wrappers around g_base64_encode() & g_base64_decode().
This patch removes the former and replaces all current usage to the
latter.
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
1 | /* |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
2 | * purple - Jabber Protocol Plugin |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
3 | * |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
6 | * source distribution. |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
7 | * |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
11 | * (at your option) any later version. |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
12 | * |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
16 | * GNU General Public License for more details. |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
17 | * |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
19 | * along with this program; if not, write to the Free Software |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
21 | * |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
22 | */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
23 | #include "internal.h" |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
24 | #include "core.h" |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
25 | #include "debug.h" |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
26 | #include "request.h" |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
27 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
28 | #include "auth.h" |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
29 | #include "jabber.h" |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
30 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
31 | static JabberSaslState jabber_auth_start_cyrus(JabberStream *js, PurpleXmlNode **reply, |
|
29090
b351fcdeede7
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents:
29089
diff
changeset
|
32 | char **error); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
33 | static void jabber_sasl_build_callbacks(JabberStream *); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
34 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
35 | static void disallow_plaintext_auth(PurpleAccount *account) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
36 | { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31804
diff
changeset
|
37 | purple_connection_error(purple_account_get_connection(account), |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
38 | PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR, |
|
30505
ced16596ce78
jabber: This is more accurate, I think (e.g. Cyrus doesn't know what SCRAM-SHA-1 is)
Paul Aurich <darkrain42@pidgin.im>
parents:
30432
diff
changeset
|
39 | _("Server may require plaintext authentication over an unencrypted stream")); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
40 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
41 | |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
42 | static void start_cyrus_wrapper(JabberStream *js) |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
43 | { |
|
29090
b351fcdeede7
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents:
29089
diff
changeset
|
44 | char *error = NULL; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
45 | PurpleXmlNode *response = NULL; |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
46 | JabberSaslState state = jabber_auth_start_cyrus(js, &response, &error); |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
47 | |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
48 | if (state == JABBER_SASL_STATE_FAIL) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31804
diff
changeset
|
49 | purple_connection_error(js->gc, |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
50 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
51 | error); |
|
29090
b351fcdeede7
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents:
29089
diff
changeset
|
52 | g_free(error); |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
53 | } else if (response) { |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
54 | jabber_send(js, response); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
55 | purple_xmlnode_free(response); |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
56 | } |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
57 | } |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
58 | |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
59 | |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
60 | /* Callbacks for Cyrus SASL */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
61 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
62 | static int jabber_sasl_cb_realm(void *ctx, int id, const char **avail, const char **result) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
63 | { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
64 | JabberStream *js = ctx; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
65 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
66 | if (id != SASL_CB_GETREALM || !result) return SASL_BADPARAM; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
67 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
68 | *result = js->user->domain; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
69 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
70 | return SASL_OK; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
71 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
72 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
73 | static int jabber_sasl_cb_simple(void *ctx, int id, const char **res, unsigned *len) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
74 | { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
75 | JabberStream *js = ctx; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
76 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
77 | switch(id) { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
78 | case SASL_CB_AUTHNAME: |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
79 | *res = js->user->node; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
80 | break; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
81 | case SASL_CB_USER: |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
82 | *res = ""; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
83 | break; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
84 | default: |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
85 | return SASL_BADPARAM; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
86 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
87 | if (len) *len = strlen((char *)*res); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
88 | return SASL_OK; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
89 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
90 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
91 | static int jabber_sasl_cb_secret(sasl_conn_t *conn, void *ctx, int id, sasl_secret_t **secret) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
92 | { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
93 | JabberStream *js = ctx; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
94 | size_t len; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
95 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
96 | if (!conn || !secret || id != SASL_CB_PASS) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
97 | return SASL_BADPARAM; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
98 | |
|
37646
8f99c1dff72e
Fix jabber password dialog infinite loop with SASL
Jakub Adam <jakub.adam@ktknet.cz>
parents:
36068
diff
changeset
|
99 | len = strlen(js->sasl_password); |
|
30691
b254fed526a6
jabber: Document this not being an off-by-one...
Paul Aurich <darkrain42@pidgin.im>
parents:
30505
diff
changeset
|
100 | /* Not an off-by-one because sasl_secret_t defines char data[1] */ |
|
30723
96e248b07586
jabber: Fix a pernicious race condition in our cyrus auth code
Paul Aurich <darkrain42@pidgin.im>
parents:
30708
diff
changeset
|
101 | /* TODO: This can probably be moved to glib's allocator */ |
|
96e248b07586
jabber: Fix a pernicious race condition in our cyrus auth code
Paul Aurich <darkrain42@pidgin.im>
parents:
30708
diff
changeset
|
102 | js->sasl_secret = malloc(sizeof(sasl_secret_t) + len); |
|
96e248b07586
jabber: Fix a pernicious race condition in our cyrus auth code
Paul Aurich <darkrain42@pidgin.im>
parents:
30708
diff
changeset
|
103 | if (!js->sasl_secret) |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
104 | return SASL_NOMEM; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
105 | |
|
30723
96e248b07586
jabber: Fix a pernicious race condition in our cyrus auth code
Paul Aurich <darkrain42@pidgin.im>
parents:
30708
diff
changeset
|
106 | js->sasl_secret->len = len; |
|
37646
8f99c1dff72e
Fix jabber password dialog infinite loop with SASL
Jakub Adam <jakub.adam@ktknet.cz>
parents:
36068
diff
changeset
|
107 | strcpy((char*)js->sasl_secret->data, js->sasl_password); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
108 | |
|
30723
96e248b07586
jabber: Fix a pernicious race condition in our cyrus auth code
Paul Aurich <darkrain42@pidgin.im>
parents:
30708
diff
changeset
|
109 | *secret = js->sasl_secret; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
110 | return SASL_OK; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
111 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
112 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
113 | static void allow_cyrus_plaintext_auth(PurpleAccount *account) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
114 | { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
115 | PurpleConnection *gc; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
116 | JabberStream *js; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
117 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
118 | gc = purple_account_get_connection(account); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
119 | js = purple_connection_get_protocol_data(gc); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
120 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
121 | purple_account_set_bool(account, "auth_plain_in_clear", TRUE); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
122 | |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
123 | start_cyrus_wrapper(js); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
124 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
125 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
126 | static void auth_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
127 | { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
128 | PurpleAccount *account; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
129 | JabberStream *js; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
130 | const char *entry; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
131 | gboolean remember; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
132 | |
|
36068
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35341
diff
changeset
|
133 | /* TODO: the password prompt dialog doesn't get disposed if the account disconnects */ |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35341
diff
changeset
|
134 | PURPLE_ASSERT_CONNECTION_IS_VALID(gc); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
135 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
136 | account = purple_connection_get_account(gc); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
137 | js = purple_connection_get_protocol_data(gc); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
138 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
139 | entry = purple_request_fields_get_string(fields, "password"); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
140 | remember = purple_request_fields_get_bool(fields, "remember"); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
141 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
142 | if (!entry || !*entry) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
143 | { |
|
34513
6f6de16b4044
Fix build with Cyrus SASL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34440
diff
changeset
|
144 | purple_notify_error(account, NULL, |
|
6f6de16b4044
Fix build with Cyrus SASL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34440
diff
changeset
|
145 | _("Password is required to sign on."), NULL, |
|
6f6de16b4044
Fix build with Cyrus SASL
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34440
diff
changeset
|
146 | purple_request_cpar_from_connection(gc)); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
147 | return; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
148 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
149 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
150 | if (remember) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
151 | purple_account_set_remember_password(account, TRUE); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
152 | |
|
34029
059c1270db1f
Remove the silly destroy argument from purple_account_set_password and
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
34028
diff
changeset
|
153 | purple_account_set_password(account, entry, NULL, NULL); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
154 | |
|
37646
8f99c1dff72e
Fix jabber password dialog infinite loop with SASL
Jakub Adam <jakub.adam@ktknet.cz>
parents:
36068
diff
changeset
|
155 | js->sasl_password = g_strdup(entry); |
|
8f99c1dff72e
Fix jabber password dialog infinite loop with SASL
Jakub Adam <jakub.adam@ktknet.cz>
parents:
36068
diff
changeset
|
156 | |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
157 | /* Rebuild our callbacks as we now have a password to offer */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
158 | jabber_sasl_build_callbacks(js); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
159 | |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
160 | /* Restart our negotiation */ |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
161 | start_cyrus_wrapper(js); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
162 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
163 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
164 | static void |
|
28860
d2a057cdd7b6
jabber: A little more use of accessors.
Paul Aurich <darkrain42@pidgin.im>
parents:
28859
diff
changeset
|
165 | auth_no_pass_cb(PurpleConnection *gc, PurpleRequestFields *fields) |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
166 | { |
|
28860
d2a057cdd7b6
jabber: A little more use of accessors.
Paul Aurich <darkrain42@pidgin.im>
parents:
28859
diff
changeset
|
167 | PurpleAccount *account; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
168 | |
|
36068
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35341
diff
changeset
|
169 | /* TODO: the password prompt dialog doesn't get disposed if the account disconnects */ |
|
e9b9320a985a
Drop PURPLE_CONNECTION_IS_VALID in favor of (temporary) PURPLE_ASSERT_CONNECTION_IS_VALID
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35341
diff
changeset
|
170 | PURPLE_ASSERT_CONNECTION_IS_VALID(gc); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
171 | |
|
28860
d2a057cdd7b6
jabber: A little more use of accessors.
Paul Aurich <darkrain42@pidgin.im>
parents:
28859
diff
changeset
|
172 | account = purple_connection_get_account(gc); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
173 | |
|
30708
535bec1e66fb
Standardize on "cancelled".
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30691
diff
changeset
|
174 | /* Disable the account as the user has cancelled connecting */ |
|
28860
d2a057cdd7b6
jabber: A little more use of accessors.
Paul Aurich <darkrain42@pidgin.im>
parents:
28859
diff
changeset
|
175 | purple_account_set_enabled(account, purple_core_get_ui(), FALSE); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
176 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
177 | |
|
33805
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
178 | static gboolean remove_current_mech(JabberStream *js) { |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
179 | char *pos; |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
180 | if ((pos = strstr(js->sasl_mechs->str, js->current_mech))) { |
|
35341
f83a8282b45a
Try to fix a signed/unsigned warning
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35053
diff
changeset
|
181 | size_t len = strlen(js->current_mech); |
|
33805
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
182 | /* Clean up space that separated this Mech from the one before or after it */ |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
183 | if (pos > js->sasl_mechs->str && *(pos - 1) == ' ') { |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
184 | /* Handle removing space before when current_mech isn't the first mech in the list */ |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
185 | pos--; |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
186 | len++; |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
187 | } else if (strlen(pos) > len && *(pos + len) == ' ') { |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
188 | /* Handle removing space after */ |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
189 | len++; |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
190 | } |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
191 | g_string_erase(js->sasl_mechs, pos - js->sasl_mechs->str, len); |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
192 | return TRUE; |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
193 | } |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
194 | return FALSE; |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
195 | } |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
196 | |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
197 | static JabberSaslState |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
198 | jabber_auth_start_cyrus(JabberStream *js, PurpleXmlNode **reply, char **error) |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
199 | { |
|
28856
992b7074357d
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents:
28855
diff
changeset
|
200 | PurpleAccount *account; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
201 | const char *clientout = NULL; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
202 | char *enc_out; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
203 | unsigned coutlen = 0; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
204 | sasl_security_properties_t secprops; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
205 | gboolean again; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
206 | gboolean plaintext = TRUE; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
207 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
208 | /* Set up security properties and options */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
209 | secprops.min_ssf = 0; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
210 | secprops.security_flags = SASL_SEC_NOANONYMOUS; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
211 | |
|
28856
992b7074357d
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents:
28855
diff
changeset
|
212 | account = purple_connection_get_account(js->gc); |
|
992b7074357d
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents:
28855
diff
changeset
|
213 | |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
214 | if (!jabber_stream_is_ssl(js)) { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
215 | secprops.max_ssf = -1; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
216 | secprops.maxbufsize = 4096; |
|
28856
992b7074357d
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents:
28855
diff
changeset
|
217 | plaintext = purple_account_get_bool(account, "auth_plain_in_clear", FALSE); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
218 | if (!plaintext) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
219 | secprops.security_flags |= SASL_SEC_NOPLAINTEXT; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
220 | } else { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
221 | secprops.max_ssf = 0; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
222 | secprops.maxbufsize = 0; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
223 | plaintext = TRUE; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
224 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
225 | secprops.property_names = 0; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
226 | secprops.property_values = 0; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
227 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
228 | do { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
229 | again = FALSE; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
230 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
231 | js->sasl_state = sasl_client_new("xmpp", js->serverFQDN, NULL, NULL, js->sasl_cb, 0, &js->sasl); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
232 | if (js->sasl_state==SASL_OK) { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
233 | sasl_setprop(js->sasl, SASL_SEC_PROPS, &secprops); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
234 | purple_debug_info("sasl", "Mechs found: %s\n", js->sasl_mechs->str); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
235 | js->sasl_state = sasl_client_start(js->sasl, js->sasl_mechs->str, NULL, &clientout, &coutlen, &js->current_mech); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
236 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
237 | switch (js->sasl_state) { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
238 | /* Success */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
239 | case SASL_OK: |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
240 | case SASL_CONTINUE: |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
241 | break; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
242 | case SASL_NOMECH: |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
243 | /* No mechanisms have offered to help */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
244 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
245 | /* Firstly, if we don't have a password try |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
246 | * to get one |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
247 | */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
248 | |
|
37646
8f99c1dff72e
Fix jabber password dialog infinite loop with SASL
Jakub Adam <jakub.adam@ktknet.cz>
parents:
36068
diff
changeset
|
249 | if (!js->sasl_password) { |
|
28856
992b7074357d
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents:
28855
diff
changeset
|
250 | purple_account_request_password(account, G_CALLBACK(auth_pass_cb), G_CALLBACK(auth_no_pass_cb), js->gc); |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
251 | return JABBER_SASL_STATE_CONTINUE; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
252 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
253 | /* If we've got a password, but aren't sending |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
254 | * it in plaintext, see if we can turn on |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
255 | * plaintext auth |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
256 | */ |
|
30505
ced16596ce78
jabber: This is more accurate, I think (e.g. Cyrus doesn't know what SCRAM-SHA-1 is)
Paul Aurich <darkrain42@pidgin.im>
parents:
30432
diff
changeset
|
257 | /* XXX Should we just check for PLAIN/LOGIN being offered mechanisms? */ |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
258 | } else if (!plaintext) { |
|
30505
ced16596ce78
jabber: This is more accurate, I think (e.g. Cyrus doesn't know what SCRAM-SHA-1 is)
Paul Aurich <darkrain42@pidgin.im>
parents:
30432
diff
changeset
|
259 | char *msg = g_strdup_printf(_("%s may require plaintext authentication over an unencrypted connection. Allow this and continue authentication?"), |
|
28856
992b7074357d
jabber: Use accessors instead of directly accessing gc->account (and similar)
Paul Aurich <darkrain42@pidgin.im>
parents:
28855
diff
changeset
|
260 | purple_account_get_username(account)); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
261 | purple_request_yes_no(js->gc, _("Plaintext Authentication"), |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
262 | _("Plaintext Authentication"), |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
263 | msg, |
|
34440
83610e0823fb
Win32: fix compilation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34111
diff
changeset
|
264 | 1, purple_request_cpar_from_account(account), account, |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
265 | allow_cyrus_plaintext_auth, |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
266 | disallow_plaintext_auth); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
267 | g_free(msg); |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
268 | return JABBER_SASL_STATE_CONTINUE; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
269 | |
|
30286
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
270 | } else |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
271 | js->auth_fail_count++; |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
272 | |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
273 | if (js->auth_fail_count == 1 && |
|
30431
6969a68a6008
jabber: Make that more future-proof by never generating "GSSAPI "
Paul Aurich <darkrain42@pidgin.im>
parents:
30430
diff
changeset
|
274 | (js->sasl_mechs->str && g_str_equal(js->sasl_mechs->str, "GSSAPI"))) { |
|
30286
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
275 | /* If we tried GSSAPI first, it failed, and it was the only method we had to try, try jabber:iq:auth |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
276 | * for compatibility with iChat 10.5 Server and other jabberd based servers. |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
277 | * |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
278 | * iChat Server 10.5 and certain other corporate servers offer SASL GSSAPI by default, which is often |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
279 | * not configured on the client side, and expects a fallback to jabber:iq:auth when it (predictably) fails. |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
280 | * |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
281 | * Note: xep-0078 points out that using jabber:iq:auth after a sasl failure is wrong. However, |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
282 | * I believe this refers to actual authentication failure, not a simple lack of concordant mechanisms. |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
283 | * Doing otherwise means that simply compiling with SASL support renders the client unable to connect to servers |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
284 | * which would connect without issue otherwise. -evands |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
285 | */ |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
286 | js->auth_mech = NULL; |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
287 | jabber_auth_start_old(js); |
|
30307
6062f0491f3a
jabber: trailing_whitespace--;
Paul Aurich <darkrain42@pidgin.im>
parents:
30301
diff
changeset
|
288 | return JABBER_SASL_STATE_CONTINUE; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
289 | } |
|
30168
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
290 | |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
291 | break; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
292 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
293 | /* Fatal errors. Give up and go home */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
294 | case SASL_BADPARAM: |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
295 | case SASL_NOMEM: |
|
30169
242b3308eda7
If SASL authentication fails, we generally shouldn't be setting an error
Evan Schoenberg <evands@pidgin.im>
parents:
30168
diff
changeset
|
296 | *error = g_strdup(_("SASL authentication failed")); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
297 | break; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
298 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
299 | /* For everything else, fail the mechanism and try again */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
300 | default: |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
301 | purple_debug_info("sasl", "sasl_state is %d, failing the mech and trying again\n", js->sasl_state); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
302 | |
|
30286
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
303 | js->auth_fail_count++; |
|
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
304 | |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
305 | /* |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
306 | * DAA: is this right? |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
307 | * The manpage says that "mech" will contain the chosen mechanism on success. |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
308 | * Presumably, if we get here that isn't the case and we shouldn't try again? |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
309 | * I suspect that this never happens. |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
310 | */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
311 | /* |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
312 | * SXW: Yes, this is right. What this handles is the situation where a |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
313 | * mechanism, say GSSAPI, is tried. If that mechanism fails, it may be |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
314 | * due to mechanism specific issues, so we want to try one of the other |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
315 | * supported mechanisms. This code handles that case |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
316 | */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
317 | if (js->current_mech && *js->current_mech) { |
|
33805
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
318 | remove_current_mech(js); |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
319 | /* Should we only try again if we've removed the mech? */ |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
320 | again = TRUE; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
321 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
322 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
323 | sasl_dispose(&js->sasl); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
324 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
325 | } while (again); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
326 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
327 | if (js->sasl_state == SASL_CONTINUE || js->sasl_state == SASL_OK) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
328 | PurpleXmlNode *auth = purple_xmlnode_new("auth"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
329 | purple_xmlnode_set_namespace(auth, NS_XMPP_SASL); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
330 | purple_xmlnode_set_attrib(auth, "mechanism", js->current_mech); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
331 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
332 | purple_xmlnode_set_attrib(auth, "xmlns:ga", "http://www.google.com/talk/protocol/auth"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
333 | purple_xmlnode_set_attrib(auth, "ga:client-uses-full-bind-result", "true"); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
334 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
335 | if (clientout) { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
336 | if (coutlen == 0) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
337 | purple_xmlnode_insert_data(auth, "=", -1); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
338 | } else { |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
37646
diff
changeset
|
339 | enc_out = g_base64_encode((unsigned char*)clientout, coutlen); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
340 | purple_xmlnode_insert_data(auth, enc_out, -1); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
341 | g_free(enc_out); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
342 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
343 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
344 | |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
345 | *reply = auth; |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
346 | return JABBER_SASL_STATE_CONTINUE; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
347 | } else { |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
348 | return JABBER_SASL_STATE_FAIL; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
349 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
350 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
351 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
352 | static int |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
353 | jabber_sasl_cb_log(void *context, int level, const char *message) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
354 | { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
355 | if(level <= SASL_LOG_TRACE) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
356 | purple_debug_info("sasl", "%s\n", message); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
357 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
358 | return SASL_OK; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
359 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
360 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
361 | static void |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
362 | jabber_sasl_build_callbacks(JabberStream *js) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
363 | { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
364 | int id; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
365 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
366 | /* Set up our callbacks structure */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
367 | if (js->sasl_cb == NULL) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
368 | js->sasl_cb = g_new0(sasl_callback_t,6); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
369 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
370 | id = 0; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
371 | js->sasl_cb[id].id = SASL_CB_GETREALM; |
|
32784
434afaa6059f
jabber: Fix some compile warnings in auth_cyrus.c
Paul Aurich <darkrain42@pidgin.im>
parents:
32157
diff
changeset
|
372 | js->sasl_cb[id].proc = (void *)jabber_sasl_cb_realm; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
373 | js->sasl_cb[id].context = (void *)js; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
374 | id++; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
375 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
376 | js->sasl_cb[id].id = SASL_CB_AUTHNAME; |
|
32784
434afaa6059f
jabber: Fix some compile warnings in auth_cyrus.c
Paul Aurich <darkrain42@pidgin.im>
parents:
32157
diff
changeset
|
377 | js->sasl_cb[id].proc = (void *)jabber_sasl_cb_simple; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
378 | js->sasl_cb[id].context = (void *)js; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
379 | id++; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
380 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
381 | js->sasl_cb[id].id = SASL_CB_USER; |
|
32784
434afaa6059f
jabber: Fix some compile warnings in auth_cyrus.c
Paul Aurich <darkrain42@pidgin.im>
parents:
32157
diff
changeset
|
382 | js->sasl_cb[id].proc = (void *)jabber_sasl_cb_simple; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
383 | js->sasl_cb[id].context = (void *)js; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
384 | id++; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
385 | |
|
37646
8f99c1dff72e
Fix jabber password dialog infinite loop with SASL
Jakub Adam <jakub.adam@ktknet.cz>
parents:
36068
diff
changeset
|
386 | if (js->sasl_password != NULL) { |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
387 | js->sasl_cb[id].id = SASL_CB_PASS; |
|
32784
434afaa6059f
jabber: Fix some compile warnings in auth_cyrus.c
Paul Aurich <darkrain42@pidgin.im>
parents:
32157
diff
changeset
|
388 | js->sasl_cb[id].proc = (void *)jabber_sasl_cb_secret; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
389 | js->sasl_cb[id].context = (void *)js; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
390 | id++; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
391 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
392 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
393 | js->sasl_cb[id].id = SASL_CB_LOG; |
|
32784
434afaa6059f
jabber: Fix some compile warnings in auth_cyrus.c
Paul Aurich <darkrain42@pidgin.im>
parents:
32157
diff
changeset
|
394 | js->sasl_cb[id].proc = (void *)jabber_sasl_cb_log; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
395 | js->sasl_cb[id].context = (void*)js; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
396 | id++; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
397 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
398 | js->sasl_cb[id].id = SASL_CB_LIST_END; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
399 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
400 | |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
401 | static JabberSaslState |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
402 | jabber_cyrus_start(JabberStream *js, PurpleXmlNode *mechanisms, |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
403 | PurpleXmlNode **reply, char **error) |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
404 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
405 | PurpleXmlNode *mechnode; |
|
30300
68e7a5c173ac
jabber: Better error message when no concordant SASL mechs
Paul Aurich <darkrain42@pidgin.im>
parents:
30286
diff
changeset
|
406 | JabberSaslState ret; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
407 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
408 | js->sasl_mechs = g_string_new(""); |
|
37646
8f99c1dff72e
Fix jabber password dialog infinite loop with SASL
Jakub Adam <jakub.adam@ktknet.cz>
parents:
36068
diff
changeset
|
409 | js->sasl_password = g_strdup(purple_connection_get_password(js->gc)); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
410 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
411 | for(mechnode = purple_xmlnode_get_child(mechanisms, "mechanism"); mechnode; |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
412 | mechnode = purple_xmlnode_get_next_twin(mechnode)) |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
413 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
414 | char *mech_name = purple_xmlnode_get_data(mechnode); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
415 | |
|
30432
dee4a4fe8cbc
jabber: Document the other cyrus hack (ignoring EXTERNAL)
Paul Aurich <darkrain42@pidgin.im>
parents:
30431
diff
changeset
|
416 | /* Ignore blank mechanisms and EXTERNAL. External isn't |
|
dee4a4fe8cbc
jabber: Document the other cyrus hack (ignoring EXTERNAL)
Paul Aurich <darkrain42@pidgin.im>
parents:
30431
diff
changeset
|
417 | * supported, and Cyrus SASL's mechanism returns |
|
dee4a4fe8cbc
jabber: Document the other cyrus hack (ignoring EXTERNAL)
Paul Aurich <darkrain42@pidgin.im>
parents:
30431
diff
changeset
|
418 | * SASL_NOMECH when the caller (us) doesn't configure it. |
|
dee4a4fe8cbc
jabber: Document the other cyrus hack (ignoring EXTERNAL)
Paul Aurich <darkrain42@pidgin.im>
parents:
30431
diff
changeset
|
419 | * Except SASL_NOMECH is supposed to mean "no concordant |
|
dee4a4fe8cbc
jabber: Document the other cyrus hack (ignoring EXTERNAL)
Paul Aurich <darkrain42@pidgin.im>
parents:
30431
diff
changeset
|
420 | * mechanisms"... Easiest just to blacklist it (for now). |
|
dee4a4fe8cbc
jabber: Document the other cyrus hack (ignoring EXTERNAL)
Paul Aurich <darkrain42@pidgin.im>
parents:
30431
diff
changeset
|
421 | */ |
|
30308
81f840e2f9c7
jabber: Blacklist EXTERNAL when using Cyrus. Allows connecting when it's advertised.
Paul Aurich <darkrain42@pidgin.im>
parents:
30307
diff
changeset
|
422 | if (!mech_name || !*mech_name || |
|
81f840e2f9c7
jabber: Blacklist EXTERNAL when using Cyrus. Allows connecting when it's advertised.
Paul Aurich <darkrain42@pidgin.im>
parents:
30307
diff
changeset
|
423 | g_str_equal(mech_name, "EXTERNAL")) { |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
424 | g_free(mech_name); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
425 | continue; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
426 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
427 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
428 | g_string_append(js->sasl_mechs, mech_name); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
429 | g_string_append_c(js->sasl_mechs, ' '); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
430 | g_free(mech_name); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
431 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
432 | |
|
30431
6969a68a6008
jabber: Make that more future-proof by never generating "GSSAPI "
Paul Aurich <darkrain42@pidgin.im>
parents:
30430
diff
changeset
|
433 | /* Strip off the trailing ' ' */ |
|
6969a68a6008
jabber: Make that more future-proof by never generating "GSSAPI "
Paul Aurich <darkrain42@pidgin.im>
parents:
30430
diff
changeset
|
434 | if (js->sasl_mechs->len > 1) |
|
6969a68a6008
jabber: Make that more future-proof by never generating "GSSAPI "
Paul Aurich <darkrain42@pidgin.im>
parents:
30430
diff
changeset
|
435 | g_string_truncate(js->sasl_mechs, js->sasl_mechs->len - 1); |
|
6969a68a6008
jabber: Make that more future-proof by never generating "GSSAPI "
Paul Aurich <darkrain42@pidgin.im>
parents:
30430
diff
changeset
|
436 | |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
437 | jabber_sasl_build_callbacks(js); |
|
30300
68e7a5c173ac
jabber: Better error message when no concordant SASL mechs
Paul Aurich <darkrain42@pidgin.im>
parents:
30286
diff
changeset
|
438 | ret = jabber_auth_start_cyrus(js, reply, error); |
|
68e7a5c173ac
jabber: Better error message when no concordant SASL mechs
Paul Aurich <darkrain42@pidgin.im>
parents:
30286
diff
changeset
|
439 | |
|
68e7a5c173ac
jabber: Better error message when no concordant SASL mechs
Paul Aurich <darkrain42@pidgin.im>
parents:
30286
diff
changeset
|
440 | /* |
|
68e7a5c173ac
jabber: Better error message when no concordant SASL mechs
Paul Aurich <darkrain42@pidgin.im>
parents:
30286
diff
changeset
|
441 | * Triggered if no overlap between server and client |
|
68e7a5c173ac
jabber: Better error message when no concordant SASL mechs
Paul Aurich <darkrain42@pidgin.im>
parents:
30286
diff
changeset
|
442 | * supported mechanisms. |
|
68e7a5c173ac
jabber: Better error message when no concordant SASL mechs
Paul Aurich <darkrain42@pidgin.im>
parents:
30286
diff
changeset
|
443 | */ |
|
68e7a5c173ac
jabber: Better error message when no concordant SASL mechs
Paul Aurich <darkrain42@pidgin.im>
parents:
30286
diff
changeset
|
444 | if (ret == JABBER_SASL_STATE_FAIL && *error == NULL) |
|
30301
1650ca6b434c
jabber: Found a better string in auth.c
Paul Aurich <darkrain42@pidgin.im>
parents:
30300
diff
changeset
|
445 | *error = g_strdup(_("Server does not use any supported authentication method")); |
|
30300
68e7a5c173ac
jabber: Better error message when no concordant SASL mechs
Paul Aurich <darkrain42@pidgin.im>
parents:
30286
diff
changeset
|
446 | |
|
68e7a5c173ac
jabber: Better error message when no concordant SASL mechs
Paul Aurich <darkrain42@pidgin.im>
parents:
30286
diff
changeset
|
447 | return ret; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
448 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
449 | |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
450 | static JabberSaslState |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
451 | jabber_cyrus_handle_challenge(JabberStream *js, PurpleXmlNode *packet, |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
452 | PurpleXmlNode **reply, char **error) |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
453 | { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
454 | char *enc_in = purple_xmlnode_get_data(packet); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
455 | unsigned char *dec_in; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
456 | char *enc_out; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
457 | const char *c_out; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
458 | unsigned int clen; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
459 | gsize declen; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
460 | |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
37646
diff
changeset
|
461 | dec_in = g_base64_decode(enc_in, &declen); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
462 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
463 | js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen, |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
464 | NULL, &c_out, &clen); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
465 | g_free(enc_in); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
466 | g_free(dec_in); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
467 | if (js->sasl_state != SASL_CONTINUE && js->sasl_state != SASL_OK) { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
468 | gchar *tmp = g_strdup_printf(_("SASL error: %s"), |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
469 | sasl_errdetail(js->sasl)); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
470 | purple_debug_error("jabber", "Error is %d : %s\n", |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
471 | js->sasl_state, sasl_errdetail(js->sasl)); |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
472 | *error = tmp; |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
473 | return JABBER_SASL_STATE_FAIL; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
474 | } else { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
475 | PurpleXmlNode *response = purple_xmlnode_new("response"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
476 | purple_xmlnode_set_namespace(response, NS_XMPP_SASL); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
477 | if (clen > 0) { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
478 | /* Cyrus SASL 2.1.22 appears to contain code to add the charset |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
479 | * to the response for DIGEST-MD5 but there is no possibility |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
480 | * it will be executed. |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
481 | * |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
482 | * My reading of the digestmd5 plugin indicates the username and |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
483 | * realm are always encoded in UTF-8 (they seem to be the values |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
484 | * we pass in), so we need to ensure charset=utf-8 is set. |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
485 | */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
486 | if (!purple_strequal(js->current_mech, "DIGEST-MD5") || |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
487 | strstr(c_out, ",charset=")) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
488 | /* If we're not using DIGEST-MD5 or Cyrus SASL is fixed */ |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
37646
diff
changeset
|
489 | enc_out = g_base64_encode((unsigned char*)c_out, clen); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
490 | else { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
491 | char *tmp = g_strdup_printf("%s,charset=utf-8", c_out); |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
37646
diff
changeset
|
492 | enc_out = g_base64_encode((unsigned char*)tmp, clen + 14); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
493 | g_free(tmp); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
494 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
495 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
496 | purple_xmlnode_insert_data(response, enc_out, -1); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
497 | g_free(enc_out); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
498 | } |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
499 | |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
500 | *reply = response; |
|
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
501 | return JABBER_SASL_STATE_CONTINUE; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
502 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
503 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
504 | |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
505 | static JabberSaslState |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
506 | jabber_cyrus_handle_success(JabberStream *js, PurpleXmlNode *packet, |
|
29090
b351fcdeede7
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents:
29089
diff
changeset
|
507 | char **error) |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
508 | { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
509 | const void *x; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
510 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
511 | /* The SASL docs say that if the client hasn't returned OK yet, we |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
512 | * should try one more round against it |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
513 | */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
514 | if (js->sasl_state != SASL_OK) { |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
515 | char *enc_in = purple_xmlnode_get_data(packet); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
516 | unsigned char *dec_in = NULL; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
517 | const char *c_out; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
518 | unsigned int clen; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
519 | gsize declen = 0; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
520 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
521 | if(enc_in != NULL) |
|
38341
3da74e727e78
Remove purple_base64_encode/decode() wrappers
Mike Ruprecht <cmaiku@gmail.com>
parents:
37646
diff
changeset
|
522 | dec_in = g_base64_decode(enc_in, &declen); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
523 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
524 | js->sasl_state = sasl_client_step(js->sasl, (char*)dec_in, declen, NULL, &c_out, &clen); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
525 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
526 | g_free(enc_in); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
527 | g_free(dec_in); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
528 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
529 | if (js->sasl_state != SASL_OK) { |
|
31364
cd03a947eaf0
jabber: Un-assert-ify one failure case in the Cyrus code.
Paul Aurich <darkrain42@pidgin.im>
parents:
30807
diff
changeset
|
530 | /* This happens when the server sends back jibberish |
|
cd03a947eaf0
jabber: Un-assert-ify one failure case in the Cyrus code.
Paul Aurich <darkrain42@pidgin.im>
parents:
30807
diff
changeset
|
531 | * in the "additional data with success" case. |
|
cd03a947eaf0
jabber: Un-assert-ify one failure case in the Cyrus code.
Paul Aurich <darkrain42@pidgin.im>
parents:
30807
diff
changeset
|
532 | * Seen with Wildfire 3.0.1. |
|
cd03a947eaf0
jabber: Un-assert-ify one failure case in the Cyrus code.
Paul Aurich <darkrain42@pidgin.im>
parents:
30807
diff
changeset
|
533 | */ |
|
29090
b351fcdeede7
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
Paul Aurich <darkrain42@pidgin.im>
parents:
29089
diff
changeset
|
534 | *error = g_strdup(_("Invalid response from server")); |
|
31364
cd03a947eaf0
jabber: Un-assert-ify one failure case in the Cyrus code.
Paul Aurich <darkrain42@pidgin.im>
parents:
30807
diff
changeset
|
535 | return JABBER_SASL_STATE_FAIL; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
536 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
537 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
538 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
539 | /* If we've negotiated a security layer, we need to enable it */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
540 | if (js->sasl) { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
541 | sasl_getprop(js->sasl, SASL_SSF, &x); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
542 | if (*(int *)x > 0) { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
543 | sasl_getprop(js->sasl, SASL_MAXOUTBUF, &x); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
544 | js->sasl_maxbuf = *(int *)x; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
545 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
546 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
547 | |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
548 | return JABBER_SASL_STATE_OK; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
549 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
550 | |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
551 | static JabberSaslState |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
552 | jabber_cyrus_handle_failure(JabberStream *js, PurpleXmlNode *packet, |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
34111
diff
changeset
|
553 | PurpleXmlNode **reply, char **error) |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
554 | { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
555 | if (js->auth_fail_count++ < 5) { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
556 | if (js->current_mech && *js->current_mech) { |
|
33805
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
557 | remove_current_mech(js); |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
558 | } |
|
33805
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
559 | |
|
da201c4757d8
jabber: Correctly remove a failed SASL mech when it isn't the first in the list
Daniel Atallah <datallah@pidgin.im>
parents:
31804
diff
changeset
|
560 | /* Should we only try again if we've actually removed a mech? */ |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
561 | if (*js->sasl_mechs->str) { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
562 | /* If we have remaining mechs to try, do so */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
563 | sasl_dispose(&js->sasl); |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
564 | |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
565 | return jabber_auth_start_cyrus(js, reply, error); |
|
30168
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
566 | |
|
30308
81f840e2f9c7
jabber: Blacklist EXTERNAL when using Cyrus. Allows connecting when it's advertised.
Paul Aurich <darkrain42@pidgin.im>
parents:
30307
diff
changeset
|
567 | } else if ((js->auth_fail_count == 1) && |
|
30168
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
568 | (js->current_mech && g_str_equal(js->current_mech, "GSSAPI"))) { |
|
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
569 | /* If we tried GSSAPI first, it failed, and it was the only method we had to try, try jabber:iq:auth |
|
30286
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
570 | * for compatibility with iChat 10.5 Server and other jabberd based servers. |
|
30168
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
571 | * |
|
30286
270c63ba1f8f
applied changes from bf4b720f9231b395fb51bf1e27440328d46bceb5
Evan Schoenberg <evands@pidgin.im>
parents:
30173
diff
changeset
|
572 | * iChat Server 10.5 and certain other corporate servers offer SASL GSSAPI by default, which is often |
|
30168
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
573 | * not configured on the client side, and expects a fallback to jabber:iq:auth when it (predictably) fails. |
|
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
574 | * |
|
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
575 | * Note: xep-0078 points out that using jabber:iq:auth after a sasl failure is wrong. However, |
|
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
576 | * I believe this refers to actual authentication failure, not a simple lack of concordant mechanisms. |
|
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
577 | * Doing otherwise means that simply compiling with SASL support renders the client unable to connect to servers |
|
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
578 | * which would connect without issue otherwise. -evands |
|
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
579 | */ |
|
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
580 | sasl_dispose(&js->sasl); |
|
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
581 | js->sasl = NULL; |
|
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
582 | js->auth_mech = NULL; |
|
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
583 | jabber_auth_start_old(js); |
|
ff3cae005cb5
Improve on a hack I commited in 12/2007 which allows connection via XMPP to iChat Server 10.5 when CYRUS-SASL is compiled with GSSAPI support but no GSSAPI credentials are valid to connect to the server. Instead of always trying jabber:iq:auth if all SASL mechs fail, we now only do so in the specific case of a single mech having been attempted and that mech being GSSAPI. In general, this means that we now gracefully fail authentication with SASL rather than getting ourselves booted from servers not expecting a jabber:iq:auth stanza.
Evan Schoenberg <evands@pidgin.im>
parents:
30151
diff
changeset
|
584 | return JABBER_SASL_STATE_CONTINUE; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
585 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
586 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
587 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
588 | /* Nothing to send */ |
|
29089
c2fee5c11127
jabber: Fix up the cyrus auth code (although there's a leak currently)
Paul Aurich <darkrain42@pidgin.im>
parents:
29008
diff
changeset
|
589 | return JABBER_SASL_STATE_FAIL; |
|
28855
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
590 | } |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
591 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
592 | static JabberSaslMech cyrus_mech = { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
593 | 100, /* priority */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
594 | "*", /* name; Cyrus provides a bunch of mechanisms, so use an invalid |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
595 | * mechanism name (per rfc4422 3.1). */ |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
596 | jabber_cyrus_start, |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
597 | jabber_cyrus_handle_challenge, |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
598 | jabber_cyrus_handle_success, |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
599 | jabber_cyrus_handle_failure, |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
600 | NULL, |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
601 | }; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
602 | |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
603 | JabberSaslMech *jabber_auth_get_cyrus_mech(void) |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
604 | { |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
605 | return &cyrus_mech; |
|
c5bc85f9c00e
jabber: Factor the SASL auth methods into their own files.
Paul Aurich <darkrain42@pidgin.im>
parents:
diff
changeset
|
606 | } |