dovecot-2.2: lib-storage: Added mail_namespace_is_shared_user_ro...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jul 3 16:13:39 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/7a60541913e9
changeset: 17584:7a60541913e9
user: Timo Sirainen <tss at iki.fi>
date: Thu Jul 03 19:12:02 2014 +0300
description:
lib-storage: Added mail_namespace_is_shared_user_root() and used it where useful.
Most importantly this should fix a crash in ACL plugin where type=shared
namespace was used without any kind of per-user prefix/location (i.e. it
probably should have been a type=public namespace instead).
diffstat:
src/lib-storage/list/mailbox-list-subscriptions.c | 3 +--
src/lib-storage/mail-namespace.c | 21 +++++++++++++++++++--
src/lib-storage/mail-namespace.h | 5 +++++
src/plugins/acl/acl-mailbox.c | 3 +--
4 files changed, 26 insertions(+), 6 deletions(-)
diffs (74 lines):
diff -r ec22ade1f101 -r 7a60541913e9 src/lib-storage/list/mailbox-list-subscriptions.c
--- a/src/lib-storage/list/mailbox-list-subscriptions.c Thu Jul 03 19:10:33 2014 +0300
+++ b/src/lib-storage/list/mailbox-list-subscriptions.c Thu Jul 03 19:12:02 2014 +0300
@@ -61,8 +61,7 @@
/* When listing shared namespace's subscriptions, we need to
autocreate all the visible child namespaces. their subscriptions
are listed later. */
- if (ns != NULL && ns->type == MAIL_NAMESPACE_TYPE_SHARED &&
- (ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) {
+ if (ns != NULL && mail_namespace_is_shared_user_root(ns)) {
/* we'll need to get the namespace autocreated.
one easy way is to just ask to join a reference and
pattern */
diff -r ec22ade1f101 -r 7a60541913e9 src/lib-storage/mail-namespace.c
--- a/src/lib-storage/mail-namespace.c Thu Jul 03 19:10:33 2014 +0300
+++ b/src/lib-storage/mail-namespace.c Thu Jul 03 19:12:02 2014 +0300
@@ -662,8 +662,7 @@
ns = mail_namespace_find_mask(namespaces, mailbox, 0, 0);
i_assert(ns != NULL);
- if (ns->type == MAIL_NAMESPACE_TYPE_SHARED &&
- (ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) {
+ if (mail_namespace_is_shared_user_root(ns)) {
/* see if we need to autocreate a namespace for shared user */
if (strchr(mailbox, mail_namespace_get_sep(ns)) != NULL)
return mail_namespace_find_shared(ns, mailbox);
@@ -751,3 +750,21 @@
}
return NULL;
}
+
+bool mail_namespace_is_shared_user_root(struct mail_namespace *ns)
+{
+ struct mail_storage *const *storagep;
+
+ if (ns->type != MAIL_NAMESPACE_TYPE_SHARED)
+ return FALSE;
+ if ((ns->flags & NAMESPACE_FLAG_AUTOCREATED) != 0) {
+ /* child of the shared root */
+ return FALSE;
+ }
+ /* if we have driver=shared storage, we're a real shared root */
+ array_foreach(&ns->all_storages, storagep) {
+ if (strcmp((*storagep)->name, MAIL_SHARED_STORAGE_NAME) == 0)
+ return TRUE;
+ }
+ return FALSE;
+}
diff -r ec22ade1f101 -r 7a60541913e9 src/lib-storage/mail-namespace.h
--- a/src/lib-storage/mail-namespace.h Thu Jul 03 19:10:33 2014 +0300
+++ b/src/lib-storage/mail-namespace.h Thu Jul 03 19:12:02 2014 +0300
@@ -150,4 +150,9 @@
void mail_namespace_finish_list_init(struct mail_namespace *ns,
struct mailbox_list *list);
+/* Returns TRUE if this is the root of a type=shared namespace that is actually
+ used for accessing shared users' mailboxes (as opposed to marking a
+ type=public namespace "wrong"). */
+bool mail_namespace_is_shared_user_root(struct mail_namespace *ns);
+
#endif
diff -r ec22ade1f101 -r 7a60541913e9 src/plugins/acl/acl-mailbox.c
--- a/src/plugins/acl/acl-mailbox.c Thu Jul 03 19:10:33 2014 +0300
+++ b/src/plugins/acl/acl-mailbox.c Thu Jul 03 19:12:02 2014 +0300
@@ -567,8 +567,7 @@
return;
}
- if (box->list->ns->type == MAIL_NAMESPACE_TYPE_SHARED &&
- (box->list->ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) {
+ if (mail_namespace_is_shared_user_root(box->list->ns)) {
/* this is the root shared namespace, which itself doesn't
have any existing mailboxes. */
return;
More information about the dovecot-cvs
mailing list