dovecot-2.2: Moved "INBOX can't be deleted" check from lib-stora...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Jun 12 21:41:36 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/db5d4c5164b3
changeset: 16498:db5d4c5164b3
user: Timo Sirainen <tss at iki.fi>
date: Wed Jun 12 21:41:09 2013 +0300
description:
Moved "INBOX can't be deleted" check from lib-storage to IMAP-specific code.
Especially "doveadm backup" should be able to delete the INBOX if needed.
diffstat:
src/imap/cmd-delete.c | 13 +++++++------
src/lib-storage/mail-storage.c | 10 +++++-----
src/lib-storage/mail-storage.h | 2 ++
3 files changed, 14 insertions(+), 11 deletions(-)
diffs (67 lines):
diff -r 4b9a43201a71 -r db5d4c5164b3 src/imap/cmd-delete.c
--- a/src/imap/cmd-delete.c Wed Jun 12 21:25:09 2013 +0300
+++ b/src/imap/cmd-delete.c Wed Jun 12 21:41:09 2013 +0300
@@ -16,17 +16,18 @@
if (!client_read_string_args(cmd, 1, &name))
return FALSE;
- if (strcasecmp(name, "INBOX") == 0) {
- /* INBOX can't be deleted */
- client_send_tagline(cmd, "NO INBOX can't be deleted.");
- return TRUE;
- }
-
ns = client_find_namespace(cmd, &name);
if (ns == NULL)
return TRUE;
box = mailbox_alloc(ns->list, name, 0);
+ if (mailbox_is_any_inbox(box)) {
+ /* IMAP protocol allows this, but I think it's safer to
+ not allow it. */
+ mailbox_free(&box);
+ client_send_tagline(cmd, "NO INBOX can't be deleted.");
+ return TRUE;
+ }
if (client->mailbox != NULL &&
mailbox_backends_equal(box, client->mailbox)) {
/* deleting selected mailbox. close it first */
diff -r 4b9a43201a71 -r db5d4c5164b3 src/lib-storage/mail-storage.c
--- a/src/lib-storage/mail-storage.c Wed Jun 12 21:25:09 2013 +0300
+++ b/src/lib-storage/mail-storage.c Wed Jun 12 21:41:09 2013 +0300
@@ -1213,6 +1213,11 @@
strcasecmp(vname2, "INBOX") == 0;
}
+bool mailbox_is_any_inbox(struct mailbox *box)
+{
+ return box->inbox_any;
+}
+
int mailbox_create(struct mailbox *box, const struct mailbox_update *update,
bool directory)
{
@@ -1288,11 +1293,6 @@
"Storage root can't be deleted");
return -1;
}
- if (box->inbox_any) {
- mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
- "INBOX can't be deleted.");
- return -1;
- }
box->deleting = TRUE;
if (mailbox_open(box) < 0) {
diff -r 4b9a43201a71 -r db5d4c5164b3 src/lib-storage/mail-storage.h
--- a/src/lib-storage/mail-storage.h Wed Jun 12 21:25:09 2013 +0300
+++ b/src/lib-storage/mail-storage.h Wed Jun 12 21:41:09 2013 +0300
@@ -481,6 +481,8 @@
bool mailbox_equals(const struct mailbox *box1,
const struct mail_namespace *ns2,
const char *vname2) ATTR_PURE;
+/* Returns TRUE if the mailbox is user's INBOX or another user's shared INBOX */
+bool mailbox_is_any_inbox(struct mailbox *box);
/* Returns -1 if mailbox_create() is guaranteed to fail because the mailbox
name is invalid, 0 not. The error message contains a reason. */
More information about the dovecot-cvs
mailing list