dovecot-2.2: pop3: Use RFC 3206 [SYS/*] and [AUTH] response codes.
dovecot at dovecot.org
dovecot at dovecot.org
Sat Feb 16 17:55:32 EET 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/7e292b8352d9
changeset: 15785:7e292b8352d9
user: Timo Sirainen <tss at iki.fi>
date: Sat Feb 16 17:54:57 2013 +0200
description:
pop3: Use RFC 3206 [SYS/*] and [AUTH] response codes.
diffstat:
README | 23 +++++++++++++++--------
src/pop3-login/client-authenticate.c | 6 ++++++
src/pop3-login/client.c | 5 ++++-
src/pop3-login/client.h | 1 +
src/pop3/main.c | 6 +++---
src/pop3/pop3-capability.h | 3 ++-
src/pop3/pop3-client.c | 31 ++++++++++++++++++++-----------
7 files changed, 51 insertions(+), 24 deletions(-)
diffs (201 lines):
diff -r 928deb8a0b8c -r 7e292b8352d9 README
--- a/README Sat Feb 16 17:33:27 2013 +0200
+++ b/README Sat Feb 16 17:54:57 2013 +0200
@@ -13,22 +13,29 @@
RFCs conformed
--------------
+email:
822 - Standard for ARPA Internet Text Messages
2822 - Internet Message Format (updated rfc822)
2045..2049 - Multipurpose Internet Mail Extensions (MIME)
+auth:
+ 2245 - Anonymous SASL Mechanism.
+ 2595 - Using TLS with IMAP, POP3 and ACAP
+ 2831 - Using Digest Authentication as a SASL Mechanism (DIGEST-MD5)
+ 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
- 1939 - Post Office Protocol - Version 3
- 2449 - POP3 Extension 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
-
+IMAP extensions:
2087 - IMAP4 QUOTA extension
2088 - IMAP4 non-synchronizing literals (LITERAL+)
2177 - IMAP4 IDLE command
diff -r 928deb8a0b8c -r 7e292b8352d9 src/pop3-login/client-authenticate.c
--- a/src/pop3-login/client-authenticate.c Sat Feb 16 17:33:27 2013 +0200
+++ b/src/pop3-login/client-authenticate.c Sat Feb 16 17:54:57 2013 +0200
@@ -61,6 +61,12 @@
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 -r 928deb8a0b8c -r 7e292b8352d9 src/pop3-login/client.c
--- a/src/pop3-login/client.c Sat Feb 16 17:33:27 2013 +0200
+++ b/src/pop3-login/client.c Sat Feb 16 17:54:57 2013 +0200
@@ -232,7 +232,10 @@
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 -r 928deb8a0b8c -r 7e292b8352d9 src/pop3-login/client.h
--- a/src/pop3-login/client.h Sat Feb 16 17:33:27 2013 +0200
+++ b/src/pop3-login/client.h Sat Feb 16 17:54:57 2013 +0200
@@ -25,6 +25,7 @@
enum pop3_cmd_reply {
POP3_CMD_REPLY_OK,
POP3_CMD_REPLY_ERROR,
+ POP3_CMD_REPLY_AUTH_ERROR,
POP3_CMD_REPLY_TEMPFAIL
};
diff -r 928deb8a0b8c -r 7e292b8352d9 src/pop3/main.c
--- a/src/pop3/main.c Sat Feb 16 17:33:27 2013 +0200
+++ b/src/pop3/main.c Sat Feb 16 17:54:57 2013 +0200
@@ -99,7 +99,7 @@
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 @@
{
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 @@
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 -r 928deb8a0b8c -r 7e292b8352d9 src/pop3/pop3-capability.h
--- a/src/pop3/pop3-capability.h Sat Feb 16 17:33:27 2013 +0200
+++ b/src/pop3/pop3-capability.h Sat Feb 16 17:54:57 2013 +0200
@@ -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 -r 928deb8a0b8c -r 7e292b8352d9 src/pop3/pop3-client.c
--- a/src/pop3/pop3-client.c Sat Feb 16 17:33:27 2013 +0200
+++ b/src/pop3/pop3-client.c Sat Feb 16 17:54:57 2013 +0200
@@ -240,7 +240,7 @@
*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;
enum mailbox_flags flags;
const char *errmsg;
- enum mail_error error;
pool_t pool;
/* always use nonblocking I/O */
@@ -330,11 +329,9 @@
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_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 @@
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.");
}
More information about the dovecot-cvs
mailing list