Mercurial > dovecot > core-2.2
changeset 15180:d40f26407aad
imap: If CLOSE/EXPUNGE fails with "permission denied", return tagged OK anyway.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 03 Oct 2012 03:20:57 +0300 |
parents | 3f55c6ca06f8 |
children | 3e3ac2c16fa4 |
files | src/imap/cmd-close.c src/imap/cmd-expunge.c |
diffstat | 2 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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; }
--- 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;