Changes in protocols/jabber/sasl.c [40cfbc5:5ebff60]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/sasl.c
r40cfbc5 r5ebff60 42 42 "https://www.facebook.com/dialog/oauth", 43 43 "https://graph.facebook.com/oauth/access_token", 44 "http s://www.bitlbee.org/main.php/Facebook/oauth2.html",44 "http://www.bitlbee.org/main.php/Facebook/oauth2.html", 45 45 "offline_access,xmpp_login", 46 46 "126828914005625", … … 55 55 char *s; 56 56 int sup_plain = 0, sup_digest = 0, sup_gtalk = 0, sup_fb = 0; 57 int want_oauth = FALSE , want_hipchat = FALSE;57 int want_oauth = FALSE; 58 58 GString *mechs; 59 59 … … 75 75 76 76 want_oauth = set_getbool(&ic->acc->set, "oauth"); 77 want_hipchat = (jd->flags & JFLAG_HIPCHAT);78 77 79 78 mechs = g_string_new(""); … … 112 111 113 112 reply = xt_new_node("auth", NULL, NULL); 114 if (!want_hipchat) { 115 xt_add_attr(reply, "xmlns", XMLNS_SASL); 116 } else { 117 xt_add_attr(reply, "xmlns", XMLNS_HIPCHAT); 118 } 113 xt_add_attr(reply, "xmlns", XMLNS_SASL); 119 114 120 115 if (sup_gtalk && want_oauth) { … … 148 143 } else if (sup_plain) { 149 144 int len; 150 GString *gs; 151 char *username; 152 153 if (!want_hipchat) { 154 xt_add_attr(reply, "mechanism", "PLAIN"); 155 username = jd->username; 156 } else { 157 username = jd->me; 158 } 159 160 /* set an arbitrary initial size to avoid reallocations */ 161 gs = g_string_sized_new(128); 145 146 xt_add_attr(reply, "mechanism", "PLAIN"); 162 147 163 148 /* With SASL PLAIN in XMPP, the text should be b64(\0user\0pass) */ 164 g_string_append_c(gs, '\0'); 165 g_string_append(gs, username); 166 g_string_append_c(gs, '\0'); 167 g_string_append(gs, ic->acc->pass); 168 if (want_hipchat) { 169 /* Hipchat's variation adds \0resource at the end */ 170 g_string_append_c(gs, '\0'); 171 g_string_append(gs, set_getstr(&ic->acc->set, "resource")); 172 } 173 174 len = gs->len; 175 s = g_string_free(gs, FALSE); 176 149 len = strlen(jd->username) + strlen(ic->acc->pass) + 2; 150 s = g_malloc(len + 1); 151 s[0] = 0; 152 strcpy(s + 1, jd->username); 153 strcpy(s + 2 + strlen(jd->username), ic->acc->pass); 177 154 reply->text = base64_encode((unsigned char *) s, len); 178 155 reply->text_len = strlen(reply->text); … … 420 397 imcb_log(ic, "Authentication finished"); 421 398 jd->flags |= JFLAG_AUTHENTICATED | JFLAG_STREAM_RESTART; 422 423 if (jd->flags & JFLAG_HIPCHAT) {424 return hipchat_handle_success(ic, node);425 }426 399 } else if (strcmp(node->name, "failure") == 0) { 427 400 imcb_error(ic, "Authentication failure");
Note: See TracChangeset
for help on using the changeset viewer.