changeset 8212:909ed7cd98a5 HEAD

ACL: Handle shared namespaces.
author Timo Sirainen <tss@iki.fi>
date Mon, 22 Sep 2008 22:31:33 +0300
parents fd4091d53627
children ffefb9074966
files src/plugins/acl/acl-backend-vfile-acllist.c src/plugins/acl/acl-backend-vfile.c
diffstat 2 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/acl/acl-backend-vfile-acllist.c	Mon Sep 22 22:31:13 2008 +0300
+++ b/src/plugins/acl/acl-backend-vfile-acllist.c	Mon Sep 22 22:31:33 2008 +0300
@@ -51,6 +51,11 @@
 
 	rootdir = mailbox_list_get_path(backend->backend.list, NULL,
 					MAILBOX_LIST_PATH_TYPE_DIR);
+	if (rootdir == NULL) {
+		/* we're never going to build acllist for this namespace. */
+		i_array_init(&backend->acllist, 1);
+		return 0;
+	}
 	path = t_strdup_printf("%s/"ACLLIST_FILENAME, rootdir);
 
 	if (backend->acllist_mtime != 0) {
@@ -191,16 +196,18 @@
 	gid_t gid;
 	int fd, ret;
 
-	mailbox_list_get_permissions(list, &mode, &gid);
+	rootdir = mailbox_list_get_path(list, NULL,
+					MAILBOX_LIST_PATH_TYPE_DIR);
+	if (rootdir == NULL)
+		return 0;
 
 	path = t_str_new(256);
-	rootdir = mailbox_list_get_path(list, NULL,
-					MAILBOX_LIST_PATH_TYPE_DIR);
 	str_printfa(path, "%s/%s", rootdir, mailbox_list_get_temp_prefix(list));
 
 	/* Build it into a temporary file and rename() over. There's no need
 	   to use locking, because even if multiple processes are rebuilding
 	   the file at the same time the result should be the same. */
+	mailbox_list_get_permissions(list, &mode, &gid);
 	fd = safe_mkstemp(path, mode, (uid_t)-1, gid);
 	if (fd == -1) {
 		if (errno == EACCES) {
--- a/src/plugins/acl/acl-backend-vfile.c	Mon Sep 22 22:31:13 2008 +0300
+++ b/src/plugins/acl/acl-backend-vfile.c	Mon Sep 22 22:31:33 2008 +0300
@@ -143,7 +143,8 @@
 	} else {
 		dir = acl_backend_vfile_get_local_dir(storage, name);
 	}
-	aclobj->local_path = i_strconcat(dir, "/"ACL_FILENAME, NULL);
+	aclobj->local_path = dir == NULL ? NULL :
+		i_strconcat(dir, "/"ACL_FILENAME, NULL);
 	return &aclobj->aclobj;
 }
 
@@ -208,8 +209,9 @@
 	   mailbox has no ACL it's equivalent to default ACLs. */
 	path = mailbox_list_get_path(storage->list, name,
 				     MAILBOX_LIST_PATH_TYPE_MAILBOX);
-	ret = acl_backend_vfile_exists(backend, path,
-				       &new_validity.mailbox_validity);
+	ret = path == NULL ? 0 :
+		acl_backend_vfile_exists(backend, path,
+					 &new_validity.mailbox_validity);
 	if (ret == 0) {
 		dir = acl_backend_vfile_get_local_dir(storage, name);
 		local_path = t_strconcat(dir, "/", name, NULL);