[dovecot-cvs] dovecot/src/plugins/acl Makefile.am, 1.2, 1.3 acl-plugin.c, 1.1, 1.2 acl-plugin.h, 1.2, 1.3 acl-storage.c, 1.2, 1.3

tss at dovecot.org tss at dovecot.org
Thu Nov 16 00:17:17 UTC 2006


Update of /var/lib/cvs/dovecot/src/plugins/acl
In directory talvi:/tmp/cvs-serv25364/src/plugins/acl

Modified Files:
	Makefile.am acl-plugin.c acl-plugin.h acl-storage.c 
Log Message:
Initial code for separation of mailbox accessing and directory layout
handling. It's not yet possible to change the default layouts though.



Index: Makefile.am
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/acl/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile.am	17 Jun 2006 18:03:45 -0000	1.2
+++ Makefile.am	16 Nov 2006 00:17:14 -0000	1.3
@@ -14,6 +14,7 @@
 	acl-backend-vfile.c \
 	acl-cache.c \
 	acl-mailbox.c \
+	acl-mailbox-list.c \
 	acl-plugin.c \
 	acl-storage.c
 

Index: acl-plugin.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/acl/acl-plugin.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- acl-plugin.c	27 Feb 2006 16:30:39 -0000	1.1
+++ acl-plugin.c	16 Nov 2006 00:17:14 -0000	1.2
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "mail-storage.h"
+#include "mailbox-list-private.h"
 #include "acl-api.h"
 #include "acl-plugin.h"
 
@@ -11,6 +12,7 @@
 extern void (*hook_mail_storage_created)(struct mail_storage *storage);
 
 void (*acl_next_hook_mail_storage_created)(struct mail_storage *storage);
+void (*acl_next_hook_mailbox_list_created)(struct mailbox_list *list);
 
 void acl_plugin_init(void)
 {
@@ -18,6 +20,9 @@
 		acl_next_hook_mail_storage_created =
 			hook_mail_storage_created;
 		hook_mail_storage_created = acl_mail_storage_created;
+
+		acl_next_hook_mailbox_list_created = hook_mailbox_list_created;
+		hook_mailbox_list_created = acl_mailbox_list_created;
 	}
 }
 
@@ -26,5 +31,7 @@
 	if (acl_next_hook_mail_storage_created != NULL) {
 		hook_mail_storage_created =
 			acl_next_hook_mail_storage_created;
+		hook_mailbox_list_created =
+			acl_next_hook_mailbox_list_created;
 	}
 }

Index: acl-plugin.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/acl/acl-plugin.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- acl-plugin.h	28 Jun 2006 13:10:55 -0000	1.2
+++ acl-plugin.h	16 Nov 2006 00:17:15 -0000	1.3
@@ -30,12 +30,21 @@
 
 extern void (*acl_next_hook_mail_storage_created)
 	(struct mail_storage *storage);
+extern void (*acl_next_hook_mailbox_list_created)(struct mailbox_list *list);
 extern unsigned int acl_storage_module_id;
 
 void acl_mail_storage_created(struct mail_storage *storage);
+void acl_mailbox_list_created(struct mailbox_list *list);
 
 struct mailbox *acl_mailbox_open_box(struct mailbox *box);
 
+const char *
+acl_storage_get_parent_mailbox_name(struct mail_storage *storage,
+				    const char *name);
+int acl_storage_have_right(struct mail_storage *storage, const char *name,
+			   unsigned int acl_storage_right_idx, bool *can_see_r);
+void acl_mailbox_list_set_storage(struct mail_storage *storage);
+
 void acl_plugin_init(void);
 void acl_plugin_deinit(void);
 

Index: acl-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/acl/acl-storage.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- acl-storage.c	28 Feb 2006 12:38:20 -0000	1.2
+++ acl-storage.c	16 Nov 2006 00:17:15 -0000	1.3
@@ -25,9 +25,8 @@
 	MAIL_ACL_ADMIN
 };
 
-static int
-acl_storage_have_right(struct mail_storage *storage, const char *name,
-		       unsigned int acl_storage_right_idx, bool *can_see_r)
+int acl_storage_have_right(struct mail_storage *storage, const char *name,
+			   unsigned int acl_storage_right_idx, bool *can_see_r)
 {
 	struct acl_mail_storage *astorage = ACL_CONTEXT(storage);
 	const unsigned int *idx_arr = astorage->acl_storage_right_idx;
@@ -49,8 +48,9 @@
 	return ret;
 }
 
-static const char *
-get_parent_mailbox_name(struct mail_storage *storage, const char *name)
+const char *
+acl_storage_get_parent_mailbox_name(struct mail_storage *storage,
+				    const char *name)
 {
 	const char *p;
 	char sep;
@@ -115,8 +115,8 @@
 
 	t_push();
 	ret = acl_storage_have_right(storage,
-				     get_parent_mailbox_name(storage, name),
-				     ACL_STORAGE_RIGHT_CREATE, NULL);
+			acl_storage_get_parent_mailbox_name(storage, name),
+			ACL_STORAGE_RIGHT_CREATE, NULL);
 	t_pop();
 
 	if (ret <= 0) {
@@ -183,8 +183,8 @@
 	/* and create the new one under the parent mailbox */
 	t_push();
 	ret = acl_storage_have_right(storage,
-				     get_parent_mailbox_name(storage, newname),
-				     ACL_STORAGE_RIGHT_CREATE, NULL);
+			acl_storage_get_parent_mailbox_name(storage, newname),
+			ACL_STORAGE_RIGHT_CREATE, NULL);
 	t_pop();
 
 	if (ret <= 0) {
@@ -201,83 +201,6 @@
 	return astorage->super.mailbox_rename(storage, oldname, newname);
 }
 
-static struct mailbox_list *
-acl_mailbox_list_next(struct mailbox_list_context *ctx)
-{
-	struct acl_mail_storage *astorage = ACL_CONTEXT(ctx->storage);
-	struct mailbox_list *list;
-	int ret;
-
-	for (;;) {
-		list = astorage->super.mailbox_list_next(ctx);
-		if (list == NULL)
-			return NULL;
-
-		ret = acl_storage_have_right(ctx->storage, list->name,
-					     ACL_STORAGE_RIGHT_LOOKUP, NULL);
-		if (ret > 0)
-			return list;
-		if (ret < 0) {
-			ctx->failed = TRUE;
-			return NULL;
-		}
-
-		/* no permission to see this mailbox */
-		if ((ctx->flags & MAILBOX_LIST_SUBSCRIBED) != 0) {
-			/* it's subscribed, show it as non-existent */
-			if ((ctx->flags & MAILBOX_LIST_FAST_FLAGS) == 0)
-				list->flags = MAILBOX_NONEXISTENT;
-			return list;
-		}
-
-		/* skip to next one */
-	}
-}
-
-static int acl_get_mailbox_name_status(struct mail_storage *storage,
-				       const char *name,
-				       enum mailbox_name_status *status)
-{
-	struct acl_mail_storage *astorage = ACL_CONTEXT(storage);
-	int ret;
-
-	ret = acl_storage_have_right(storage, name,
-				     ACL_STORAGE_RIGHT_LOOKUP, NULL);
-	if (ret < 0)
-		return -1;
-
-	if (astorage->super.get_mailbox_name_status(storage, name, status) < 0)
-		return -1;
-	if (ret > 0)
-		return 0;
-
-	/* we shouldn't reveal this mailbox's existance */
-	switch (*status) {
-	case MAILBOX_NAME_EXISTS:
-		*status = MAILBOX_NAME_VALID;
-		break;
-	case MAILBOX_NAME_VALID:
-	case MAILBOX_NAME_INVALID:
-		break;
-	case MAILBOX_NAME_NOINFERIORS:
-		/* have to check if we are allowed to see the parent */
-		t_push();
-		ret = acl_storage_have_right(storage,
-				get_parent_mailbox_name(storage, name),
-				ACL_STORAGE_RIGHT_LOOKUP, NULL);
-		t_pop();
-
-		if (ret < 0)
-			return -1;
-		if (ret == 0) {
-			/* no permission to see the parent */
-			*status = MAILBOX_NAME_VALID;
-		}
-		break;
-	}
-	return 0;
-}
-
 void acl_mail_storage_created(struct mail_storage *storage)
 {
 	struct acl_mail_storage *astorage;
@@ -301,7 +224,7 @@
 		(storage->flags & MAIL_STORAGE_FLAG_SHARED_NAMESPACE) == 0 ?
 		getenv("USER") : NULL;
 	backend = acl_backend_init(acl_env, storage, user_env, NULL,
-				  owner_username);
+				   owner_username);
 	if (backend == NULL)
 		i_fatal("ACL backend initialization failed");
 
@@ -319,8 +242,8 @@
 	storage->v.mailbox_create = acl_mailbox_create;
 	storage->v.mailbox_delete = acl_mailbox_delete;
 	storage->v.mailbox_rename = acl_mailbox_rename;
-	storage->v.mailbox_list_next = acl_mailbox_list_next;
-	storage->v.get_mailbox_name_status = acl_get_mailbox_name_status;
+
+	acl_mailbox_list_set_storage(storage);
 
 	/* build ACL right lookup table */
 	for (i = 0; i < ACL_STORAGE_RIGHT_COUNT; i++) {
@@ -337,3 +260,4 @@
 	array_idx_set(&storage->module_contexts,
 		      acl_storage_module_id, &astorage);
 }
+



More information about the dovecot-cvs mailing list