request.c (imapfilter-2.7.5) | : | request.c (imapfilter-2.7.6) | ||
---|---|---|---|---|
skipping to change at line 54 | skipping to change at line 54 | |||
} \ | } \ | |||
return -1; \ | return -1; \ | |||
case STATUS_BYE: \ | case STATUS_BYE: \ | |||
error("unexpected IMAP BYE for %s@%s\n", \ | error("unexpected IMAP BYE for %s@%s\n", \ | |||
ssn->username, ssn->server); \ | ssn->username, ssn->server); \ | |||
close_connection(ssn); \ | close_connection(ssn); \ | |||
if (!strcasecmp(get_option_string("recover"), "all")) { \ | if (!strcasecmp(get_option_string("recover"), "all")) { \ | |||
if (request_login(&ssn, NULL, NULL, NULL, NULL, \ | if (request_login(&ssn, NULL, NULL, NULL, NULL, \ | |||
NULL, NULL) != -1) \ | NULL, NULL) != -1) \ | |||
return STATUS_NONE; \ | return STATUS_NONE; \ | |||
} else \ | } else { \ | |||
session_destroy(ssn); \ | session_destroy(ssn); \ | |||
ssn = NULL; \ | ssn = NULL; \ | |||
} \ | ||||
return -1; \ | return -1; \ | |||
} | } | |||
/* | /* | |||
* Sends to server data; a command. | * Sends to server data; a command. | |||
*/ | */ | |||
int | int | |||
send_request(session *ssn, const char *fmt,...) | send_request(session *ssn, const char *fmt,...) | |||
{ | { | |||
int n; | int n; | |||
skipping to change at line 235 | skipping to change at line 236 | |||
CHECK(rl = response_generic(ssn, t)); | CHECK(rl = response_generic(ssn, t)); | |||
} | } | |||
if (rl == STATUS_NO) { | if (rl == STATUS_NO) { | |||
error("oauth2 string rejected at %s@%s\n", | error("oauth2 string rejected at %s@%s\n", | |||
ssn->username, ssn->server); | ssn->username, ssn->server); | |||
close_connection(ssn); | close_connection(ssn); | |||
session_destroy(ssn); | session_destroy(ssn); | |||
ssn = NULL; | ssn = NULL; | |||
return STATUS_NO; | return STATUS_NO; | |||
} | } | |||
if (rl != STATUS_OK && ssn->password && | ||||
ssn->capabilities & CAPABILITY_CRAMMD5 && | ||||
get_option_boolean("crammd5")) { | ||||
unsigned char *in, *out; | ||||
CHECK(t = send_request(ssn, "AUTHENTICATE CRAM-MD5")); | ||||
CHECK(r = response_authenticate(ssn, t, &in)); | ||||
if (r == STATUS_CONTINUE) { | ||||
if ((out = auth_cram_md5(ssn->username, | ||||
ssn->password, in)) == NULL) | ||||
goto abort; | ||||
CHECK(send_continuation(ssn, (char *)(out), | ||||
strlen((char *)(out)))); | ||||
xfree(out); | ||||
CHECK(rl = response_generic(ssn, t)); | ||||
} else | ||||
goto abort; | ||||
} | ||||
if (rl != STATUS_OK && ssn->password) { | if (rl != STATUS_OK && ssn->password) { | |||
CHECK(t = send_request(ssn, "LOGIN \"%s\" \"%s\"", | CHECK(t = send_request(ssn, "LOGIN \"%s\" \"%s\"", | |||
ssn->username, ssn->password)); | ssn->username, ssn->password)); | |||
CHECK(rl = response_generic(ssn, t)); | CHECK(rl = response_generic(ssn, t)); | |||
} | } | |||
if (rl == STATUS_NO) { | if (rl == STATUS_NO) { | |||
error("username %s or password rejected at %s\n", | error("username %s or password rejected at %s\n", | |||
ssn->username, ssn->server); | ssn->username, ssn->server); | |||
close_connection(ssn); | close_connection(ssn); | |||
session_destroy(ssn); | session_destroy(ssn); | |||
skipping to change at line 289 | skipping to change at line 273 | |||
CHECK(t = send_request(ssn, "SELECT \"%s\"", | CHECK(t = send_request(ssn, "SELECT \"%s\"", | |||
apply_namespace(ssn->selected, ssn->ns.prefix, | apply_namespace(ssn->selected, ssn->ns.prefix, | |||
ssn->ns.delim))); | ssn->ns.delim))); | |||
CHECK(response_select(ssn, t)); | CHECK(response_select(ssn, t)); | |||
} | } | |||
return rl; | return rl; | |||
abort: | abort: | |||
close_connection(ssn); | close_connection(ssn); | |||
fail: | fail: | |||
session_destroy(ssn); | if (!*ssnptr) { | |||
ssn = NULL; | session_destroy(ssn); | |||
ssn = NULL; | ||||
} | ||||
return -1; | return -1; | |||
} | } | |||
/* | /* | |||
* Logout from the IMAP server and disconnect from the server. | * Logout from the IMAP server and disconnect from the server. | |||
*/ | */ | |||
int | int | |||
request_logout(session *ssn) | request_logout(session *ssn) | |||
{ | { | |||
End of changes. 4 change blocks. | ||||
20 lines changed or deleted | 6 lines changed or added |