Mon, 10 Apr 2006 02:47:43 +0000
[gaim-migrate @ 15993]
Get rid of an error message when sending or recieving a file. It was
something along the lines of "can not call g_source_remove on < 0"
and was happening because I was calling gaim_input_remove() twice.
| 13235 | 1 | /* |
| 2 | * Gaim's oscar protocol plugin | |
| 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 | |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 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 | ||
| 35 | #define USE_XOR_FOR_ICQ | |
| 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 |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
82 | aim_encode_password_md5(const char *password, const char *key, guint8 *digest) |
| 13235 | 83 | { |
| 84 | GaimCipher *cipher; | |
| 85 | GaimCipherContext *context; | |
| 86 | ||
| 87 | cipher = gaim_ciphers_find_cipher("md5"); | |
| 88 | ||
| 89 | context = gaim_cipher_context_new(cipher, NULL); | |
| 90 | gaim_cipher_context_append(context, (const guchar *)key, strlen(key)); | |
| 91 | gaim_cipher_context_append(context, (const guchar *)password, strlen(password)); | |
| 92 | gaim_cipher_context_append(context, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | |
| 93 | gaim_cipher_context_digest(context, 16, digest, NULL); | |
| 94 | gaim_cipher_context_destroy(context); | |
| 95 | ||
| 96 | return 0; | |
| 97 | } | |
| 98 | #else | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
99 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
100 | aim_encode_password_md5(const char *password, const char *key, guint8 *digest) |
| 13235 | 101 | { |
| 102 | GaimCipher *cipher; | |
| 103 | GaimCipherContext *context; | |
| 104 | guchar passdigest[16]; | |
| 105 | ||
| 106 | cipher = gaim_ciphers_find_cipher("md5"); | |
| 107 | ||
| 108 | context = gaim_cipher_context_new(cipher, NULL); | |
| 109 | gaim_cipher_context_append(context, (const guchar *)password, strlen(password)); | |
| 110 | gaim_cipher_context_digest(context, 16, passdigest, NULL); | |
| 111 | gaim_cipher_context_destroy(context); | |
| 112 | ||
| 113 | context = gaim_cipher_context_new(cipher, NULL); | |
| 114 | gaim_cipher_context_append(context, (const guchar *)key, strlen(key)); | |
| 115 | gaim_cipher_context_append(context, passdigest, 16); | |
| 116 | gaim_cipher_context_append(context, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | |
| 117 | gaim_cipher_context_digest(context, 16, digest, NULL); | |
| 118 | gaim_cipher_context_destroy(context); | |
| 119 | ||
| 120 | return 0; | |
| 121 | } | |
| 122 | #endif | |
| 123 | ||
| 124 | #ifdef USE_XOR_FOR_ICQ | |
| 125 | /* | |
| 126 | * Part two of the ICQ hack. Note the ignoring of the key. | |
| 127 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
128 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
129 | goddamnicq2(OscarData *od, FlapConnection *conn, const char *sn, const char *password, ClientInfo *ci) |
| 13235 | 130 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
131 | FlapFrame *frame; |
| 13235 | 132 | aim_tlvlist_t *tl = NULL; |
| 133 | int passwdlen; | |
| 134 | guint8 *password_encoded; | |
| 135 | ||
| 136 | passwdlen = strlen(password); | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
137 | password_encoded = (guint8 *)malloc(passwdlen+1); |
| 13235 | 138 | if (passwdlen > MAXICQPASSLEN) |
| 139 | passwdlen = MAXICQPASSLEN; | |
| 140 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
141 | frame = flap_frame_new(od, 0x01, 1152); |
| 13235 | 142 | |
| 143 | aim_encode_password(password, password_encoded); | |
| 144 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
145 | byte_stream_put32(&frame->data, 0x00000001); /* FLAP Version */ |
| 13235 | 146 | aim_tlvlist_add_str(&tl, 0x0001, sn); |
| 147 | aim_tlvlist_add_raw(&tl, 0x0002, passwdlen, password_encoded); | |
| 148 | ||
| 149 | if (ci->clientstring) | |
| 150 | aim_tlvlist_add_str(&tl, 0x0003, ci->clientstring); | |
| 151 | aim_tlvlist_add_16(&tl, 0x0016, (guint16)ci->clientid); | |
| 152 | aim_tlvlist_add_16(&tl, 0x0017, (guint16)ci->major); | |
| 153 | aim_tlvlist_add_16(&tl, 0x0018, (guint16)ci->minor); | |
| 154 | aim_tlvlist_add_16(&tl, 0x0019, (guint16)ci->point); | |
| 155 | aim_tlvlist_add_16(&tl, 0x001a, (guint16)ci->build); | |
| 156 | aim_tlvlist_add_32(&tl, 0x0014, (guint32)ci->distrib); /* distribution chan */ | |
| 157 | aim_tlvlist_add_str(&tl, 0x000f, ci->lang); | |
| 158 | aim_tlvlist_add_str(&tl, 0x000e, ci->country); | |
| 159 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
160 | aim_tlvlist_write(&frame->data, &tl); |
| 13235 | 161 | |
| 162 | free(password_encoded); | |
| 163 | aim_tlvlist_free(&tl); | |
| 164 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
165 | flap_connection_send(conn, frame); |
| 13235 | 166 | |
| 167 | return 0; | |
| 168 | } | |
| 169 | #endif | |
| 170 | ||
| 171 | /* | |
| 172 | * Subtype 0x0002 | |
| 173 | * | |
| 174 | * This is the initial login request packet. | |
| 175 | * | |
| 176 | * NOTE!! If you want/need to make use of the aim_sendmemblock() function, | |
| 177 | * then the client information you send here must exactly match the | |
| 178 | * executable that you're pulling the data from. | |
| 179 | * | |
| 180 | * Java AIM 1.1.19: | |
| 181 | * 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" | |
| 182 | * clientid = 0x0001 | |
| 183 | * major = 0x0001 | |
| 184 | * minor = 0x0001 | |
| 185 | * point = (not sent) | |
| 186 | * build = 0x0013 | |
| 187 | * unknown= (not sent) | |
|
13240
db5187cc40d1
[gaim-migrate @ 15605]
Mark Doliner <markdoliner@pidgin.im>
parents:
13235
diff
changeset
|
188 | * |
| 13235 | 189 | * AIM for Linux 1.1.112: |
| 190 | * clientstring = "AOL Instant Messenger (SM)" | |
| 191 | * clientid = 0x1d09 | |
| 192 | * major = 0x0001 | |
| 193 | * minor = 0x0001 | |
| 194 | * point = 0x0001 | |
| 195 | * build = 0x0070 | |
| 196 | * unknown= 0x0000008b | |
| 197 | * serverstore = 0x01 | |
| 198 | * | |
| 199 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
200 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
201 | aim_send_login(OscarData *od, FlapConnection *conn, const char *sn, const char *password, ClientInfo *ci, const char *key) |
| 13235 | 202 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
203 | FlapFrame *frame; |
| 13235 | 204 | aim_tlvlist_t *tl = NULL; |
| 205 | guint8 digest[16]; | |
| 206 | aim_snacid_t snacid; | |
| 207 | ||
| 208 | if (!ci || !sn || !password) | |
| 209 | return -EINVAL; | |
| 210 | ||
| 211 | #ifdef USE_XOR_FOR_ICQ | |
| 212 | /* If we're signing on an ICQ account then use the older, XOR login method */ | |
| 213 | if (isdigit(sn[0])) | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
214 | return goddamnicq2(od, conn, sn, password, ci); |
| 13235 | 215 | #endif |
| 216 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
217 | frame = flap_frame_new(od, 0x02, 1152); |
| 13235 | 218 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
219 | snacid = aim_cachesnac(od, 0x0017, 0x0002, 0x0000, NULL, 0); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
220 | aim_putsnac(&frame->data, 0x0017, 0x0002, 0x0000, snacid); |
| 13235 | 221 | |
| 222 | aim_tlvlist_add_str(&tl, 0x0001, sn); | |
| 223 | ||
| 224 | /* Truncate ICQ passwords, if necessary */ | |
| 225 | if (isdigit(sn[0]) && (strlen(password) > MAXICQPASSLEN)) | |
| 226 | { | |
| 227 | char truncated[MAXICQPASSLEN + 1]; | |
| 228 | strncpy(truncated, password, MAXICQPASSLEN); | |
| 229 | truncated[MAXICQPASSLEN] = 0; | |
| 230 | aim_encode_password_md5(truncated, key, digest); | |
| 231 | } | |
| 232 | else | |
| 233 | { | |
| 234 | aim_encode_password_md5(password, key, digest); | |
| 235 | } | |
| 236 | ||
| 237 | aim_tlvlist_add_raw(&tl, 0x0025, 16, digest); | |
| 238 | ||
| 239 | #ifndef USE_OLD_MD5 | |
| 240 | aim_tlvlist_add_noval(&tl, 0x004c); | |
| 241 | #endif | |
| 242 | ||
| 243 | if (ci->clientstring) | |
| 244 | aim_tlvlist_add_str(&tl, 0x0003, ci->clientstring); | |
| 245 | aim_tlvlist_add_16(&tl, 0x0016, (guint16)ci->clientid); | |
| 246 | aim_tlvlist_add_16(&tl, 0x0017, (guint16)ci->major); | |
| 247 | aim_tlvlist_add_16(&tl, 0x0018, (guint16)ci->minor); | |
| 248 | aim_tlvlist_add_16(&tl, 0x0019, (guint16)ci->point); | |
| 249 | aim_tlvlist_add_16(&tl, 0x001a, (guint16)ci->build); | |
| 250 | aim_tlvlist_add_32(&tl, 0x0014, (guint32)ci->distrib); | |
| 251 | aim_tlvlist_add_str(&tl, 0x000f, ci->lang); | |
| 252 | aim_tlvlist_add_str(&tl, 0x000e, ci->country); | |
| 253 | ||
| 254 | /* | |
| 255 | * If set, old-fashioned buddy lists will not work. You will need | |
| 256 | * to use SSI. | |
| 257 | */ | |
| 258 | aim_tlvlist_add_8(&tl, 0x004a, 0x01); | |
| 259 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
260 | aim_tlvlist_write(&frame->data, &tl); |
| 13235 | 261 | |
| 262 | aim_tlvlist_free(&tl); | |
| 263 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
264 | flap_connection_send(conn, frame); |
| 13235 | 265 | |
| 266 | return 0; | |
| 267 | } | |
| 268 | ||
| 269 | /* | |
| 270 | * This is sent back as a general response to the login command. | |
| 271 | * 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
|
272 | * presence of certain TLVs. |
| 13235 | 273 | * |
| 274 | * The client should check the value passed as errorcode. If | |
| 275 | * its nonzero, there was an error. | |
| 276 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
277 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
278 | parse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 279 | { |
| 280 | aim_tlvlist_t *tlvlist; | |
| 281 | aim_rxcallback_t userfunc; | |
| 282 | struct aim_authresp_info *info; | |
| 283 | int ret = 0; | |
| 284 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
285 | info = g_new0(struct aim_authresp_info, 1); |
| 13235 | 286 | |
| 287 | /* | |
| 288 | * Read block of TLVs. All further data is derived | |
| 289 | * from what is parsed here. | |
| 290 | */ | |
| 291 | tlvlist = aim_tlvlist_read(bs); | |
| 292 | ||
| 293 | /* | |
| 294 | * No matter what, we should have a screen name. | |
| 295 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
296 | memset(od->sn, 0, sizeof(od->sn)); |
| 13235 | 297 | if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) { |
| 298 | info->sn = aim_tlv_getstr(tlvlist, 0x0001, 1); | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
299 | strncpy(od->sn, info->sn, sizeof(od->sn)); |
| 13235 | 300 | } |
| 301 | ||
| 302 | /* | |
| 303 | * Check for an error code. If so, we should also | |
| 304 | * have an error url. | |
| 305 | */ | |
| 306 | if (aim_tlv_gettlv(tlvlist, 0x0008, 1)) | |
| 307 | info->errorcode = aim_tlv_get16(tlvlist, 0x0008, 1); | |
| 308 | if (aim_tlv_gettlv(tlvlist, 0x0004, 1)) | |
| 309 | info->errorurl = aim_tlv_getstr(tlvlist, 0x0004, 1); | |
| 310 | ||
| 311 | /* | |
| 312 | * BOS server address. | |
| 313 | */ | |
| 314 | if (aim_tlv_gettlv(tlvlist, 0x0005, 1)) | |
| 315 | info->bosip = aim_tlv_getstr(tlvlist, 0x0005, 1); | |
| 316 | ||
| 317 | /* | |
| 318 | * Authorization cookie. | |
| 319 | */ | |
| 320 | if (aim_tlv_gettlv(tlvlist, 0x0006, 1)) { | |
| 321 | aim_tlv_t *tmptlv; | |
| 322 | ||
| 323 | tmptlv = aim_tlv_gettlv(tlvlist, 0x0006, 1); | |
| 324 | ||
| 325 | info->cookielen = tmptlv->length; | |
| 326 | info->cookie = tmptlv->value; | |
| 327 | } | |
| 328 | ||
| 329 | /* | |
| 330 | * The email address attached to this account | |
| 331 | * Not available for ICQ or @mac.com logins. | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
332 | * If you receive this TLV, then you are allowed to use |
| 13235 | 333 | * family 0x0018 to check the status of your email. |
| 334 | * XXX - Not really true! | |
| 335 | */ | |
| 336 | if (aim_tlv_gettlv(tlvlist, 0x0011, 1)) | |
| 337 | info->email = aim_tlv_getstr(tlvlist, 0x0011, 1); | |
| 338 | ||
| 339 | /* | |
| 340 | * The registration status. (Not real sure what it means.) | |
| 341 | * Not available for ICQ or @mac.com logins. | |
| 342 | * | |
| 343 | * 1 = No disclosure | |
| 344 | * 2 = Limited disclosure | |
| 345 | * 3 = Full disclosure | |
| 346 | * | |
| 347 | * This has to do with whether your email address is available | |
| 348 | * to other users or not. AFAIK, this feature is no longer used. | |
| 349 | * | |
| 350 | * Means you can use the admin family? (0x0007) | |
| 351 | * | |
| 352 | */ | |
| 353 | if (aim_tlv_gettlv(tlvlist, 0x0013, 1)) | |
| 354 | info->regstatus = aim_tlv_get16(tlvlist, 0x0013, 1); | |
| 355 | ||
| 356 | if (aim_tlv_gettlv(tlvlist, 0x0040, 1)) | |
| 357 | info->latestbeta.build = aim_tlv_get32(tlvlist, 0x0040, 1); | |
| 358 | if (aim_tlv_gettlv(tlvlist, 0x0041, 1)) | |
| 359 | info->latestbeta.url = aim_tlv_getstr(tlvlist, 0x0041, 1); | |
| 360 | if (aim_tlv_gettlv(tlvlist, 0x0042, 1)) | |
| 361 | info->latestbeta.info = aim_tlv_getstr(tlvlist, 0x0042, 1); | |
| 362 | if (aim_tlv_gettlv(tlvlist, 0x0043, 1)) | |
| 363 | info->latestbeta.name = aim_tlv_getstr(tlvlist, 0x0043, 1); | |
| 364 | ||
| 365 | #if 0 | |
| 366 | if (aim_tlv_gettlv(tlvlist, 0x0048, 1)) { | |
| 367 | /* beta serial */ | |
| 368 | } | |
| 369 | #endif | |
| 370 | ||
| 371 | if (aim_tlv_gettlv(tlvlist, 0x0044, 1)) | |
| 372 | info->latestrelease.build = aim_tlv_get32(tlvlist, 0x0044, 1); | |
| 373 | if (aim_tlv_gettlv(tlvlist, 0x0045, 1)) | |
| 374 | info->latestrelease.url = aim_tlv_getstr(tlvlist, 0x0045, 1); | |
| 375 | if (aim_tlv_gettlv(tlvlist, 0x0046, 1)) | |
| 376 | info->latestrelease.info = aim_tlv_getstr(tlvlist, 0x0046, 1); | |
| 377 | if (aim_tlv_gettlv(tlvlist, 0x0047, 1)) | |
| 378 | info->latestrelease.name = aim_tlv_getstr(tlvlist, 0x0047, 1); | |
| 379 | ||
| 380 | #if 0 | |
| 381 | if (aim_tlv_gettlv(tlvlist, 0x0049, 1)) { | |
| 382 | /* lastest release serial */ | |
| 383 | } | |
| 384 | #endif | |
| 385 | ||
| 386 | /* | |
| 387 | * URL to change password. | |
| 388 | */ | |
| 389 | if (aim_tlv_gettlv(tlvlist, 0x0054, 1)) | |
| 390 | info->chpassurl = aim_tlv_getstr(tlvlist, 0x0054, 1); | |
| 391 | ||
| 392 | #if 0 | |
| 393 | /* | |
| 394 | * Unknown. Seen on an @mac.com screen name with value of 0x003f | |
| 395 | */ | |
| 396 | if (aim_tlv_gettlv(tlvlist, 0x0055, 1)) { | |
| 397 | /* Unhandled */ | |
| 398 | } | |
| 399 | #endif | |
| 400 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
401 | od->authinfo = info; |
| 13235 | 402 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
403 | if ((userfunc = aim_callhandler(od, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003))) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
404 | ret = userfunc(od, conn, frame, info); |
| 13235 | 405 | |
| 406 | aim_tlvlist_free(&tlvlist); | |
| 407 | ||
| 408 | return ret; | |
| 409 | } | |
| 410 | ||
| 411 | #ifdef USE_XOR_FOR_ICQ | |
| 412 | /* | |
| 413 | * Subtype 0x0007 (kind of) - Send a fake type 0x0007 SNAC to the client | |
| 414 | * | |
| 415 | * This is a bit confusing. | |
| 416 | * | |
| 417 | * Normal SNAC login goes like this: | |
| 418 | * - connect | |
| 419 | * - server sends flap version | |
| 420 | * - client sends flap version | |
| 421 | * - client sends screen name (17/6) | |
| 422 | * - server sends hash key (17/7) | |
| 423 | * - client sends auth request (17/2 -- aim_send_login) | |
| 424 | * - server yells | |
| 425 | * | |
| 426 | * XOR login (for ICQ) goes like this: | |
| 427 | * - connect | |
| 428 | * - server sends flap version | |
| 429 | * - client sends auth request which contains flap version (aim_send_login) | |
| 430 | * - server yells | |
| 431 | * | |
| 432 | * For the client API, we make them implement the most complicated version, | |
| 433 | * and for the simpler version, we fake it and make it look like the more | |
| 434 | * complicated process. | |
| 435 | * | |
| 436 | * This is done by giving the client a faked key, just so we can convince | |
| 437 | * them to call aim_send_login right away, which will detect the session | |
| 438 | * flag that says this is XOR login and ignore the key, sending an ICQ | |
| 439 | * login request instead of the normal SNAC one. | |
| 440 | * | |
| 441 | * As soon as AOL makes ICQ log in the same way as AIM, this is /gone/. | |
| 442 | * | |
| 443 | * XXX This may cause problems if the client relies on callbacks only | |
| 444 | * being called from the context of aim_rxdispatch()... | |
| 445 | * | |
| 446 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
447 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
448 | goddamnicq(OscarData *od, FlapConnection *conn, const char *sn) |
| 13235 | 449 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
450 | FlapFrame frame; |
| 13235 | 451 | aim_rxcallback_t userfunc; |
| 452 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
453 | if ((userfunc = aim_callhandler(od, 0x0017, 0x0007))) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
454 | userfunc(od, conn, &frame, ""); |
| 13235 | 455 | |
| 456 | return 0; | |
| 457 | } | |
| 458 | #endif | |
| 459 | ||
| 460 | /* | |
| 461 | * Subtype 0x0006 | |
| 462 | * | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
463 | * In AIM 3.5 protocol, the first stage of login is to request login from the |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
464 | * Authorizer, passing it the screen name for verification. If the name is |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
465 | * 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
|
466 | * 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
|
467 | * login command (0017/0002). |
| 13235 | 468 | * |
| 469 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
470 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
471 | aim_request_login(OscarData *od, FlapConnection *conn, const char *sn) |
| 13235 | 472 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
473 | FlapFrame *frame; |
| 13235 | 474 | aim_snacid_t snacid; |
| 475 | aim_tlvlist_t *tl = NULL; | |
| 476 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
477 | if (!od || !conn || !sn) |
| 13235 | 478 | return -EINVAL; |
| 479 | ||
| 480 | #ifdef USE_XOR_FOR_ICQ | |
| 481 | if (isdigit(sn[0])) | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
482 | return goddamnicq(od, conn, sn); |
| 13235 | 483 | #endif |
| 484 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
485 | frame = flap_frame_new(od, 0x02, 10+2+2+strlen(sn)+8); |
| 13235 | 486 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
487 | snacid = aim_cachesnac(od, 0x0017, 0x0006, 0x0000, NULL, 0); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
488 | aim_putsnac(&frame->data, 0x0017, 0x0006, 0x0000, snacid); |
| 13235 | 489 | |
| 490 | aim_tlvlist_add_str(&tl, 0x0001, sn); | |
| 491 | ||
| 492 | /* Tell the server we support SecurID logins. */ | |
| 493 | aim_tlvlist_add_noval(&tl, 0x004b); | |
| 494 | ||
| 495 | /* Unknown. Sent in recent WinAIM clients.*/ | |
| 496 | aim_tlvlist_add_noval(&tl, 0x005a); | |
| 497 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
498 | aim_tlvlist_write(&frame->data, &tl); |
| 13235 | 499 | aim_tlvlist_free(&tl); |
| 500 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
501 | flap_connection_send(conn, frame); |
| 13235 | 502 | |
| 503 | return 0; | |
| 504 | } | |
| 505 | ||
| 506 | /* | |
| 507 | * Subtype 0x0007 | |
| 508 | * | |
| 509 | * Middle handler for 0017/0007 SNACs. Contains the auth key prefixed | |
| 510 | * by only its length in a two byte word. | |
| 511 | * | |
| 512 | * Calls the client, which should then use the value to call aim_send_login. | |
| 513 | * | |
| 514 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
515 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
516 | keyparse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 517 | { |
| 518 | int keylen, ret = 1; | |
| 519 | aim_rxcallback_t userfunc; | |
| 520 | char *keystr; | |
| 521 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
522 | keylen = byte_stream_get16(bs); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
523 | keystr = byte_stream_getstr(bs, keylen); |
| 13235 | 524 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
525 | /* 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
|
526 | * for the netscape network. This SNAC had a type 0x0058 TLV with length 10. |
| 13235 | 527 | * Data is 0x0007 0004 3e19 ae1e 0006 0004 0000 0005 */ |
| 528 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
529 | if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
530 | ret = userfunc(od, conn, frame, keystr); |
| 13235 | 531 | |
| 532 | free(keystr); | |
| 533 | ||
| 534 | return ret; | |
| 535 | } | |
| 536 | ||
| 537 | /** | |
| 538 | * Subtype 0x000a | |
| 539 | * | |
| 540 | * Receive SecurID request. | |
| 541 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
542 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
543 | got_securid_request(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 544 | { |
| 545 | int ret = 0; | |
| 546 | aim_rxcallback_t userfunc; | |
| 547 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
548 | if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
549 | ret = userfunc(od, conn, frame); |
| 13235 | 550 | |
| 551 | return ret; | |
| 552 | } | |
| 553 | ||
| 554 | /** | |
| 555 | * Subtype 0x000b | |
| 556 | * | |
| 557 | * Send SecurID response. | |
| 558 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
559 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
560 | aim_auth_securid_send(OscarData *od, const char *securid) |
| 13235 | 561 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
562 | FlapConnection *conn; |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
563 | FlapFrame *frame; |
| 13235 | 564 | aim_snacid_t snacid; |
| 565 | int len; | |
| 566 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
567 | if (!od || !(conn = flap_connection_getbytype_all(od, SNAC_FAMILY_AUTH)) || !securid) |
| 13235 | 568 | return -EINVAL; |
| 569 | ||
| 570 | len = strlen(securid); | |
| 571 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
572 | frame = flap_frame_new(od, 0x02, 10+2+len); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
573 | |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
574 | 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
|
575 | aim_putsnac(&frame->data, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_RESPONSE, 0x0000, 0); |
| 13235 | 576 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
577 | byte_stream_put16(&frame->data, len); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
578 | byte_stream_putstr(&frame->data, securid); |
| 13235 | 579 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
580 | flap_connection_send(conn, frame); |
| 13235 | 581 | |
| 582 | return 0; | |
| 583 | } | |
| 584 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
585 | static void |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
586 | auth_shutdown(OscarData *od, aim_module_t *mod) |
| 13235 | 587 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
588 | if (od->authinfo != NULL) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
589 | { |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
590 | free(od->authinfo->sn); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
591 | free(od->authinfo->bosip); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
592 | free(od->authinfo->errorurl); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
593 | free(od->authinfo->email); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
594 | free(od->authinfo->chpassurl); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
595 | free(od->authinfo->latestrelease.name); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
596 | free(od->authinfo->latestrelease.url); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
597 | free(od->authinfo->latestrelease.info); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
598 | free(od->authinfo->latestbeta.name); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
599 | free(od->authinfo->latestbeta.url); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
600 | free(od->authinfo->latestbeta.info); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
601 | free(od->authinfo); |
| 13235 | 602 | } |
| 603 | } | |
| 604 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
605 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
606 | snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 607 | { |
| 608 | if (snac->subtype == 0x0003) | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
609 | return parse(od, conn, mod, frame, snac, bs); |
| 13235 | 610 | else if (snac->subtype == 0x0007) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
611 | return keyparse(od, conn, mod, frame, snac, bs); |
| 13235 | 612 | else if (snac->subtype == 0x000a) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
613 | return got_securid_request(od, conn, mod, frame, snac, bs); |
| 13235 | 614 | |
| 615 | return 0; | |
| 616 | } | |
| 617 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
618 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
619 | auth_modfirst(OscarData *od, aim_module_t *mod) |
| 13235 | 620 | { |
| 621 | mod->family = 0x0017; | |
| 622 | mod->version = 0x0000; | |
| 623 | mod->flags = 0; | |
| 624 | strncpy(mod->name, "auth", sizeof(mod->name)); | |
| 625 | mod->snachandler = snachandler; | |
| 626 | mod->shutdown = auth_shutdown; | |
| 627 | ||
| 628 | return 0; | |
| 629 | } |