dovecot-2.2: imap: If CLOSE/EXPUNGE fails with "permission denie...

dovecot at dovecot.org dovecot at dovecot.org
Wed Oct 3 03:21:08 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/d40f26407aad
changeset: 15180:d40f26407aad
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Oct 03 03:20:57 2012 +0300
description:
imap: If CLOSE/EXPUNGE fails with "permission denied", return tagged OK anyway.

diffstat:

 src/imap/cmd-close.c   |  15 ++++++++++++---
 src/imap/cmd-expunge.c |  15 ++++++++++++---
 2 files changed, 24 insertions(+), 6 deletions(-)

diffs (69 lines):

diff -r 3f55c6ca06f8 -r d40f26407aad src/imap/cmd-close.c
--- a/src/imap/cmd-close.c	Wed Oct 03 03:20:15 2012 +0300
+++ b/src/imap/cmd-close.c	Wed Oct 03 03:20:57 2012 +0300
@@ -9,6 +9,8 @@
 	struct client *client = cmd->client;
 	struct mailbox *mailbox = client->mailbox;
 	struct mail_storage *storage;
+	const char *errstr, *tagged_reply = "OK Close completed.";
+	enum mail_error error = MAIL_ERROR_NONE;
 
 	if (!client_verify_open_mailbox(cmd))
 		return TRUE;
@@ -17,14 +19,21 @@
 	client->mailbox = NULL;
 
 	storage = mailbox_get_storage(mailbox);
-	if (imap_expunge(mailbox, NULL) < 0)
-		client_send_untagged_storage_error(client, storage);
+	if (imap_expunge(mailbox, NULL) < 0) {
+		errstr = mailbox_get_last_error(mailbox, &error);
+		if (error != MAIL_ERROR_PERM)
+			client_send_untagged_storage_error(client, storage);
+		else {
+			tagged_reply = t_strdup_printf(
+				"OK Closed without expunging: %s", errstr);
+		}
+	}
 	if (mailbox_sync(mailbox, 0) < 0)
 		client_send_untagged_storage_error(client, storage);
 
 	mailbox_free(&mailbox);
 	client_update_mailbox_flags(client, NULL);
 
-	client_send_tagline(cmd, "OK Close completed.");
+	client_send_tagline(cmd, tagged_reply);
 	return TRUE;
 }
diff -r 3f55c6ca06f8 -r d40f26407aad src/imap/cmd-expunge.c
--- a/src/imap/cmd-expunge.c	Wed Oct 03 03:20:15 2012 +0300
+++ b/src/imap/cmd-expunge.c	Wed Oct 03 03:20:57 2012 +0300
@@ -24,6 +24,8 @@
 		   struct mail_search_args *search_args)
 {
 	struct client *client = cmd->client;
+	const char *errstr;
+	enum mail_error error = MAIL_ERROR_NONE;
 	int ret;
 
 	ret = imap_expunge(client->mailbox, search_args == NULL ? NULL :
@@ -31,9 +33,16 @@
 	if (search_args != NULL)
 		mail_search_args_unref(&search_args);
 	if (ret < 0) {
-		client_send_storage_error(cmd,
-					  mailbox_get_storage(client->mailbox));
-		return TRUE;
+		errstr = mailbox_get_last_error(client->mailbox, &error);
+		if (error != MAIL_ERROR_PERM) {
+			client_send_storage_error(cmd,
+				mailbox_get_storage(client->mailbox));
+			return TRUE;
+		} else {
+			return cmd_sync(cmd, 0, IMAP_SYNC_FLAG_SAFE,
+				t_strdup_printf("OK Expunge ignored: %s.",
+						errstr));
+		}
 	}
 
 	client->sync_seen_deletes = FALSE;


More information about the dovecot-cvs mailing list