Especially "doveadm backup" should be able to delete the INBOX if needed.
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 */
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)
{
"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) {
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. */