dovecot-2.0: lib-storage: Fixed setting usable/unusable flags fo...

dovecot at dovecot.org dovecot at dovecot.org
Wed Apr 4 04:34:13 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.0/rev/b15889b82258
changeset: 13081:b15889b82258
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Apr 04 04:34:08 2012 +0300
description:
lib-storage: Fixed setting usable/unusable flags for shared namespaces.
If a namespace doesn't have a root that exists, mark it as unusable.
This avoids ACL plugin from autocreating that directory.

diffstat:

 src/lib-storage/index/shared/shared-storage.c |  20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diffs (37 lines):

diff -r a45cfc1971e8 -r b15889b82258 src/lib-storage/index/shared/shared-storage.c
--- a/src/lib-storage/index/shared/shared-storage.c	Wed Apr 04 03:44:04 2012 +0300
+++ b/src/lib-storage/index/shared/shared-storage.c	Wed Apr 04 04:34:08 2012 +0300
@@ -119,6 +119,19 @@
 	str_append(location, username);
 }
 
+static bool shared_namespace_exists(struct mail_namespace *ns)
+{
+	const char *path;
+	struct stat st;
+
+	path = mailbox_list_get_path(ns->list, NULL, MAILBOX_LIST_PATH_TYPE_DIR);
+	if (path == NULL) {
+		/* we can't know if this exists */
+		return TRUE;
+	}
+	return stat(path, &st) == 0;
+}
+
 int shared_storage_get_namespace(struct mail_namespace **_ns,
 				 const char **_name)
 {
@@ -307,6 +320,13 @@
 		mail_namespace_destroy(new_ns);
 		return -1;
 	}
+	if ((new_ns->flags & NAMESPACE_FLAG_UNUSABLE) == 0 &&
+	    !shared_namespace_exists(new_ns)) {
+		/* this user doesn't have a usable storage */
+		new_ns->flags |= NAMESPACE_FLAG_UNUSABLE;
+	}
+	/* mark the shared namespace root as usable, since it now has
+	   child namespaces */
 	ns->flags |= NAMESPACE_FLAG_USABLE;
 	*_name = mail_namespace_fix_sep(new_ns, name);
 	*_ns = new_ns;


More information about the dovecot-cvs mailing list