From: Timo Sirainen Date: Sat, 16 Feb 2013 15:54:57 +0000 (+0200) Subject: pop3: Use RFC 3206 [SYS/*] and [AUTH] response codes. X-Git-Tag: 2.2.beta2~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=348d897426ff46ae23aaa432aff0087ce4d034d5;p=thirdparty%2Fdovecot%2Fcore.git pop3: Use RFC 3206 [SYS/*] and [AUTH] response codes. --- diff --git a/README b/README index 72d8709b99..109ba8f753 100644 --- a/README +++ b/README @@ -13,22 +13,29 @@ See doc/documentation.txt or http://wiki2.dovecot.org/ RFCs conformed -------------- +email: 822 - Standard for ARPA Internet Text Messages 2822 - Internet Message Format (updated rfc822) 2045..2049 - Multipurpose Internet Mail Extensions (MIME) - 3501 - IMAP4rev1 - 2180 - IMAP4 Multi-Accessed Mailbox Practice - 2683 - IMAP4 Implementation Recommendations - 1939 - Post Office Protocol - Version 3 - 2449 - POP3 Extension Mechanism - +auth: + 2245 - Anonymous SASL Mechanism. 2595 - Using TLS with IMAP, POP3 and ACAP 2831 - Using Digest Authentication as a SASL Mechanism (DIGEST-MD5) - 2245 - Anonymous SASL Mechanism. 5802 - Salted Challenge Response Authentication Mechanism (SCRAM) SASL and GSS-API Mechanisms +POP3: + 1939 - Post Office Protocol - Version 3 + 2449 - POP3 Extension Mechanism + 3206 - The SYS and AUTH POP Response Codes + +IMAP base: + 3501 - IMAP4rev1 + 2180 - IMAP4 Multi-Accessed Mailbox Practice + 2683 - IMAP4 Implementation Recommendations + +IMAP extensions: 2087 - IMAP4 QUOTA extension 2088 - IMAP4 non-synchronizing literals (LITERAL+) 2177 - IMAP4 IDLE command diff --git a/src/pop3-login/client-authenticate.c b/src/pop3-login/client-authenticate.c index e0df32b68c..31a7e274da 100644 --- a/src/pop3-login/client-authenticate.c +++ b/src/pop3-login/client-authenticate.c @@ -61,6 +61,12 @@ void pop3_client_auth_result(struct client *client, case CLIENT_AUTH_RESULT_TEMPFAIL: client_send_reply(client, POP3_CMD_REPLY_TEMPFAIL, text); break; + case CLIENT_AUTH_RESULT_AUTHFAILED: + case CLIENT_AUTH_RESULT_AUTHFAILED_REASON: + case CLIENT_AUTH_RESULT_AUTHZFAILED: + case CLIENT_AUTH_RESULT_SSL_REQUIRED: + client_send_reply(client, POP3_CMD_REPLY_AUTH_ERROR, text); + break; default: client_send_reply(client, POP3_CMD_REPLY_ERROR, text); break; diff --git a/src/pop3-login/client.c b/src/pop3-login/client.c index 38134a6c41..3138b6f138 100644 --- a/src/pop3-login/client.c +++ b/src/pop3-login/client.c @@ -232,7 +232,10 @@ void client_send_reply(struct client *client, enum pop3_cmd_reply reply, prefix = "+OK"; break; case POP3_CMD_REPLY_TEMPFAIL: - prefix = "-ERR [IN-USE]"; + prefix = "-ERR [SYS/TEMP]"; + break; + case POP3_CMD_REPLY_AUTH_ERROR: + prefix = "-ERR [AUTH]"; break; case POP3_CMD_REPLY_ERROR: break; diff --git a/src/pop3-login/client.h b/src/pop3-login/client.h index 34abacce70..37653750af 100644 --- a/src/pop3-login/client.h +++ b/src/pop3-login/client.h @@ -25,6 +25,7 @@ struct pop3_client { enum pop3_cmd_reply { POP3_CMD_REPLY_OK, POP3_CMD_REPLY_ERROR, + POP3_CMD_REPLY_AUTH_ERROR, POP3_CMD_REPLY_TEMPFAIL }; diff --git a/src/pop3/main.c b/src/pop3/main.c index 046ccf5e9a..0d763e6578 100644 --- a/src/pop3/main.c +++ b/src/pop3/main.c @@ -99,7 +99,7 @@ client_create_from_input(const struct mail_storage_service_input *input, const char **error_r) { const char *lookup_error_str = - "-ERR [IN-USE] "MAIL_ERRSTR_CRITICAL_MSG"\r\n"; + "-ERR [SYS/TEMP] "MAIL_ERRSTR_CRITICAL_MSG"\r\n"; struct mail_storage_service_user *user; struct mail_user *mail_user; struct client *client; @@ -184,7 +184,7 @@ static void login_client_failed(const struct master_login_client *client, { const char *msg; - msg = t_strdup_printf("-ERR [IN-USE] %s\r\n", errormsg); + msg = t_strdup_printf("-ERR [SYS/TEMP] %s\r\n", errormsg); if (write(client->fd, msg, strlen(msg)) < 0) { /* ignored */ } @@ -216,7 +216,7 @@ int main(int argc, char *argv[]) if (IS_STANDALONE() && getuid() == 0 && net_getpeername(1, NULL, NULL) == 0) { - printf("-ERR pop3 binary must not be started from " + printf("-ERR [SYS/PERM] pop3 binary must not be started from " "inetd, use pop3-login instead.\n"); return 1; } diff --git a/src/pop3/pop3-capability.h b/src/pop3/pop3-capability.h index ce765bb577..3cd48cebe7 100644 --- a/src/pop3/pop3-capability.h +++ b/src/pop3/pop3-capability.h @@ -6,7 +6,8 @@ "TOP\r\n" \ "UIDL\r\n" \ "RESP-CODES\r\n" \ - "PIPELINING\r\n" + "PIPELINING\r\n" \ + "AUTH-RESP-CODE\r\n" /* + SASL */ diff --git a/src/pop3/pop3-client.c b/src/pop3/pop3-client.c index 69dd4d0a54..75b8302043 100644 --- a/src/pop3/pop3-client.c +++ b/src/pop3/pop3-client.c @@ -240,7 +240,7 @@ static int init_mailbox(struct client *client, const char **error_r) *error_r = "Can't sync mailbox: " "Messages keep getting expunged"; } - client_send_line(client, "-ERR [IN-USE] Couldn't sync mailbox."); + client_send_line(client, "-ERR [SYS/TEMP] Couldn't sync mailbox."); } return -1; } @@ -283,7 +283,6 @@ struct client *client_create(int fd_in, int fd_out, const char *session_id, struct client *client; enum mailbox_flags flags; const char *errmsg; - enum mail_error error; pool_t pool; /* always use nonblocking I/O */ @@ -330,11 +329,9 @@ struct client *client_create(int fd_in, int fd_out, const char *session_id, client->mailbox = mailbox_alloc(client->inbox_ns->list, "INBOX", flags); storage = mailbox_get_storage(client->mailbox); if (mailbox_open(client->mailbox) < 0) { - errmsg = t_strdup_printf("Couldn't open INBOX: %s", - mailbox_get_last_error(client->mailbox, - &error)); - i_error("%s", errmsg); - client_send_line(client, "-ERR [IN-USE] %s", errmsg); + i_error("Couldn't open INBOX: %s", + mailbox_get_last_error(client->mailbox, NULL)); + client_send_storage_error(client); client_destroy(client, "Couldn't open INBOX"); return NULL; } @@ -603,15 +600,27 @@ void client_send_line(struct client *client, const char *fmt, ...) void client_send_storage_error(struct client *client) { + const char *errstr; + enum mail_error error; + if (mailbox_is_inconsistent(client->mailbox)) { - client_send_line(client, "-ERR Mailbox is in inconsistent " + client_send_line(client, "-ERR [SYS/TEMP] Mailbox is in inconsistent " "state, please relogin."); client_disconnect(client, "Mailbox is in inconsistent state."); return; } - client_send_line(client, "-ERR %s", - mailbox_get_last_error(client->mailbox, NULL)); + errstr = mailbox_get_last_error(client->mailbox, &error); + switch (error) { + case MAIL_ERROR_TEMP: + case MAIL_ERROR_NOSPACE: + case MAIL_ERROR_INUSE: + client_send_line(client, "-ERR [SYS/TEMP] %s", errstr); + break; + default: + client_send_line(client, "-ERR [SYS/PERM] %s", errstr); + break; + } } bool client_handle_input(struct client *client) @@ -731,7 +740,7 @@ void clients_destroy_all(void) while (pop3_clients != NULL) { if (pop3_clients->cmd == NULL) { client_send_line(pop3_clients, - "-ERR Server shutting down."); + "-ERR [SYS/TEMP] Server shutting down."); } client_destroy(pop3_clients, "Server shutting down."); }