diff -Naur cyrus-imapd-2.4.20.orig/imap/annotate.c cyrus-imapd-2.4.20/imap/annotate.c --- cyrus-imapd-2.4.20.orig/imap/annotate.c 2017-08-18 02:29:14.000000000 +0200 +++ cyrus-imapd-2.4.20/imap/annotate.c 2017-08-21 17:12:57.000000000 +0200 @@ -1834,6 +1834,9 @@ { "/vendor/cmu/cyrus-imapd/duplicatedeliver", ATTRIB_TYPE_BOOLEAN, BACKEND_ONLY, ATTRIB_VALUE_SHARED | ATTRIB_CONTENTTYPE_SHARED, ACL_ADMIN, annotation_set_mailboxopt, NULL }, + { "/vendor/qmul/cyrus-imapd/lmtptarget", ATTRIB_TYPE_BOOLEAN, BACKEND_ONLY, + ATTRIB_VALUE_SHARED | ATTRIB_CONTENTTYPE_SHARED, + ACL_ADMIN, annotation_set_todb, NULL }, { NULL, 0, ANNOTATION_PROXY_T_INVALID, 0, 0, NULL, NULL } }; diff -Naur cyrus-imapd-2.4.20.orig/imap/mboxlist.c cyrus-imapd-2.4.20/imap/mboxlist.c --- cyrus-imapd-2.4.20.orig/imap/mboxlist.c 2017-08-18 02:29:14.000000000 +0200 +++ cyrus-imapd-2.4.20/imap/mboxlist.c 2017-08-21 17:14:22.000000000 +0200 @@ -884,6 +884,7 @@ int isremote = 0; const char *p; mupdate_handle *mupdate_h = NULL; + struct annotation_data attrib; if (!isadmin && force) return IMAP_PERMISSION_DENIED; @@ -903,6 +904,14 @@ if (!isadmin) { r = IMAP_PERMISSION_DENIED; goto done; } } + /* Does mailbox have the lmtptarget annotation set? */ + if (annotatemore_lookup(name, "/vendor/qmul/cyrus-imapd/lmtptarget", "", &attrib) == 0 && + attrib.value && !strcasecmp(attrib.value, "true")) { + /* Even admins can't delete a mailbox with the lmtptarget annotation set. */ + r = IMAP_MAILBOX_NOTSUPPORTED; + goto done; + } + r = mboxlist_mylookup(name, &mbentry, NULL, 1); if (r) goto done; @@ -1003,6 +1012,7 @@ char *newpartition = NULL; char *mboxent = NULL; mupdate_handle *mupdate_h = NULL; + struct annotation_data attrib; /* 1. open mailbox */ r = mailbox_open_iwl(oldname, &oldmailbox); @@ -1096,6 +1106,14 @@ } } + /* Does mailbox have the lmtptarget annotation set? */ + if (annotatemore_lookup(oldname, "/vendor/qmul/cyrus-imapd/lmtptarget", "", &attrib) == 0 && + attrib.value && !strcasecmp(attrib.value, "true")) { + /* Even admins can't rename a mailbox with the lmtptarget annotation set. */ + r = IMAP_MAILBOX_NOTSUPPORTED; + goto done; + } + r = mboxlist_mycreatemailboxcheck(newname, 0, partition, isadmin, userid, auth_state, NULL, &newpartition, 1, 0, forceuser, NULL); diff -Naur cyrus-imapd-2.4.20.orig/perl/imap/IMAP/Admin.pm cyrus-imapd-2.4.20/perl/imap/IMAP/Admin.pm --- cyrus-imapd-2.4.20.orig/perl/imap/IMAP/Admin.pm 2017-08-18 02:29:14.000000000 +0200 +++ cyrus-imapd-2.4.20/perl/imap/IMAP/Admin.pm 2017-08-21 17:12:57.000000000 +0200 @@ -788,6 +788,7 @@ "expire" => "/vendor/cmu/cyrus-imapd/expire", "news2mail" => "/vendor/cmu/cyrus-imapd/news2mail", "sharedseen" => "/vendor/cmu/cyrus-imapd/sharedseen", + "lmtptarget" => "/vendor/qmul/cyrus-imapd/lmtptarget", "sieve" => "/vendor/cmu/cyrus-imapd/sieve", "squat" => "/vendor/cmu/cyrus-imapd/squat" );