Thu, 02 Nov 2023 23:38:51 -0500
Add symbol visibility on IRCv3 protocol plugin
This only adds visibility to things that have `Since: 3.0.0` _and_ are not already tagged with `G_GNUC_INTERNAL`.
It also assumes that the version is the same as libpurple, but that 3.0 is the minimum instead of 2.0, so everything is `PURPLE_IRCV3_AVAILABLE_IN_ALL`.
Testing Done:
Compiled on Linux and Windows.
Bugs closed: PIDGIN-17840
Reviewed at https://reviews.imfreedom.org/r/2773/
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * This program is free software; you can redistribute it and/or modify |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation; either version 2 of the License, or |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | #include <glib/gi18n-lib.h> |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
21 | #include <hasl.h> |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #include "purpleircv3sasl.h" |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | #include "purpleircv3capabilities.h" |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | #include "purpleircv3connection.h" |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include "purpleircv3core.h" |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | #define PURPLE_IRCV3_SASL_DATA_KEY ("sasl-data") |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | typedef struct { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | PurpleConnection *connection; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
34 | HaslContext *ctx; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | GString *server_in_buffer; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | } PurpleIRCv3SASLData; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | /****************************************************************************** |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | * Helpers |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | *****************************************************************************/ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | static const char * |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | purple_ircv3_sasl_get_username(PurpleConnection *connection) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | PurpleAccount *account = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | const char *username = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | account = purple_connection_get_account(connection); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | username = purple_account_get_string(account, "sasl-login-name", ""); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | if(username != NULL && username[0] != '\0') { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | return username; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | return purple_connection_get_display_name(connection); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | /****************************************************************************** |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | * SASL Helpers |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | *****************************************************************************/ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | static void |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | purple_ircv3_sasl_data_free(PurpleIRCv3SASLData *data) { |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
62 | g_clear_object(&data->ctx); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | |
|
42045
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
64 | g_string_free(data->server_in_buffer, TRUE); |
|
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
65 | |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | g_free(data); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | static void |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
70 | purple_ircv3_sasl_data_add(PurpleConnection *connection, HaslContext *ctx) { |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | PurpleIRCv3SASLData *data = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | data = g_new0(PurpleIRCv3SASLData, 1); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | g_object_set_data_full(G_OBJECT(connection), PURPLE_IRCV3_SASL_DATA_KEY, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | data, (GDestroyNotify)purple_ircv3_sasl_data_free); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | /* We don't reference this because the life cycle of this data is tied |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | * directly to the connection and adding a reference to the connection |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | * would keep both alive forever. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
80 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | data->connection = connection; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | data->ctx = ctx; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
83 | |
|
42045
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
84 | /* We truncate the server_in_buffer when we need to so that we can minimize |
|
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
85 | * allocations and simplify the logic involved with it. |
|
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
86 | */ |
|
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
87 | data->server_in_buffer = g_string_new(""); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | static void |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | purple_ircv3_sasl_attempt(PurpleIRCv3Connection *connection) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | PurpleIRCv3SASLData *data = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | const char *next_mechanism = NULL; |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
94 | const char *current = NULL; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | data = g_object_get_data(G_OBJECT(connection), PURPLE_IRCV3_SASL_DATA_KEY); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
98 | current = hasl_context_get_current_mechanism(data->ctx); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
99 | if(current != NULL) { |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
100 | g_message("SASL '%s' mechanism failed", current); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
103 | next_mechanism = hasl_context_next(data->ctx); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
104 | if(next_mechanism == NULL) { |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
105 | GError *error = g_error_new(PURPLE_CONNECTION_ERROR, |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
106 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
107 | _("No valid SASL mechanisms found")); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
109 | purple_connection_take_error(PURPLE_CONNECTION(connection), error); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
111 | return; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | g_message("trying SASL '%s' mechanism", next_mechanism); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
116 | purple_ircv3_connection_writef(connection, "AUTHENTICATE %s", |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
117 | next_mechanism); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | static void |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | purple_ircv3_sasl_start(PurpleIRCv3Capabilities *caps) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | PurpleIRCv3Connection *connection = NULL; |
|
42044
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
123 | PurpleAccount *account = NULL; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | PurpleConnection *purple_connection = NULL; |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
125 | HaslContext *ctx = NULL; |
|
42044
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
126 | const char *mechanisms = NULL; |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
127 | gboolean toggle = FALSE; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | connection = purple_ircv3_capabilities_get_connection(caps); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | purple_connection = PURPLE_CONNECTION(connection); |
|
42044
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
131 | account = purple_connection_get_account(purple_connection); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
133 | ctx = hasl_context_new(); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
135 | /* At this point we are ready to start our SASL negotiation, so add a wait |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | * counter to the capabilities and start the negotiations! |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | purple_ircv3_capabilities_add_wait(caps); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
140 | /* Determine what mechanisms we're allowing and tell the context. */ |
|
42044
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
141 | mechanisms = purple_account_get_string(account, "sasl-mechanisms", ""); |
|
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
142 | if(purple_strempty(mechanisms)) { |
|
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
143 | /* If the user didn't specify any mechanisms, grab the mechanisms that |
|
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
144 | * the server advertised. |
|
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
145 | */ |
|
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
146 | mechanisms = purple_ircv3_capabilities_lookup(caps, "sasl", NULL); |
|
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
147 | } |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
148 | hasl_context_set_allowed_mechanisms(ctx, mechanisms); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
149 | |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
150 | /* Add the values we know to the context. */ |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
151 | hasl_context_set_username(ctx, purple_ircv3_sasl_get_username(purple_connection)); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
152 | hasl_context_set_password(ctx, purple_connection_get_password(purple_connection)); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
153 | |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
154 | toggle = purple_account_get_bool(account, "use-tls", TRUE); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
155 | hasl_context_set_tls(ctx, toggle); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
156 | |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
157 | toggle = purple_account_get_bool(account, "plain-sasl-in-clear", FALSE); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
158 | hasl_context_set_allow_clear_text(ctx, toggle); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | /* Create our SASLData object, add it to the connection. */ |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
161 | purple_ircv3_sasl_data_add(purple_connection, ctx); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | /* Make it go! */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | purple_ircv3_sasl_attempt(connection); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | /****************************************************************************** |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | * Callbacks |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | *****************************************************************************/ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | static void |
|
42040
86284f7119e1
IRCv3: Add detail to the ack and nak signals for PurpleIRCv3Capabilities
Gary Kramlich <grim@reaperworld.com>
parents:
42027
diff
changeset
|
171 | purple_ircv3_sasl_ack_cb(PurpleIRCv3Capabilities *caps, |
|
86284f7119e1
IRCv3: Add detail to the ack and nak signals for PurpleIRCv3Capabilities
Gary Kramlich <grim@reaperworld.com>
parents:
42027
diff
changeset
|
172 | G_GNUC_UNUSED const char *capability, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | G_GNUC_UNUSED gpointer data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | purple_ircv3_sasl_start(caps); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | /****************************************************************************** |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | * Internal API |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | *****************************************************************************/ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | void |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | purple_ircv3_sasl_request(PurpleIRCv3Capabilities *capabilities) { |
|
42287
8fc84ffcdcb2
IRCv3: Use constants for capability names
Gary Kramlich <grim@reaperworld.com>
parents:
42271
diff
changeset
|
183 | purple_ircv3_capabilities_request(capabilities, |
|
8fc84ffcdcb2
IRCv3: Use constants for capability names
Gary Kramlich <grim@reaperworld.com>
parents:
42271
diff
changeset
|
184 | PURPLE_IRCV3_CAPABILITY_SASL); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | |
|
42287
8fc84ffcdcb2
IRCv3: Use constants for capability names
Gary Kramlich <grim@reaperworld.com>
parents:
42271
diff
changeset
|
186 | g_signal_connect(capabilities, "ack::" PURPLE_IRCV3_CAPABILITY_SASL, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | G_CALLBACK(purple_ircv3_sasl_ack_cb), NULL); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
191 | purple_ircv3_sasl_logged_in(G_GNUC_UNUSED PurpleIRCv3Message *message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | PurpleIRCv3SASLData *data = NULL; |
|
42271
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
197 | PurpleAccount *account = NULL; |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
198 | const char *sasl_name = NULL; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | data = g_object_get_data(G_OBJECT(connection), PURPLE_IRCV3_SASL_DATA_KEY); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | "RPL_LOGGEDIN received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
208 | |
|
42271
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
209 | /* Check if the SASL login name is not set. If it is not set, set it to the |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
210 | * current nick as it was successful. |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | */ |
|
42271
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
212 | account = purple_connection_get_account(PURPLE_CONNECTION(connection)); |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
213 | sasl_name = purple_account_get_string(account, "sasl-login-name", ""); |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
214 | if(purple_strempty(sasl_name)) { |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
215 | char **userparts = NULL; |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
216 | const char *username = NULL; |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
217 | |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
218 | username = purple_contact_info_get_username(PURPLE_CONTACT_INFO(account)); |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
219 | userparts = g_strsplit(username, "@", 2); |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
220 | |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
221 | purple_account_set_string(account, "sasl-login-name", userparts[0]); |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
222 | |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
223 | g_strfreev(userparts); |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
224 | } |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | return TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
230 | purple_ircv3_sasl_logged_out(G_GNUC_UNUSED PurpleIRCv3Message *message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | PurpleIRCv3SASLData *data = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | data = g_object_get_data(G_OBJECT(connection), PURPLE_IRCV3_SASL_DATA_KEY); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
240 | "RPL_LOGGEDOUT received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
242 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
244 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
245 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | /* Not sure how to trigger this or what we should do in this case to be |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | * honest, so just note it for now. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
248 | * -- GK 2023-01-12 |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | g_warning("Server sent SASL logged out"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
251 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
252 | return TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
253 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
256 | purple_ircv3_sasl_nick_locked(PurpleIRCv3Message *v3_message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
259 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | PurpleIRCv3SASLData *data = NULL; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
262 | GStrv params = NULL; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | char *message = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | data = g_object_get_data(G_OBJECT(connection), PURPLE_IRCV3_SASL_DATA_KEY); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
268 | "ERR_NICKLOCKED received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
271 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
272 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
274 | params = purple_ircv3_message_get_params(v3_message); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | message = g_strjoinv(" ", params); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | g_set_error(error, PURPLE_CONNECTION_ERROR, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | _("Nick name is locked: %s"), message); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
280 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | g_free(message); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
282 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
283 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
286 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
287 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
288 | purple_ircv3_sasl_success(G_GNUC_UNUSED PurpleIRCv3Message *message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
292 | PurpleIRCv3Capabilities *capabilities = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
293 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
294 | PurpleIRCv3SASLData *data = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
295 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
296 | capabilities = purple_ircv3_connection_get_capabilities(connection); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
297 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
298 | data = g_object_get_data(G_OBJECT(connection), PURPLE_IRCV3_SASL_DATA_KEY); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
299 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
300 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
301 | "RPL_SASLSUCCESS received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
302 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
303 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
304 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
305 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
306 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | /* This needs to be after we've checked the SASL data otherwise we might |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | * end up removing a wait that we don't own. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
310 | purple_ircv3_capabilities_remove_wait(capabilities); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
311 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
312 | g_message("successfully authenticated with SASL '%s' mechanism.", |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
313 | hasl_context_get_current_mechanism(data->ctx)); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | return TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
316 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
317 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
318 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
319 | purple_ircv3_sasl_failed(G_GNUC_UNUSED PurpleIRCv3Message *message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
320 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
322 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
323 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | PurpleIRCv3SASLData *data = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
325 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | data = g_object_get_data(G_OBJECT(connection), PURPLE_IRCV3_SASL_DATA_KEY); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
328 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | "ERR_SASLFAIL received with no SASL data present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
332 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | purple_ircv3_sasl_attempt(connection); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
336 | return TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
337 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
338 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
339 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
340 | purple_ircv3_sasl_message_too_long(G_GNUC_UNUSED PurpleIRCv3Message *message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
344 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | PurpleIRCv3SASLData *data = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
346 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | data = g_object_get_data(G_OBJECT(connection), PURPLE_IRCV3_SASL_DATA_KEY); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
348 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
350 | "ERR_SASLTOOLONG received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
352 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
353 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
354 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
355 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
356 | return TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
358 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
359 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
360 | purple_ircv3_sasl_aborted(G_GNUC_UNUSED PurpleIRCv3Message *message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
362 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
363 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
364 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
365 | PurpleIRCv3SASLData *data = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
366 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
367 | data = g_object_get_data(G_OBJECT(connection), PURPLE_IRCV3_SASL_DATA_KEY); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
368 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
369 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
370 | "ERR_SASLABORTED received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
371 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
372 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
373 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
374 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
375 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
376 | /* This is supposed to get sent, when the client sends `AUTHENTICATE *`, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
377 | * but we don't do this, so I guess we'll note it for now...? |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
378 | * --GK 2023-01-12 |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
379 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
380 | g_warning("The server claims we aborted SASL authentication."); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
381 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
382 | return TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
383 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
384 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
385 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
386 | purple_ircv3_sasl_already_authed(G_GNUC_UNUSED PurpleIRCv3Message *message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
387 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
388 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
389 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
390 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
391 | PurpleIRCv3SASLData *data = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
392 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
393 | data = g_object_get_data(G_OBJECT(connection), PURPLE_IRCV3_SASL_DATA_KEY); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
394 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
395 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
396 | "ERR_SASLALREADY received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
397 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
398 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
399 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
400 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
401 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
402 | /* Similar to aborted above, we don't allow this, so just note that it |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
403 | * happened. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
404 | * -- GK 2023-01-12 |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
405 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
406 | g_warning("Server claims we tried to SASL authenticate again."); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
407 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
408 | return TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
409 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
410 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
411 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
412 | purple_ircv3_sasl_mechanisms(PurpleIRCv3Message *message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
413 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
414 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
415 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
416 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
417 | PurpleIRCv3SASLData *data = NULL; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
418 | GStrv params = NULL; |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
419 | guint n_params = 0; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
420 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
421 | data = g_object_get_data(G_OBJECT(connection), PURPLE_IRCV3_SASL_DATA_KEY); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
422 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
423 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
424 | "RPL_SASLMECHS received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
425 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
426 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
427 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
428 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
429 | |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
430 | params = purple_ircv3_message_get_params(message); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
431 | if(params != NULL) { |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
432 | n_params = g_strv_length(params); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
433 | } |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
434 | |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
435 | /* We need to find a server that sends this message. The specification says |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
436 | * it _may_ be sent when the client sends AUTHENTICATE with an unknown |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
437 | * mechanism, but ergo doesn't. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
438 | * |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
439 | * We can't just blindly accept the new list either, as depending on how |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
440 | * the server implements it, we'll need to remove mechanisms we've already |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
441 | * tried in the event the server just dumps the entire list. As we're not |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
442 | * currently tracking which mechanisms we've tried, this will have to be |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
443 | * addressed as well. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
444 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
445 | if(n_params > 0) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
446 | char *message = g_strjoinv(" ", params); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
447 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
448 | g_message("Server sent the following SASL mechanisms: %s", message); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
449 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
450 | g_free(message); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
451 | } else { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
452 | g_message("Server sent an empty list of SASL mechanisms"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
453 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
454 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
455 | return TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
456 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
457 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
458 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
459 | purple_ircv3_sasl_authenticate(PurpleIRCv3Message *message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
460 | GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
461 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
462 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
463 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
464 | PurpleIRCv3SASLData *data = NULL; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
465 | GStrv params = NULL; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
466 | char *payload = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
467 | gboolean done = FALSE; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
468 | guint n_params = 0; |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
469 | |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
470 | params = purple_ircv3_message_get_params(message); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
471 | if(params != NULL) { |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
472 | n_params = g_strv_length(params); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
473 | } |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
474 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
475 | if(n_params != 1) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
476 | g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
477 | "ignoring AUTHENTICATE with %d parameters", n_params); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
478 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
479 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
480 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
481 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
482 | payload = params[0]; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
483 | data = g_object_get_data(G_OBJECT(connection), PURPLE_IRCV3_SASL_DATA_KEY); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
484 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
485 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
486 | "AUTHENTICATE received with no SASL data present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
487 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
488 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
489 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
490 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
491 | /* If the server sent us a payload, combine the chunks. */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
492 | if(payload[0] != '+') { |
|
42045
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
493 | g_string_append(data->server_in_buffer, payload); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
494 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
495 | if(strlen(payload) < 400) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
496 | done = TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
497 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
498 | } else { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
499 | /* The server sent a + which is an empty message or the final message |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
500 | * ended on a 400 byte barrier. */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
501 | done = TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
502 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
503 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
504 | if(done) { |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
505 | HaslMechanismResult res = 0; |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
506 | GError *local_error = NULL; |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
507 | guint8 *server_in = NULL; |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
508 | guint8 *client_out = NULL; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
509 | gsize server_in_length = 0; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
510 | size_t client_out_length = 0; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
511 | |
|
42045
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
512 | /* If we have a buffer, base64 decode it, and then truncate it. */ |
|
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
513 | if(data->server_in_buffer->len > 0) { |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
514 | server_in = g_base64_decode(data->server_in_buffer->str, |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
515 | &server_in_length); |
|
42045
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
516 | g_string_truncate(data->server_in_buffer, 0); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
517 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
518 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
519 | /* Try to move to the next step of the sasl client. */ |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
520 | res = hasl_context_step(data->ctx, server_in, server_in_length, |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
521 | &client_out, &client_out_length, &local_error); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
522 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
523 | /* We should be done with server_in, so free it.*/ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
524 | g_clear_pointer(&server_in, g_free); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
525 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
526 | if(res == HASL_MECHANISM_RESULT_ERROR) { |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
527 | g_propagate_error(error, local_error); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
528 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
529 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
530 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
531 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
532 | if(local_error != NULL) { |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
533 | g_warning("hasl_context_step returned an error without an error " |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
534 | "status: %s", local_error->message); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
535 | |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
536 | g_clear_error(&local_error); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
537 | } |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
538 | |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
539 | /* If we got an output for the client, write it out. */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
540 | if(client_out_length > 0) { |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
541 | char *encoded = NULL; |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
542 | |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
543 | encoded = g_base64_encode(client_out, client_out_length); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
544 | g_clear_pointer(&client_out, g_free); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
545 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
546 | purple_ircv3_connection_writef(connection, "AUTHENTICATE %s", |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
547 | encoded); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
548 | g_free(encoded); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
549 | } else { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
550 | purple_ircv3_connection_writef(connection, "AUTHENTICATE +"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
551 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
552 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
553 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
554 | return TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
555 | } |