]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
pop3: Use RFC 3206 [SYS/*] and [AUTH] response codes.
authorTimo Sirainen <tss@iki.fi>
Sat, 16 Feb 2013 15:54:57 +0000 (17:54 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 16 Feb 2013 15:54:57 +0000 (17:54 +0200)
README
src/pop3-login/client-authenticate.c
src/pop3-login/client.c
src/pop3-login/client.h
src/pop3/main.c
src/pop3/pop3-capability.h
src/pop3/pop3-client.c

diff --git a/README b/README
index 72d8709b9986ba20cc304529e383234ee5909475..109ba8f7533f14db7dde7e3e047c0e821ad2fb06 100644 (file)
--- 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
index e0df32b68c3af36fd25625e36b08415a27126a1d..31a7e274dab431895f88fb68e3469eded128745d 100644 (file)
@@ -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;
index 38134a6c4134f87ba6fceaa45bfffe9a5524596a..3138b6f138f9483ef8cbf9dce2e73b2b100ae24a 100644 (file)
@@ -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;
index 34abacce70252ffe7b9fb143ec4d32344c025ea5..37653750af64e94aeadc59aaa6e64c3486867b4a 100644 (file)
@@ -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
 };
 
index 046ccf5e9ad4d5dd676d0fd6ede3d890cc65fec4..0d763e657807754a04189c7cae76f973f1a76b90 100644 (file)
@@ -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;
        }
index ce765bb577cf1c84e4a5644295645a0eb6dd09e8..3cd48cebe7f1b4797f9d8128a1cde0f4c06e47ba 100644 (file)
@@ -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 */
 
index 69dd4d0a542215c6145700a59616ee3b463e3ac2..75b830204379c4c4cb4fe76d3cd5653e1f13ee17 100644 (file)
@@ -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.");
        }