Sun, 14 Jan 2024 20:08:13 -0600
Make sure all of the license headers for IRCv3 are GPLv2
Testing Done:
Ran `licensecheck` from debian in the following way.
```
$ licensecheck *.[ch] | cut -d: -f 2 | sort | uniq -c
27 GNU General Public License v2.0 or later
```
Reviewed at https://reviews.imfreedom.org/r/2913/
|
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 | * |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
5 | * Purple is the legal property of its developers, whose names are too numerous |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
7 | * source distribution. |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
8 | * |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
9 | * This library is free software; you can redistribute it and/or modify |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * 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
|
11 | * 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
|
12 | * (at your option) any later version. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
14 | * This library is distributed in the hope that it will be useful, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * 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
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
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 | * You should have received a copy of the GNU General Public License |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
20 | * along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
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 <glib/gi18n-lib.h> |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
25 | #include <hasl.h> |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include "purpleircv3sasl.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 | #include "purpleircv3capabilities.h" |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | #include "purpleircv3connection.h" |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
31 | #include "purpleircv3constants.h" |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | #include "purpleircv3core.h" |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | #define PURPLE_IRCV3_SASL_DATA_KEY ("sasl-data") |
|
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 | typedef struct { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | PurpleConnection *connection; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
39 | HaslContext *ctx; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | GString *server_in_buffer; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | } PurpleIRCv3SASLData; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | /****************************************************************************** |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | * Helpers |
|
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 | static const char * |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | purple_ircv3_sasl_get_username(PurpleConnection *connection) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | PurpleAccount *account = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | const char *username = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | account = purple_connection_get_account(connection); |
|
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 | username = purple_account_get_string(account, "sasl-login-name", ""); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | if(username != NULL && username[0] != '\0') { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | return username; |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | return purple_connection_get_display_name(connection); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | /****************************************************************************** |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | * SASL Helpers |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | *****************************************************************************/ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | static void |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | 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
|
67 | g_clear_object(&data->ctx); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | |
|
42045
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
69 | g_string_free(data->server_in_buffer, TRUE); |
|
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
70 | |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | g_free(data); |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | static void |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
75 | 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
|
76 | PurpleIRCv3SASLData *data = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | data = g_new0(PurpleIRCv3SASLData, 1); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | 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
|
80 | data, (GDestroyNotify)purple_ircv3_sasl_data_free); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
81 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | /* 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
|
83 | * 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
|
84 | * would keep both alive forever. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | data->connection = connection; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | data->ctx = ctx; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | |
|
42045
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
89 | /* 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
|
90 | * allocations and simplify the logic involved with it. |
|
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
91 | */ |
|
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
92 | data->server_in_buffer = g_string_new(""); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | static void |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | purple_ircv3_sasl_attempt(PurpleIRCv3Connection *connection) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | PurpleIRCv3SASLData *data = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | 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
|
99 | const char *current = NULL; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | 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
|
102 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
103 | 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
|
104 | if(current != NULL) { |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
105 | g_message("SASL '%s' mechanism failed", current); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
108 | 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
|
109 | if(next_mechanism == NULL) { |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
110 | 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
|
111 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
112 | _("No valid SASL mechanisms found")); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
114 | purple_connection_take_error(PURPLE_CONNECTION(connection), error); |
|
42023
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 | return; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | } |
|
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 | g_message("trying SASL '%s' mechanism", next_mechanism); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
121 | purple_ircv3_connection_writef(connection, "%s %s", |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
122 | PURPLE_IRCV3_MSG_AUTHENTICATE, |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
123 | next_mechanism); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
126 | static void |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
127 | purple_ircv3_sasl_start(PurpleIRCv3Capabilities *caps) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | PurpleIRCv3Connection *connection = NULL; |
|
42044
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
129 | PurpleAccount *account = NULL; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | PurpleConnection *purple_connection = NULL; |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
131 | HaslContext *ctx = NULL; |
|
42044
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
132 | const char *mechanisms = NULL; |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
133 | gboolean toggle = FALSE; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
135 | connection = purple_ircv3_capabilities_get_connection(caps); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | 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
|
137 | account = purple_connection_get_account(purple_connection); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
139 | ctx = hasl_context_new(); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
141 | /* 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
|
142 | * counter to the capabilities and start the negotiations! |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | purple_ircv3_capabilities_add_wait(caps); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
146 | /* 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
|
147 | 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
|
148 | if(purple_strempty(mechanisms)) { |
|
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
149 | /* 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
|
150 | * the server advertised. |
|
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
151 | */ |
|
37eaa6065a9a
IRCv3: Add an account option to specify the SASL mechanisms
Gary Kramlich <grim@reaperworld.com>
parents:
42040
diff
changeset
|
152 | 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
|
153 | } |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
154 | 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
|
155 | |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
156 | /* 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
|
157 | 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
|
158 | 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
|
159 | |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
160 | 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
|
161 | 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
|
162 | |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
163 | 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
|
164 | hasl_context_set_allow_clear_text(ctx, toggle); |
|
42023
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 | /* 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
|
167 | purple_ircv3_sasl_data_add(purple_connection, ctx); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | /* Make it go! */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | purple_ircv3_sasl_attempt(connection); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | /****************************************************************************** |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | * Callbacks |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | *****************************************************************************/ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | static void |
|
42040
86284f7119e1
IRCv3: Add detail to the ack and nak signals for PurpleIRCv3Capabilities
Gary Kramlich <grim@reaperworld.com>
parents:
42027
diff
changeset
|
177 | 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
|
178 | G_GNUC_UNUSED const char *capability, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | G_GNUC_UNUSED gpointer data) |
|
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 | purple_ircv3_sasl_start(caps); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
184 | /****************************************************************************** |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | * Internal API |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | *****************************************************************************/ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | void |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | purple_ircv3_sasl_request(PurpleIRCv3Capabilities *capabilities) { |
|
42287
8fc84ffcdcb2
IRCv3: Use constants for capability names
Gary Kramlich <grim@reaperworld.com>
parents:
42271
diff
changeset
|
189 | purple_ircv3_capabilities_request(capabilities, |
|
8fc84ffcdcb2
IRCv3: Use constants for capability names
Gary Kramlich <grim@reaperworld.com>
parents:
42271
diff
changeset
|
190 | PURPLE_IRCV3_CAPABILITY_SASL); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | |
|
42287
8fc84ffcdcb2
IRCv3: Use constants for capability names
Gary Kramlich <grim@reaperworld.com>
parents:
42271
diff
changeset
|
192 | 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
|
193 | G_CALLBACK(purple_ircv3_sasl_ack_cb), NULL); |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
197 | 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
|
198 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | 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
|
203 | PurpleAccount *account = NULL; |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
204 | const char *sasl_name = NULL; |
|
42023
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 | 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
|
207 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
208 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | "RPL_LOGGEDIN received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | |
|
42271
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
215 | /* 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
|
216 | * current nick as it was successful. |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | */ |
|
42271
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
218 | 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
|
219 | 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
|
220 | 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
|
221 | char **userparts = NULL; |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
222 | 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
|
223 | |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
224 | 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
|
225 | 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
|
226 | |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
227 | 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
|
228 | |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
229 | g_strfreev(userparts); |
|
1a7cacfd281f
Set the sasl login name on successful login if not set
Gary Kramlich <grim@reaperworld.com>
parents:
42081
diff
changeset
|
230 | } |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | return TRUE; |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
236 | 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
|
237 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
240 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | PurpleIRCv3SASLData *data = NULL; |
|
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 | 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
|
244 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
245 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | "RPL_LOGGEDOUT received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
248 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | } |
|
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 | /* 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
|
253 | * honest, so just note it for now. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | * -- GK 2023-01-12 |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | g_warning("Server sent SASL logged out"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | return TRUE; |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
262 | purple_ircv3_sasl_nick_locked(PurpleIRCv3Message *v3_message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | PurpleIRCv3SASLData *data = NULL; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
268 | GStrv params = NULL; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | char *message = NULL; |
|
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 | 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
|
272 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | "ERR_NICKLOCKED received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | "present"); |
|
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 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
280 | params = purple_ircv3_message_get_params(v3_message); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | message = g_strjoinv(" ", params); |
|
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 | g_set_error(error, PURPLE_CONNECTION_ERROR, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | _("Nick name is locked: %s"), message); |
|
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 | g_free(message); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | } |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
293 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
294 | 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
|
295 | GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
296 | gpointer user_data) |
|
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 | PurpleIRCv3Capabilities *capabilities = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
299 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
300 | PurpleIRCv3SASLData *data = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
301 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
302 | capabilities = purple_ircv3_connection_get_capabilities(connection); |
|
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 | 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
|
305 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
306 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | "RPL_SASLSUCCESS received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | "present"); |
|
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 | return FALSE; |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | /* 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
|
314 | * 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
|
315 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
316 | purple_ircv3_capabilities_remove_wait(capabilities); |
|
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 | 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
|
319 | hasl_context_get_current_mechanism(data->ctx)); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
320 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | return TRUE; |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
325 | 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
|
326 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
328 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | PurpleIRCv3SASLData *data = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
332 | 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
|
333 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | "ERR_SASLFAIL received with no SASL data present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
336 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
337 | return FALSE; |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | purple_ircv3_sasl_attempt(connection); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | return TRUE; |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
346 | 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
|
347 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
348 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
350 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
351 | PurpleIRCv3SASLData *data = NULL; |
|
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 | 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
|
354 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
355 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
356 | "ERR_SASLTOOLONG received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | "present"); |
|
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 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
360 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
362 | return TRUE; |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
365 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
366 | 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
|
367 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
368 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
369 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
370 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
371 | PurpleIRCv3SASLData *data = NULL; |
|
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 | 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
|
374 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
375 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
376 | "ERR_SASLABORTED received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
377 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
378 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
379 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
380 | } |
|
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 | /* 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
|
383 | * 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
|
384 | * --GK 2023-01-12 |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
385 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
386 | g_warning("The server claims we aborted SASL authentication."); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
387 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
388 | return TRUE; |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
391 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
392 | 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
|
393 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
394 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
395 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
396 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
397 | PurpleIRCv3SASLData *data = NULL; |
|
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 | 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
|
400 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
401 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
402 | "ERR_SASLALREADY received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
403 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
404 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
405 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
406 | } |
|
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 | /* 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
|
409 | * happened. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
410 | * -- GK 2023-01-12 |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
411 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
412 | 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
|
413 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
414 | return TRUE; |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
417 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
418 | purple_ircv3_sasl_mechanisms(PurpleIRCv3Message *message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
419 | G_GNUC_UNUSED GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
420 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
421 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
422 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
423 | PurpleIRCv3SASLData *data = NULL; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
424 | GStrv params = NULL; |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
425 | guint n_params = 0; |
|
42023
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 | 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
|
428 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
429 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
430 | "RPL_SASLMECHS received with no SASL data " |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
431 | "present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
432 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
433 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
434 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
435 | |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
436 | 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
|
437 | if(params != NULL) { |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
438 | n_params = g_strv_length(params); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
439 | } |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
440 | |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
441 | /* 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
|
442 | * 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
|
443 | * mechanism, but ergo doesn't. |
|
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 | * 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
|
446 | * 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
|
447 | * 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
|
448 | * 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
|
449 | * addressed as well. |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
450 | */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
451 | if(n_params > 0) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
452 | char *message = g_strjoinv(" ", params); |
|
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 | 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
|
455 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
456 | g_free(message); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
457 | } else { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
458 | 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
|
459 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
460 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
461 | return TRUE; |
|
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 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
464 | gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
465 | purple_ircv3_sasl_authenticate(PurpleIRCv3Message *message, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
466 | GError **error, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
467 | gpointer user_data) |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
468 | { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
469 | PurpleIRCv3Connection *connection = user_data; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
470 | PurpleIRCv3SASLData *data = NULL; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
471 | GStrv params = NULL; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
472 | char *payload = NULL; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
473 | gboolean done = FALSE; |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
474 | guint n_params = 0; |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
475 | |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
476 | 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
|
477 | if(params != NULL) { |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
478 | n_params = g_strv_length(params); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42287
diff
changeset
|
479 | } |
|
42023
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 | if(n_params != 1) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
482 | g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
483 | "ignoring AUTHENTICATE with %d parameters", n_params); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
484 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
485 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
486 | } |
|
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 | payload = params[0]; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
489 | 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
|
490 | if(data == NULL) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
491 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
492 | "AUTHENTICATE received with no SASL data present"); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
493 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
494 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
495 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
496 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
497 | /* 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
|
498 | if(payload[0] != '+') { |
|
42045
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
499 | g_string_append(data->server_in_buffer, payload); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
500 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
501 | if(strlen(payload) < 400) { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
502 | done = TRUE; |
|
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 | } else { |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
505 | /* 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
|
506 | * ended on a 400 byte barrier. */ |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
507 | done = TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
508 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
509 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
510 | if(done) { |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
511 | HaslMechanismResult res = 0; |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
512 | GError *local_error = NULL; |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
513 | guint8 *server_in = NULL; |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
514 | guint8 *client_out = NULL; |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
515 | gsize server_in_length = 0; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
516 | size_t client_out_length = 0; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
517 | |
|
42045
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
518 | /* 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
|
519 | 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
|
520 | 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
|
521 | &server_in_length); |
|
42045
bfe15fc3cbf4
IRCv3: Get SCRAM-SHA-256 working
Gary Kramlich <grim@reaperworld.com>
parents:
42044
diff
changeset
|
522 | g_string_truncate(data->server_in_buffer, 0); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
523 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
524 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
525 | /* 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
|
526 | 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
|
527 | &client_out, &client_out_length, &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 | /* 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
|
530 | g_clear_pointer(&server_in, g_free); |
|
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(res == HASL_MECHANISM_RESULT_ERROR) { |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
533 | g_propagate_error(error, local_error); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
534 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
535 | return FALSE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
536 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
537 | |
|
42081
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
538 | if(local_error != NULL) { |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
539 | 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
|
540 | "status: %s", local_error->message); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
541 | |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
542 | g_clear_error(&local_error); |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
543 | } |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
544 | |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
545 | /* 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
|
546 | 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
|
547 | char *encoded = NULL; |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
548 | |
|
16ef7725e459
IRCv3: Port to our new SASL library named Hasl
Gary Kramlich <grim@reaperworld.com>
parents:
42046
diff
changeset
|
549 | 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
|
550 | g_clear_pointer(&client_out, g_free); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
551 | |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
552 | purple_ircv3_connection_writef(connection, "%s %s", |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
553 | PURPLE_IRCV3_MSG_AUTHENTICATE, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
554 | encoded); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
555 | g_free(encoded); |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
556 | } else { |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
557 | purple_ircv3_connection_writef(connection, "%s +", |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
558 | PURPLE_IRCV3_MSG_AUTHENTICATE); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
559 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
560 | } |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
561 | |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
562 | return TRUE; |
|
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
563 | } |