Changeset c3e349e for protocols/yahoo
- Timestamp:
- 2009-10-03T22:25:36Z (15 years ago)
- Branches:
- master
- Children:
- bdad407
- Parents:
- 4fefb77
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/yahoo/libyahoo2.c
r4fefb77 rc3e349e 92 92 93 93 static void yahoo_process_auth_response(struct http_request *req); 94 95 /* What's this used for actually? */96 static void _yahoo_http_connected(int id, int fd, int error, void *data);97 94 98 95 #ifdef USE_STRUCT_CALLBACKS … … 1533 1530 break; 1534 1531 case 65: 1532 g_free(cur_group); 1535 1533 cur_group = strdup(pair->value); 1536 1534 break; … … 1551 1549 } 1552 1550 } 1551 1552 g_free(cur_group); 1553 1553 1554 1554 /* we could be getting multiple packets here */ … … 1557 1557 1558 1558 YAHOO_CALLBACK(ext_yahoo_got_buddies)(yd->client_id, yd->buddies); 1559 1560 1559 1561 1560 /*** We login at the very end of the packet communication */ … … 1637 1636 } 1638 1637 1639 // if(yd->cookie_y && yd->cookie_t && yd->cookie_c)1640 1638 if(yd->cookie_y && yd->cookie_t) 1641 1639 YAHOO_CALLBACK(ext_yahoo_got_cookies)(yd->client_id); … … 3645 3643 } 3646 3644 3647 / /#define LOG(x...) printf x3645 /* #define LOG(x...) printf x */ 3648 3646 3649 3647 static void yahoo_process_auth_response(struct http_request *req) … … 3656 3654 int is_ymsgr = 0; 3657 3655 3658 struct yahoo_data *yd = NULL;3659 3656 struct yahoo_input_data *yid = req->data; 3660 3657 3661 unsignedchar crypt_hash[25];3658 char crypt_hash[25]; 3662 3659 3663 3660 md5_byte_t result[16]; 3664 3661 md5_state_t ctx; 3665 3662 3666 struct yahoo_packet *packet =NULL; 3663 struct yahoo_packet *packet = NULL; 3664 3665 if (y_list_find(inputs, yid) == NULL) 3666 return; 3667 3668 if (req->status_code != 200) { 3669 error_code = 3000 + req->status_code; 3670 goto FAIL; 3671 } 3667 3672 3668 3673 token = req->reply_body; … … 3672 3677 *line_end = '\0'; 3673 3678 3674 line_end+=2; 3675 } 3676 3677 error_code = atoi((char *)token); 3679 line_end += 2; 3680 } 3681 3682 if (sscanf(token, "%d", &error_code) != 1) { 3683 error_code = 3000; 3684 goto FAIL; 3685 } 3678 3686 3679 3687 switch(error_code) { 3680 3688 case 0: 3681 3689 /* successful */ 3682 LOG(("successful\n"));3683 break; 3690 break; 3691 3684 3692 case 1212: 3685 /* Incorrect ID or password */3686 3693 LOG(("Incorrect ID or password\n")); 3687 3688 return; 3694 error_code = YAHOO_LOGIN_PASSWD; 3695 goto FAIL; 3696 3689 3697 case 1213: 3690 /* Security lock from too many failed login attempts */3691 3698 LOG(("Security lock from too many failed login attempts\n")); 3692 3693 return;3699 error_code = YAHOO_LOGIN_LOCK; 3700 goto FAIL; 3694 3701 3695 3702 case 1214: 3696 /* Security lock */3697 3703 LOG(("Security lock\n")); 3698 3699 return; 3704 goto FAIL; 3700 3705 3701 3706 case 1235: 3702 /* User ID not taken yet */3703 3707 LOG(("User ID not taken yet\n")); 3704 3705 return;3708 error_code = YAHOO_LOGIN_UNAME; 3709 goto FAIL; 3706 3710 3707 3711 case 1216: 3708 /* Seems to be a lock, but shows the same generic User ID/Password failure */3709 3712 LOG(("Seems to be a lock, but shows the same generic User ID/Password failure\n")); 3710 3711 return; 3712 case 100: 3713 /* Username and password cannot be blank */ 3714 LOG(("Username and password cannot be blank\n")); 3715 3716 return; 3713 goto FAIL; 3714 3717 3715 default: 3718 3716 /* Unknown error code */ 3719 3717 LOG(("Unknown Error\n")); 3720 3721 return; 3718 goto FAIL; 3722 3719 } 3723 3720 … … 3728 3725 LOG(("Oops! There was no ymsgr=. Where do I get my token from now :(")); 3729 3726 LOG(("I got this:\n\n%s\n",line_end)); 3730 return;3731 /* Error */3727 error_code = 2201; 3728 goto FAIL; 3732 3729 } 3733 3730 … … 3738 3735 if(line_end) { 3739 3736 *line_end = '\0'; 3740 line_end +=2;3737 line_end += 2; 3741 3738 } 3742 3739 … … 3748 3745 "https://login.yahoo.com/config/pwtoken_login?" 3749 3746 "src=ymsgr&ts=&token=%s", token); 3750 3747 3751 3748 http_dorequest_url(url, yahoo_process_auth_response, yid); 3749 3752 3750 g_free(url); 3753 3751 … … 3761 3759 } 3762 3760 3763 cookie = strstr(req->reply_headers, "Set-Cookie: Y="); 3764 3765 if(!cookie) { 3761 if((cookie = strstr(req->reply_headers, "Set-Cookie: Y=")) && 3762 (line_end = strstr(cookie + 14, "\r\n"))) { 3763 *line_end = '\0'; 3764 yid->yd->cookie_y = strdup(cookie + 14); 3765 *line_end = ';'; 3766 } else { 3766 3767 /* Cry. */ 3767 3768 LOG(("NO Y Cookie!")); 3768 return; 3769 } 3770 3771 cookie+=14; 3772 3773 line_end = strstr(cookie, "\r\n"); 3774 *line_end = '\0'; 3775 3776 LOG(("Cookie length: %d", strlen(cookie))); 3777 3778 yid->yd->cookie_y = strdup(cookie); 3779 *line_end = ';'; 3780 3781 cookie = strstr(req->reply_headers, "Set-Cookie: T="); 3782 if(!cookie) { 3769 error_code = 2202; 3770 goto FAIL; 3771 } 3772 3773 if((cookie = strstr(req->reply_headers, "Set-Cookie: T=")) && 3774 (line_end = strstr(cookie + 14, "\r\n"))) { 3775 *line_end = '\0'; 3776 yid->yd->cookie_t = strdup(cookie + 14); 3777 *line_end = ';'; 3778 } else { 3779 /* Cry. */ 3783 3780 LOG(("NO T Cookie!")); 3784 /* Cry. */ 3785 return; 3786 } 3787 3788 cookie+=14; 3789 3790 line_end = strstr(cookie, "\r\n"); 3791 *line_end = '\0'; 3792 3793 yid->yd->cookie_t = strdup(cookie); 3794 3795 LOG(("My Cookies ::\n Y: %s\nT: %s\n\n", yid->yd->cookie_y, yid->yd->cookie_t)); 3781 error_code = 2203; 3782 goto FAIL; 3783 } 3796 3784 3797 3785 md5_init(&ctx); … … 3800 3788 md5_finish(&ctx, result); 3801 3789 3802 to_y64(crypt_hash, result, 16); 3803 3804 yd = yid->yd; 3805 3806 //yid = find_input_by_id_and_type(yd->client_id, YAHOO_CONNECTION_PAGER); 3807 3808 packet = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->initial_status, yd->session_id); 3809 yahoo_packet_hash(packet, 1, yd->user); 3810 yahoo_packet_hash(packet, 0, yd->user); 3811 yahoo_packet_hash(packet, 277, yd->cookie_y); 3812 yahoo_packet_hash(packet, 278, yd->cookie_t); 3790 to_y64((unsigned char*)crypt_hash, result, 16); 3791 3792 packet = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yid->yd->initial_status, yid->yd->session_id); 3793 yahoo_packet_hash(packet, 1, yid->yd->user); 3794 yahoo_packet_hash(packet, 0, yid->yd->user); 3795 yahoo_packet_hash(packet, 277, yid->yd->cookie_y); 3796 yahoo_packet_hash(packet, 278, yid->yd->cookie_t); 3813 3797 yahoo_packet_hash(packet, 307, crypt_hash); 3814 3798 yahoo_packet_hash(packet, 244, "2097087"); /* Rekkanoryo says this is the build number */ 3815 yahoo_packet_hash(packet, 2, y d->user);3799 yahoo_packet_hash(packet, 2, yid->yd->user); 3816 3800 yahoo_packet_hash(packet, 2, "1"); 3817 3801 yahoo_packet_hash(packet, 98, "us"); /* TODO Put country code */ … … 3823 3807 3824 3808 /* We don't need this anymore */ 3825 free(yd->login_cookie); 3826 yd->login_cookie = NULL; 3809 free(yid->yd->login_cookie); 3810 yid->yd->login_cookie = NULL; 3811 3812 return; 3813 3814 FAIL: 3815 YAHOO_CALLBACK(ext_yahoo_login_response)(yid->yd->client_id, error_code, NULL); 3827 3816 } 3828 3817
Note: See TracChangeset
for help on using the changeset viewer.