Wed, 10 Jun 2009 07:44:35 +0000
Check in a change requested by Gregory Cypes from AOL. They want clients
to be able to specify the clientstring and distribution id used when
authenticating. Seems like a reasonable request.
If the UI doesn't change these preferences then the default values from the
ClientInfo struct are used.
| 13235 | 1 | /* |
| 15884 | 2 | * Purple's oscar protocol plugin |
| 13235 | 3 | * This file is the legal property of its developers. |
| 4 | * Please see the AUTHORS file distributed alongside this file. | |
| 5 | * | |
| 6 | * This library is free software; you can redistribute it and/or | |
| 7 | * modify it under the terms of the GNU Lesser General Public | |
| 8 | * License as published by the Free Software Foundation; either | |
| 9 | * version 2 of the License, or (at your option) any later version. | |
| 10 | * | |
| 11 | * This library is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | * Lesser General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU Lesser General Public | |
| 17 | * License along with this library; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19820
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 13235 | 19 | */ |
| 20 | ||
| 21 | /* | |
| 22 | * Family 0x0017 - Authentication. | |
| 23 | * | |
| 24 | * Deals with the authorizer for SNAC-based login, and also old-style | |
| 25 | * non-SNAC login. | |
| 26 | * | |
| 27 | */ | |
| 28 | ||
| 29 | #include "oscar.h" | |
| 30 | ||
| 31 | #include "cipher.h" | |
| 32 | ||
| 33 | #include <ctype.h> | |
| 34 | ||
|
24670
84014b07aa10
Patch from 'db42' to enable MD5 auth on ICQ. Refs #4449. Before I merge
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
23526
diff
changeset
|
35 | /* #define USE_XOR_FOR_ICQ */ |
| 13235 | 36 | |
| 37 | #ifdef USE_XOR_FOR_ICQ | |
| 38 | /** | |
| 39 | * Encode a password using old XOR method | |
| 40 | * | |
| 41 | * This takes a const pointer to a (null terminated) string | |
| 42 | * containing the unencoded password. It also gets passed | |
| 43 | * an already allocated buffer to store the encoded password. | |
| 44 | * This buffer should be the exact length of the password without | |
| 45 | * the null. The encoded password buffer /is not %NULL terminated/. | |
| 46 | * | |
| 47 | * The encoding_table seems to be a fixed set of values. We'll | |
| 48 | * hope it doesn't change over time! | |
| 49 | * | |
| 50 | * This is only used for the XOR method, not the better MD5 method. | |
| 51 | * | |
| 52 | * @param password Incoming password. | |
| 53 | * @param encoded Buffer to put encoded password. | |
| 54 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
55 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
56 | aim_encode_password(const char *password, guint8 *encoded) |
| 13235 | 57 | { |
| 58 | guint8 encoding_table[] = { | |
| 59 | #if 0 /* old v1 table */ | |
| 60 | 0xf3, 0xb3, 0x6c, 0x99, | |
| 61 | 0x95, 0x3f, 0xac, 0xb6, | |
| 62 | 0xc5, 0xfa, 0x6b, 0x63, | |
| 63 | 0x69, 0x6c, 0xc3, 0x9f | |
| 64 | #else /* v2.1 table, also works for ICQ */ | |
| 65 | 0xf3, 0x26, 0x81, 0xc4, | |
| 66 | 0x39, 0x86, 0xdb, 0x92, | |
| 67 | 0x71, 0xa3, 0xb9, 0xe6, | |
| 68 | 0x53, 0x7a, 0x95, 0x7c | |
| 69 | #endif | |
| 70 | }; | |
| 71 | unsigned int i; | |
| 72 | ||
| 73 | for (i = 0; i < strlen(password); i++) | |
| 74 | encoded[i] = (password[i] ^ encoding_table[i]); | |
| 75 | ||
| 76 | return 0; | |
| 77 | } | |
| 78 | #endif | |
| 79 | ||
| 80 | #ifdef USE_OLD_MD5 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
81 | static int |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
82 | aim_encode_password_md5(const char *password, size_t password_len, const char *key, guint8 *digest) |
| 13235 | 83 | { |
| 15884 | 84 | PurpleCipherContext *context; |
| 13235 | 85 | |
|
23526
23c321e72167
Helper functions are cool
Mark Doliner <markdoliner@pidgin.im>
parents:
23456
diff
changeset
|
86 | context = purple_cipher_context_new_by_name("md5", NULL); |
| 15884 | 87 | purple_cipher_context_append(context, (const guchar *)key, strlen(key)); |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
88 | purple_cipher_context_append(context, (const guchar *)password, password_len); |
| 15884 | 89 | purple_cipher_context_append(context, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); |
| 90 | purple_cipher_context_digest(context, 16, digest, NULL); | |
| 91 | purple_cipher_context_destroy(context); | |
| 13235 | 92 | |
| 93 | return 0; | |
| 94 | } | |
| 95 | #else | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
96 | static int |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
97 | aim_encode_password_md5(const char *password, size_t password_len, const char *key, guint8 *digest) |
| 13235 | 98 | { |
| 15884 | 99 | PurpleCipher *cipher; |
| 100 | PurpleCipherContext *context; | |
| 13235 | 101 | guchar passdigest[16]; |
| 102 | ||
| 15884 | 103 | cipher = purple_ciphers_find_cipher("md5"); |
| 13235 | 104 | |
| 15884 | 105 | context = purple_cipher_context_new(cipher, NULL); |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
106 | purple_cipher_context_append(context, (const guchar *)password, password_len); |
| 15884 | 107 | purple_cipher_context_digest(context, 16, passdigest, NULL); |
| 108 | purple_cipher_context_destroy(context); | |
| 13235 | 109 | |
| 15884 | 110 | context = purple_cipher_context_new(cipher, NULL); |
| 111 | purple_cipher_context_append(context, (const guchar *)key, strlen(key)); | |
| 112 | purple_cipher_context_append(context, passdigest, 16); | |
| 113 | purple_cipher_context_append(context, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | |
| 114 | purple_cipher_context_digest(context, 16, digest, NULL); | |
| 115 | purple_cipher_context_destroy(context); | |
| 13235 | 116 | |
| 117 | return 0; | |
| 118 | } | |
| 119 | #endif | |
| 120 | ||
| 121 | #ifdef USE_XOR_FOR_ICQ | |
| 122 | /* | |
| 123 | * Part two of the ICQ hack. Note the ignoring of the key. | |
| 124 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
125 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
126 | goddamnicq2(OscarData *od, FlapConnection *conn, const char *sn, const char *password, ClientInfo *ci) |
| 13235 | 127 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
128 | FlapFrame *frame; |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
129 | GSList *tlvlist = NULL; |
| 13235 | 130 | int passwdlen; |
| 131 | guint8 *password_encoded; | |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
132 | const char *clientstring; |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
133 | guint32 distrib; |
| 13235 | 134 | |
| 135 | passwdlen = strlen(password); | |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
136 | password_encoded = (guint8 *)g_malloc(passwdlen+1); |
| 13235 | 137 | if (passwdlen > MAXICQPASSLEN) |
| 138 | passwdlen = MAXICQPASSLEN; | |
| 139 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
140 | frame = flap_frame_new(od, 0x01, 1152); |
| 13235 | 141 | |
| 142 | aim_encode_password(password, password_encoded); | |
| 143 | ||
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
144 | clientstring = purple_prefs_get_string("/plugins/prpl/oscar/clientstring"); |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
145 | if (clientstring == NULL) |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
146 | clientstring = ci->clientstring; |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
147 | distrib = purple_prefs_get_int("/plugins/prpl/oscar/distid"); |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
148 | if ((gint32)distrib == -1) |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
149 | distrib = ci->distrib; |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
150 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
151 | byte_stream_put32(&frame->data, 0x00000001); /* FLAP Version */ |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
152 | aim_tlvlist_add_str(&tlvlist, 0x0001, sn); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
153 | aim_tlvlist_add_raw(&tlvlist, 0x0002, passwdlen, password_encoded); |
| 13235 | 154 | |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
155 | if (clientstring) |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
156 | aim_tlvlist_add_str(&tlvlist, 0x0003, clientstring); |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
157 | aim_tlvlist_add_16(&tlvlist, 0x0016, (guint16)ci->clientid); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
158 | aim_tlvlist_add_16(&tlvlist, 0x0017, (guint16)ci->major); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
159 | aim_tlvlist_add_16(&tlvlist, 0x0018, (guint16)ci->minor); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
160 | aim_tlvlist_add_16(&tlvlist, 0x0019, (guint16)ci->point); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
161 | aim_tlvlist_add_16(&tlvlist, 0x001a, (guint16)ci->build); |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
162 | aim_tlvlist_add_32(&tlvlist, 0x0014, distrib); /* distribution chan */ |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
163 | aim_tlvlist_add_str(&tlvlist, 0x000f, ci->lang); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
164 | aim_tlvlist_add_str(&tlvlist, 0x000e, ci->country); |
| 13235 | 165 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
166 | aim_tlvlist_write(&frame->data, &tlvlist); |
| 13235 | 167 | |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
168 | g_free(password_encoded); |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
169 | aim_tlvlist_free(tlvlist); |
| 13235 | 170 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
171 | flap_connection_send(conn, frame); |
| 13235 | 172 | |
| 173 | return 0; | |
| 174 | } | |
| 175 | #endif | |
| 176 | ||
| 177 | /* | |
| 178 | * Subtype 0x0002 | |
| 179 | * | |
| 180 | * This is the initial login request packet. | |
| 181 | * | |
| 182 | * NOTE!! If you want/need to make use of the aim_sendmemblock() function, | |
| 183 | * then the client information you send here must exactly match the | |
| 184 | * executable that you're pulling the data from. | |
| 185 | * | |
| 186 | * Java AIM 1.1.19: | |
| 187 | * clientstring = "AOL Instant Messenger (TM) version 1.1.19 for Java built 03/24/98, freeMem 215871 totalMem 1048567, i686, Linus, #2 SMP Sun Feb 11 03:41:17 UTC 2001 2.4.1-ac9, IBM Corporation, 1.1.8, 45.3, Tue Mar 27 12:09:17 PST 2001" | |
| 188 | * clientid = 0x0001 | |
| 189 | * major = 0x0001 | |
| 190 | * minor = 0x0001 | |
| 191 | * point = (not sent) | |
| 192 | * build = 0x0013 | |
| 193 | * unknown= (not sent) | |
|
13240
db5187cc40d1
[gaim-migrate @ 15605]
Mark Doliner <markdoliner@pidgin.im>
parents:
13235
diff
changeset
|
194 | * |
| 13235 | 195 | * AIM for Linux 1.1.112: |
| 196 | * clientstring = "AOL Instant Messenger (SM)" | |
| 197 | * clientid = 0x1d09 | |
| 198 | * major = 0x0001 | |
| 199 | * minor = 0x0001 | |
| 200 | * point = 0x0001 | |
| 201 | * build = 0x0070 | |
| 202 | * unknown= 0x0000008b | |
| 203 | * serverstore = 0x01 | |
| 204 | * | |
|
22127
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
205 | * @param truncate_pass Truncate the password to 8 characters. This |
|
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
206 | * usually happens for AOL accounts. We are told that we |
|
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
207 | * should truncate it if the 0x0017/0x0007 SNAC contains |
|
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
208 | * a TLV of type 0x0026 with data 0x0000. |
|
23454
d8721c84f49c
Added paramater to aim_send_login() to allow control over whether we want
Evan Schoenberg <evands@pidgin.im>
parents:
22127
diff
changeset
|
209 | * @param allow_multiple_logins Allow multiple logins? If TRUE, the AIM |
|
d8721c84f49c
Added paramater to aim_send_login() to allow control over whether we want
Evan Schoenberg <evands@pidgin.im>
parents:
22127
diff
changeset
|
210 | * server will prompt the user when multiple logins occur. If |
|
d8721c84f49c
Added paramater to aim_send_login() to allow control over whether we want
Evan Schoenberg <evands@pidgin.im>
parents:
22127
diff
changeset
|
211 | * FALSE, existing connections (on other clients) will be |
|
d8721c84f49c
Added paramater to aim_send_login() to allow control over whether we want
Evan Schoenberg <evands@pidgin.im>
parents:
22127
diff
changeset
|
212 | * disconnected automatically as we connect. |
| 13235 | 213 | */ |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
214 | int |
|
23454
d8721c84f49c
Added paramater to aim_send_login() to allow control over whether we want
Evan Schoenberg <evands@pidgin.im>
parents:
22127
diff
changeset
|
215 | aim_send_login(OscarData *od, FlapConnection *conn, const char *sn, const char *password, gboolean truncate_pass, ClientInfo *ci, const char *key, gboolean allow_multiple_logins) |
| 13235 | 216 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
217 | FlapFrame *frame; |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
218 | GSList *tlvlist = NULL; |
| 13235 | 219 | guint8 digest[16]; |
| 220 | aim_snacid_t snacid; | |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
221 | size_t password_len; |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
222 | const char *clientstring; |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
223 | guint32 distrib; |
| 13235 | 224 | |
| 225 | if (!ci || !sn || !password) | |
| 226 | return -EINVAL; | |
| 227 | ||
| 228 | #ifdef USE_XOR_FOR_ICQ | |
| 229 | /* If we're signing on an ICQ account then use the older, XOR login method */ | |
|
19820
0f82885da3d8
A little function name shuffling.
Mark Doliner <markdoliner@pidgin.im>
parents:
18341
diff
changeset
|
230 | if (aim_snvalid_icq(sn)) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
231 | return goddamnicq2(od, conn, sn, password, ci); |
| 13235 | 232 | #endif |
| 233 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
234 | frame = flap_frame_new(od, 0x02, 1152); |
| 13235 | 235 | |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
236 | snacid = aim_cachesnac(od, SNAC_FAMILY_AUTH, 0x0002, 0x0000, NULL, 0); |
|
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
237 | aim_putsnac(&frame->data, SNAC_FAMILY_AUTH, 0x0002, 0x0000, snacid); |
| 13235 | 238 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
239 | aim_tlvlist_add_str(&tlvlist, 0x0001, sn); |
| 13235 | 240 | |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
241 | /* Truncate ICQ and AOL passwords, if necessary */ |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
242 | password_len = strlen(password); |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
243 | if (oscar_util_valid_name_icq(sn) && (password_len > MAXICQPASSLEN)) |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
244 | password_len = MAXICQPASSLEN; |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
245 | else if (truncate_pass && password_len > 8) |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
246 | password_len = 8; |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
247 | |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
248 | aim_encode_password_md5(password, password_len, key, digest); |
| 13235 | 249 | |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
250 | clientstring = purple_prefs_get_string("/plugins/prpl/oscar/clientstring"); |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
251 | if (clientstring == NULL) |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
252 | clientstring = ci->clientstring; |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
253 | distrib = purple_prefs_get_int("/plugins/prpl/oscar/distid"); |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
254 | if ((gint32)distrib == -1) |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
255 | distrib = ci->distrib; |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
256 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
257 | aim_tlvlist_add_raw(&tlvlist, 0x0025, 16, digest); |
| 13235 | 258 | |
| 259 | #ifndef USE_OLD_MD5 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
260 | aim_tlvlist_add_noval(&tlvlist, 0x004c); |
| 13235 | 261 | #endif |
| 262 | ||
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
263 | if (clientstring) |
|
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
264 | aim_tlvlist_add_str(&tlvlist, 0x0003, clientstring); |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
265 | aim_tlvlist_add_16(&tlvlist, 0x0016, (guint16)ci->clientid); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
266 | aim_tlvlist_add_16(&tlvlist, 0x0017, (guint16)ci->major); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
267 | aim_tlvlist_add_16(&tlvlist, 0x0018, (guint16)ci->minor); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
268 | aim_tlvlist_add_16(&tlvlist, 0x0019, (guint16)ci->point); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
269 | aim_tlvlist_add_16(&tlvlist, 0x001a, (guint16)ci->build); |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
270 | aim_tlvlist_add_32(&tlvlist, 0x0014, distrib); |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
271 | aim_tlvlist_add_str(&tlvlist, 0x000f, ci->lang); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
272 | aim_tlvlist_add_str(&tlvlist, 0x000e, ci->country); |
| 13235 | 273 | |
| 274 | /* | |
| 275 | * If set, old-fashioned buddy lists will not work. You will need | |
| 276 | * to use SSI. | |
| 277 | */ | |
|
23454
d8721c84f49c
Added paramater to aim_send_login() to allow control over whether we want
Evan Schoenberg <evands@pidgin.im>
parents:
22127
diff
changeset
|
278 | aim_tlvlist_add_8(&tlvlist, 0x004a, (allow_multiple_logins ? 0x01 : 0x02)); |
| 13235 | 279 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
280 | aim_tlvlist_write(&frame->data, &tlvlist); |
| 13235 | 281 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
282 | aim_tlvlist_free(tlvlist); |
| 13235 | 283 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
284 | flap_connection_send(conn, frame); |
| 13235 | 285 | |
| 286 | return 0; | |
| 287 | } | |
| 288 | ||
| 289 | /* | |
| 290 | * This is sent back as a general response to the login command. | |
| 291 | * It can be either an error or a success, depending on the | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
292 | * presence of certain TLVs. |
| 13235 | 293 | * |
| 294 | * The client should check the value passed as errorcode. If | |
| 295 | * its nonzero, there was an error. | |
| 296 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
297 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
298 | parse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 299 | { |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
300 | GSList *tlvlist; |
| 13235 | 301 | aim_rxcallback_t userfunc; |
| 302 | struct aim_authresp_info *info; | |
| 303 | int ret = 0; | |
| 304 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
305 | info = g_new0(struct aim_authresp_info, 1); |
| 13235 | 306 | |
| 307 | /* | |
| 308 | * Read block of TLVs. All further data is derived | |
| 309 | * from what is parsed here. | |
| 310 | */ | |
| 311 | tlvlist = aim_tlvlist_read(bs); | |
| 312 | ||
| 313 | /* | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
314 | * No matter what, we should have a username. |
| 13235 | 315 | */ |
| 316 | if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) { | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
317 | info->bn = aim_tlv_getstr(tlvlist, 0x0001, 1); |
|
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
318 | purple_connection_set_display_name(od->gc, info->bn); |
| 13235 | 319 | } |
| 320 | ||
| 321 | /* | |
| 322 | * Check for an error code. If so, we should also | |
| 323 | * have an error url. | |
| 324 | */ | |
| 325 | if (aim_tlv_gettlv(tlvlist, 0x0008, 1)) | |
| 326 | info->errorcode = aim_tlv_get16(tlvlist, 0x0008, 1); | |
| 327 | if (aim_tlv_gettlv(tlvlist, 0x0004, 1)) | |
| 328 | info->errorurl = aim_tlv_getstr(tlvlist, 0x0004, 1); | |
| 329 | ||
| 330 | /* | |
| 331 | * BOS server address. | |
| 332 | */ | |
| 333 | if (aim_tlv_gettlv(tlvlist, 0x0005, 1)) | |
| 334 | info->bosip = aim_tlv_getstr(tlvlist, 0x0005, 1); | |
| 335 | ||
| 336 | /* | |
| 337 | * Authorization cookie. | |
| 338 | */ | |
| 339 | if (aim_tlv_gettlv(tlvlist, 0x0006, 1)) { | |
| 340 | aim_tlv_t *tmptlv; | |
| 341 | ||
| 342 | tmptlv = aim_tlv_gettlv(tlvlist, 0x0006, 1); | |
|
13653
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
343 | if (tmptlv != NULL) |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
344 | { |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
345 | info->cookielen = tmptlv->length; |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
346 | info->cookie = tmptlv->value; |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
347 | } |
| 13235 | 348 | } |
| 349 | ||
| 350 | /* | |
| 351 | * The email address attached to this account | |
| 352 | * Not available for ICQ or @mac.com logins. | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
353 | * If you receive this TLV, then you are allowed to use |
| 13235 | 354 | * family 0x0018 to check the status of your email. |
| 355 | * XXX - Not really true! | |
| 356 | */ | |
| 357 | if (aim_tlv_gettlv(tlvlist, 0x0011, 1)) | |
| 358 | info->email = aim_tlv_getstr(tlvlist, 0x0011, 1); | |
| 359 | ||
| 360 | /* | |
| 361 | * The registration status. (Not real sure what it means.) | |
| 362 | * Not available for ICQ or @mac.com logins. | |
| 363 | * | |
| 364 | * 1 = No disclosure | |
| 365 | * 2 = Limited disclosure | |
| 366 | * 3 = Full disclosure | |
| 367 | * | |
| 368 | * This has to do with whether your email address is available | |
| 369 | * to other users or not. AFAIK, this feature is no longer used. | |
| 370 | * | |
| 371 | * Means you can use the admin family? (0x0007) | |
| 372 | * | |
| 373 | */ | |
| 374 | if (aim_tlv_gettlv(tlvlist, 0x0013, 1)) | |
| 375 | info->regstatus = aim_tlv_get16(tlvlist, 0x0013, 1); | |
| 376 | ||
| 377 | if (aim_tlv_gettlv(tlvlist, 0x0040, 1)) | |
| 378 | info->latestbeta.build = aim_tlv_get32(tlvlist, 0x0040, 1); | |
| 379 | if (aim_tlv_gettlv(tlvlist, 0x0041, 1)) | |
| 380 | info->latestbeta.url = aim_tlv_getstr(tlvlist, 0x0041, 1); | |
| 381 | if (aim_tlv_gettlv(tlvlist, 0x0042, 1)) | |
| 382 | info->latestbeta.info = aim_tlv_getstr(tlvlist, 0x0042, 1); | |
| 383 | if (aim_tlv_gettlv(tlvlist, 0x0043, 1)) | |
| 384 | info->latestbeta.name = aim_tlv_getstr(tlvlist, 0x0043, 1); | |
| 385 | ||
| 386 | #if 0 | |
| 387 | if (aim_tlv_gettlv(tlvlist, 0x0048, 1)) { | |
| 388 | /* beta serial */ | |
| 389 | } | |
| 390 | #endif | |
| 391 | ||
| 392 | if (aim_tlv_gettlv(tlvlist, 0x0044, 1)) | |
| 393 | info->latestrelease.build = aim_tlv_get32(tlvlist, 0x0044, 1); | |
| 394 | if (aim_tlv_gettlv(tlvlist, 0x0045, 1)) | |
| 395 | info->latestrelease.url = aim_tlv_getstr(tlvlist, 0x0045, 1); | |
| 396 | if (aim_tlv_gettlv(tlvlist, 0x0046, 1)) | |
| 397 | info->latestrelease.info = aim_tlv_getstr(tlvlist, 0x0046, 1); | |
| 398 | if (aim_tlv_gettlv(tlvlist, 0x0047, 1)) | |
| 399 | info->latestrelease.name = aim_tlv_getstr(tlvlist, 0x0047, 1); | |
| 400 | ||
| 401 | #if 0 | |
| 402 | if (aim_tlv_gettlv(tlvlist, 0x0049, 1)) { | |
| 403 | /* lastest release serial */ | |
| 404 | } | |
| 405 | #endif | |
| 406 | ||
| 407 | /* | |
| 408 | * URL to change password. | |
| 409 | */ | |
| 410 | if (aim_tlv_gettlv(tlvlist, 0x0054, 1)) | |
| 411 | info->chpassurl = aim_tlv_getstr(tlvlist, 0x0054, 1); | |
| 412 | ||
| 413 | #if 0 | |
| 414 | /* | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
415 | * Unknown. Seen on an @mac.com username with value of 0x003f |
| 13235 | 416 | */ |
| 417 | if (aim_tlv_gettlv(tlvlist, 0x0055, 1)) { | |
| 418 | /* Unhandled */ | |
| 419 | } | |
| 420 | #endif | |
| 421 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
422 | od->authinfo = info; |
| 13235 | 423 | |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
424 | if ((userfunc = aim_callhandler(od, snac ? snac->family : SNAC_FAMILY_AUTH, snac ? snac->subtype : 0x0003))) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
425 | ret = userfunc(od, conn, frame, info); |
| 13235 | 426 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
427 | aim_tlvlist_free(tlvlist); |
| 13235 | 428 | |
| 429 | return ret; | |
| 430 | } | |
| 431 | ||
| 432 | #ifdef USE_XOR_FOR_ICQ | |
| 433 | /* | |
| 434 | * Subtype 0x0007 (kind of) - Send a fake type 0x0007 SNAC to the client | |
| 435 | * | |
| 436 | * This is a bit confusing. | |
| 437 | * | |
| 438 | * Normal SNAC login goes like this: | |
| 439 | * - connect | |
| 440 | * - server sends flap version | |
| 441 | * - client sends flap version | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
442 | * - client sends username (17/6) |
| 13235 | 443 | * - server sends hash key (17/7) |
| 444 | * - client sends auth request (17/2 -- aim_send_login) | |
| 445 | * - server yells | |
| 446 | * | |
| 447 | * XOR login (for ICQ) goes like this: | |
| 448 | * - connect | |
| 449 | * - server sends flap version | |
| 450 | * - client sends auth request which contains flap version (aim_send_login) | |
| 451 | * - server yells | |
| 452 | * | |
| 453 | * For the client API, we make them implement the most complicated version, | |
| 454 | * and for the simpler version, we fake it and make it look like the more | |
| 455 | * complicated process. | |
| 456 | * | |
| 457 | * This is done by giving the client a faked key, just so we can convince | |
| 458 | * them to call aim_send_login right away, which will detect the session | |
| 459 | * flag that says this is XOR login and ignore the key, sending an ICQ | |
| 460 | * login request instead of the normal SNAC one. | |
| 461 | * | |
| 462 | * As soon as AOL makes ICQ log in the same way as AIM, this is /gone/. | |
| 463 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
464 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
465 | goddamnicq(OscarData *od, FlapConnection *conn, const char *sn) |
| 13235 | 466 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
467 | FlapFrame frame; |
| 13235 | 468 | aim_rxcallback_t userfunc; |
| 469 | ||
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
470 | if ((userfunc = aim_callhandler(od, SNAC_FAMILY_AUTH, 0x0007))) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
471 | userfunc(od, conn, &frame, ""); |
| 13235 | 472 | |
| 473 | return 0; | |
| 474 | } | |
| 475 | #endif | |
| 476 | ||
| 477 | /* | |
| 478 | * Subtype 0x0006 | |
| 479 | * | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
480 | * In AIM 3.5 protocol, the first stage of login is to request login from the |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
481 | * Authorizer, passing it the username for verification. If the name is |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
482 | * invalid, a 0017/0003 is spit back, with the standard error contents. If |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
483 | * valid, a 0017/0007 comes back, which is the signal to send it the main |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
484 | * login command (0017/0002). |
| 13235 | 485 | * |
| 486 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
487 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
488 | aim_request_login(OscarData *od, FlapConnection *conn, const char *sn) |
| 13235 | 489 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
490 | FlapFrame *frame; |
| 13235 | 491 | aim_snacid_t snacid; |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
492 | GSList *tlvlist = NULL; |
| 13235 | 493 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
494 | if (!od || !conn || !sn) |
| 13235 | 495 | return -EINVAL; |
| 496 | ||
| 497 | #ifdef USE_XOR_FOR_ICQ | |
|
19820
0f82885da3d8
A little function name shuffling.
Mark Doliner <markdoliner@pidgin.im>
parents:
18341
diff
changeset
|
498 | if (aim_snvalid_icq(sn)) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
499 | return goddamnicq(od, conn, sn); |
| 13235 | 500 | #endif |
| 501 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
502 | frame = flap_frame_new(od, 0x02, 10+2+2+strlen(sn)+8); |
| 13235 | 503 | |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
504 | snacid = aim_cachesnac(od, SNAC_FAMILY_AUTH, 0x0006, 0x0000, NULL, 0); |
|
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
505 | aim_putsnac(&frame->data, SNAC_FAMILY_AUTH, 0x0006, 0x0000, snacid); |
| 13235 | 506 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
507 | aim_tlvlist_add_str(&tlvlist, 0x0001, sn); |
| 13235 | 508 | |
| 509 | /* Tell the server we support SecurID logins. */ | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
510 | aim_tlvlist_add_noval(&tlvlist, 0x004b); |
| 13235 | 511 | |
| 512 | /* Unknown. Sent in recent WinAIM clients.*/ | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
513 | aim_tlvlist_add_noval(&tlvlist, 0x005a); |
| 13235 | 514 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
515 | aim_tlvlist_write(&frame->data, &tlvlist); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
516 | aim_tlvlist_free(tlvlist); |
| 13235 | 517 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
518 | flap_connection_send(conn, frame); |
| 13235 | 519 | |
| 520 | return 0; | |
| 521 | } | |
| 522 | ||
| 523 | /* | |
| 524 | * Subtype 0x0007 | |
| 525 | * | |
| 526 | * Middle handler for 0017/0007 SNACs. Contains the auth key prefixed | |
| 527 | * by only its length in a two byte word. | |
| 528 | * | |
| 529 | * Calls the client, which should then use the value to call aim_send_login. | |
| 530 | * | |
| 531 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
532 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
533 | keyparse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 534 | { |
| 535 | int keylen, ret = 1; | |
| 536 | aim_rxcallback_t userfunc; | |
| 537 | char *keystr; | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
538 | GSList *tlvlist; |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
539 | gboolean truncate_pass; |
| 13235 | 540 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
541 | keylen = byte_stream_get16(bs); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
542 | keystr = byte_stream_getstr(bs, keylen); |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
543 | tlvlist = aim_tlvlist_read(bs); |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
544 | |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
545 | /* |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
546 | * If the truncate_pass TLV exists then we should truncate the |
|
22127
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
547 | * user's password to 8 characters. This flag is sent to us |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
548 | * when logging in with an AOL user's username. |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
549 | */ |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
550 | truncate_pass = aim_tlv_gettlv(tlvlist, 0x0026, 1) != NULL; |
| 13235 | 551 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
552 | /* XXX - When GiantGrayPanda signed on AIM I got a thing asking me to register |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
553 | * for the netscape network. This SNAC had a type 0x0058 TLV with length 10. |
| 13235 | 554 | * Data is 0x0007 0004 3e19 ae1e 0006 0004 0000 0005 */ |
| 555 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
556 | if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
557 | ret = userfunc(od, conn, frame, keystr, (int)truncate_pass); |
| 13235 | 558 | |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
559 | g_free(keystr); |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
560 | aim_tlvlist_free(tlvlist); |
| 13235 | 561 | |
| 562 | return ret; | |
| 563 | } | |
| 564 | ||
| 565 | /** | |
| 566 | * Subtype 0x000a | |
| 567 | * | |
| 568 | * Receive SecurID request. | |
| 569 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
570 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
571 | got_securid_request(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 572 | { |
| 573 | int ret = 0; | |
| 574 | aim_rxcallback_t userfunc; | |
| 575 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
576 | if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
577 | ret = userfunc(od, conn, frame); |
| 13235 | 578 | |
| 579 | return ret; | |
| 580 | } | |
| 581 | ||
| 582 | /** | |
| 583 | * Subtype 0x000b | |
| 584 | * | |
| 585 | * Send SecurID response. | |
| 586 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
587 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
588 | aim_auth_securid_send(OscarData *od, const char *securid) |
| 13235 | 589 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
590 | FlapConnection *conn; |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
591 | FlapFrame *frame; |
| 13235 | 592 | aim_snacid_t snacid; |
| 593 | int len; | |
| 594 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
595 | if (!od || !(conn = flap_connection_getbytype_all(od, SNAC_FAMILY_AUTH)) || !securid) |
| 13235 | 596 | return -EINVAL; |
| 597 | ||
| 598 | len = strlen(securid); | |
| 599 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
600 | frame = flap_frame_new(od, 0x02, 10+2+len); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
601 | |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
602 | snacid = aim_cachesnac(od, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_RESPONSE, 0x0000, NULL, 0); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
603 | aim_putsnac(&frame->data, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_RESPONSE, 0x0000, 0); |
| 13235 | 604 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
605 | byte_stream_put16(&frame->data, len); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
606 | byte_stream_putstr(&frame->data, securid); |
| 13235 | 607 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
608 | flap_connection_send(conn, frame); |
| 13235 | 609 | |
| 610 | return 0; | |
| 611 | } | |
| 612 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
613 | static void |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
614 | auth_shutdown(OscarData *od, aim_module_t *mod) |
| 13235 | 615 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
616 | if (od->authinfo != NULL) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
617 | { |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
618 | g_free(od->authinfo->bn); |
|
25152
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
619 | g_free(od->authinfo->bosip); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
620 | g_free(od->authinfo->errorurl); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
621 | g_free(od->authinfo->email); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
622 | g_free(od->authinfo->chpassurl); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
623 | g_free(od->authinfo->latestrelease.name); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
624 | g_free(od->authinfo->latestrelease.url); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
625 | g_free(od->authinfo->latestrelease.info); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
626 | g_free(od->authinfo->latestbeta.name); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
627 | g_free(od->authinfo->latestbeta.url); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
628 | g_free(od->authinfo->latestbeta.info); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
629 | g_free(od->authinfo); |
| 13235 | 630 | } |
| 631 | } | |
| 632 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
633 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
634 | snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 635 | { |
| 636 | if (snac->subtype == 0x0003) | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
637 | return parse(od, conn, mod, frame, snac, bs); |
| 13235 | 638 | else if (snac->subtype == 0x0007) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
639 | return keyparse(od, conn, mod, frame, snac, bs); |
| 13235 | 640 | else if (snac->subtype == 0x000a) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
641 | return got_securid_request(od, conn, mod, frame, snac, bs); |
| 13235 | 642 | |
| 643 | return 0; | |
| 644 | } | |
| 645 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
646 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
647 | auth_modfirst(OscarData *od, aim_module_t *mod) |
| 13235 | 648 | { |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
649 | mod->family = SNAC_FAMILY_AUTH; |
| 13235 | 650 | mod->version = 0x0000; |
| 651 | mod->flags = 0; | |
| 652 | strncpy(mod->name, "auth", sizeof(mod->name)); | |
| 653 | mod->snachandler = snachandler; | |
| 654 | mod->shutdown = auth_shutdown; | |
| 655 | ||
| 656 | return 0; | |
| 657 | } |