Mercurial > dovecot > original-hg > dovecot-1.2
changeset 2785:fc4b1ec1b3ef HEAD
Use USER/PASS instad for AUTH PLAIN. Also don't require "+OK" to have
parameters.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 20 Oct 2004 16:49:04 +0300 |
parents | 12ac68531a3a |
children | 9aaa737f8215 |
files | src/pop3-login/pop3-proxy.c |
diffstat | 1 files changed, 32 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pop3-login/pop3-proxy.c Tue Oct 19 18:53:16 2004 +0300 +++ b/src/pop3-login/pop3-proxy.c Wed Oct 20 16:49:04 2004 +0300 @@ -14,7 +14,7 @@ void *context) { struct pop3_client *client = context; - string_t *auth, *str; + string_t *str; const char *line; if (input == NULL) { @@ -48,7 +48,7 @@ if (client->proxy_user != NULL) { /* this is a banner */ - if (strncmp(line, "+OK ", 4) != 0) { + if (strncmp(line, "+OK", 3) != 0) { i_error("pop3-proxy(%s): " "Remote returned invalid banner: %s", client->common.virtual_user, line); @@ -56,39 +56,44 @@ return; } - /* send AUTH command */ - auth = t_str_new(128); - str_append_c(auth, '\0'); - str_append(auth, client->proxy_user); - str_append_c(auth, '\0'); - str_append(auth, client->proxy_password); - + /* send USER command */ str = t_str_new(128); - str_append(str, "AUTH PLAIN "); - base64_encode(str_data(auth), str_len(auth), str); + str_append(str, "USER "); + str_append(str, client->proxy_user); str_append(str, "\r\n"); (void)o_stream_send(output, str_data(str), str_len(str)); - safe_memset(client->proxy_password, 0, - strlen(client->proxy_password)); i_free(client->proxy_user); - i_free(client->proxy_password); client->proxy_user = NULL; - client->proxy_password = NULL; - } else if (strncmp(line, "+OK ", 4) == 0) { - /* Login successful. Send this line to client. */ - (void)o_stream_send_str(client->output, line); - (void)o_stream_send(client->output, "\r\n", 2); + } else if (strncmp(line, "+OK", 3) == 0) { + if (client->proxy_password != NULL) { + /* USER successful, send PASS */ + str = t_str_new(128); + str_append(str, "PASS "); + str_append(str, client->proxy_password); + str_append(str, "\r\n"); + (void)o_stream_send(output, str_data(str), + str_len(str)); - login_proxy_detach(client->proxy, client->input, - client->output); + safe_memset(client->proxy_password, 0, + strlen(client->proxy_password)); + i_free(client->proxy_password); + client->proxy_password = NULL; + } else { + /* Login successful. Send this line to client. */ + (void)o_stream_send_str(client->output, line); + (void)o_stream_send(client->output, "\r\n", 2); - client->proxy = NULL; - client->input = NULL; - client->output = NULL; - client->common.fd = -1; - client_destroy(client, t_strconcat( - "Proxy: ", client->common.virtual_user, NULL)); + login_proxy_detach(client->proxy, client->input, + client->output); + + client->proxy = NULL; + client->input = NULL; + client->output = NULL; + client->common.fd = -1; + client_destroy(client, t_strconcat( + "Proxy: ", client->common.virtual_user, NULL)); + } } else { /* Login failed. Send our own failure reply so client can't figure out if user exists or not just by looking at the