[dovecot-cvs] dovecot/src/plugins/acl acl-mailbox-list.c, 1.2, 1.3 acl-mailbox.c, 1.3, 1.4 acl-storage.c, 1.3, 1.4

tss at dovecot.org tss at dovecot.org
Thu Mar 29 10:59:13 EEST 2007


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

Modified Files:
	acl-mailbox-list.c acl-mailbox.c acl-storage.c 
Log Message:
Moved delete/rename operations to mailbox_list API. Fixed mbox/maildir to
work with either fs/maildir++ directory layout. They can be changed by
appending :LAYOUT=fs|maildir++ to mail_location.



Index: acl-mailbox-list.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/acl/acl-mailbox-list.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- acl-mailbox-list.c	18 Nov 2006 11:53:59 -0000	1.2
+++ acl-mailbox-list.c	29 Mar 2007 07:59:11 -0000	1.3
@@ -102,6 +102,76 @@
 	return 0;
 }
 
+static int
+acl_mailbox_list_delete(struct mailbox_list *list, const char *name)
+{
+	struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(list);
+	bool can_see;
+	int ret;
+
+	ret = acl_storage_have_right(alist->storage, name,
+				     ACL_STORAGE_RIGHT_DELETE, &can_see);
+	if (ret <= 0) {
+		if (ret < 0)
+			return -1;
+		if (can_see) {
+			mail_storage_set_error(alist->storage,
+					       MAILBOX_LIST_ERR_NO_PERMISSION);
+		} else {
+			mail_storage_set_error(alist->storage,
+				MAILBOX_LIST_ERR_MAILBOX_NOT_FOUND, name);
+		}
+		return -1;
+	}
+
+	return alist->super.delete_mailbox(list, name);
+}
+
+static int
+acl_mailbox_list_rename(struct mailbox_list *list,
+			const char *oldname, const char *newname)
+{
+	struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(list);
+	bool can_see;
+	int ret;
+
+	/* renaming requires rights to delete the old mailbox */
+	ret = acl_storage_have_right(alist->storage, oldname,
+				     ACL_STORAGE_RIGHT_DELETE, &can_see);
+	if (ret <= 0) {
+		if (ret < 0)
+			return -1;
+		if (can_see) {
+			mail_storage_set_error(alist->storage,
+					       MAILBOX_LIST_ERR_NO_PERMISSION);
+		} else {
+			mail_storage_set_error(alist->storage,
+				MAILBOX_LIST_ERR_MAILBOX_NOT_FOUND, oldname);
+		}
+		return 0;
+	}
+
+	/* and create the new one under the parent mailbox */
+	t_push();
+	ret = acl_storage_have_right(alist->storage,
+		acl_storage_get_parent_mailbox_name(alist->storage, newname),
+		ACL_STORAGE_RIGHT_CREATE, NULL);
+	t_pop();
+
+	if (ret <= 0) {
+		if (ret == 0) {
+			/* Note that if the mailbox didn't have LOOKUP
+			   permission, this not reveals to user the mailbox's
+			   existence. Can't help it. */
+			mail_storage_set_error(alist->storage,
+					       MAILBOX_LIST_ERR_NO_PERMISSION);
+		}
+		return -1;
+	}
+
+	return alist->super.rename_mailbox(list, oldname, newname);
+}
+
 void acl_mailbox_list_created(struct mailbox_list *list)
 {
 	struct acl_mailbox_list *alist;
@@ -113,6 +183,8 @@
 	alist->super = list->v;
 	list->v.iter_next = acl_mailbox_list_iter_next;
 	list->v.get_mailbox_name_status = acl_get_mailbox_name_status;
+	list->v.delete_mailbox = acl_mailbox_list_delete;
+	list->v.rename_mailbox = acl_mailbox_list_rename;
 
 	if (!acl_mailbox_list_module_id_set) {
 		acl_mailbox_list_module_id = mailbox_list_module_id++;

Index: acl-mailbox.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/acl/acl-mailbox.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- acl-mailbox.c	28 Jun 2006 13:10:55 -0000	1.3
+++ acl-mailbox.c	29 Mar 2007 07:59:11 -0000	1.4
@@ -7,7 +7,7 @@
 #include "lib.h"
 #include "array.h"
 #include "istream.h"
-#include "mail-storage-private.h"
+#include "mailbox-list-private.h"
 #include "acl-api-private.h"
 #include "acl-plugin.h"
 
@@ -49,7 +49,7 @@
 	if (ret < 0)
 		return -1;
 
-	mail_storage_set_error(box->storage, MAIL_STORAGE_ERR_NO_PERMISSION);
+	mail_storage_set_error(box->storage, MAILBOX_LIST_ERR_NO_PERMISSION);
 	return 0;
 }
 

Index: acl-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/acl/acl-storage.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- acl-storage.c	16 Nov 2006 00:17:15 -0000	1.3
+++ acl-storage.c	29 Mar 2007 07:59:11 -0000	1.4
@@ -4,6 +4,7 @@
 #include "array.h"
 #include "istream.h"
 #include "acl-api-private.h"
+#include "mailbox-list-private.h"
 #include "acl-plugin.h"
 
 #include <stdlib.h>
@@ -92,10 +93,10 @@
 			return NULL;
 		if (can_see) {
 			mail_storage_set_error(storage,
-					       MAIL_STORAGE_ERR_NO_PERMISSION);
+					       MAILBOX_LIST_ERR_NO_PERMISSION);
 		} else {
 			mail_storage_set_error(storage,
-				MAIL_STORAGE_ERR_MAILBOX_NOT_FOUND, name);
+				MAILBOX_LIST_ERR_MAILBOX_NOT_FOUND, name);
 		}
 		return NULL;
 	}
@@ -125,7 +126,7 @@
 			   permission, this not reveals to user the mailbox's
 			   existence. Can't help it. */
 			mail_storage_set_error(storage,
-					       MAIL_STORAGE_ERR_NO_PERMISSION);
+					       MAILBOX_LIST_ERR_NO_PERMISSION);
 		}
 		return -1;
 	}
@@ -133,74 +134,6 @@
 	return astorage->super.mailbox_create(storage, name, directory);
 }
 
-static int acl_mailbox_delete(struct mail_storage *storage, const char *name)
-{
-	struct acl_mail_storage *astorage = ACL_CONTEXT(storage);
-	bool can_see;
-	int ret;
-
-	ret = acl_storage_have_right(storage, name, ACL_STORAGE_RIGHT_DELETE,
-				     &can_see);
-	if (ret <= 0) {
-		if (ret < 0)
-			return -1;
-		if (can_see) {
-			mail_storage_set_error(storage,
-					       MAIL_STORAGE_ERR_NO_PERMISSION);
-		} else {
-			mail_storage_set_error(storage,
-				MAIL_STORAGE_ERR_MAILBOX_NOT_FOUND, name);
-		}
-		return -1;
-	}
-
-	return astorage->super.mailbox_delete(storage, name);
-}
-
-static int acl_mailbox_rename(struct mail_storage *storage, const char *oldname,
-			      const char *newname)
-{
-	struct acl_mail_storage *astorage = ACL_CONTEXT(storage);
-	bool can_see;
-	int ret;
-
-	/* renaming requires rights to delete the old mailbox */
-	ret = acl_storage_have_right(storage, oldname,
-				     ACL_STORAGE_RIGHT_DELETE, &can_see);
-	if (ret <= 0) {
-		if (ret < 0)
-			return -1;
-		if (can_see) {
-			mail_storage_set_error(storage,
-					       MAIL_STORAGE_ERR_NO_PERMISSION);
-		} else {
-			mail_storage_set_error(storage,
-				MAIL_STORAGE_ERR_MAILBOX_NOT_FOUND, oldname);
-		}
-		return 0;
-	}
-
-	/* and create the new one under the parent mailbox */
-	t_push();
-	ret = acl_storage_have_right(storage,
-			acl_storage_get_parent_mailbox_name(storage, newname),
-			ACL_STORAGE_RIGHT_CREATE, NULL);
-	t_pop();
-
-	if (ret <= 0) {
-		if (ret == 0) {
-			/* Note that if the mailbox didn't have LOOKUP
-			   permission, this not reveals to user the mailbox's
-			   existence. Can't help it. */
-			mail_storage_set_error(storage,
-					       MAIL_STORAGE_ERR_NO_PERMISSION);
-		}
-		return -1;
-	}
-
-	return astorage->super.mailbox_rename(storage, oldname, newname);
-}
-
 void acl_mail_storage_created(struct mail_storage *storage)
 {
 	struct acl_mail_storage *astorage;
@@ -240,8 +173,6 @@
 	storage->v.destroy = acl_storage_destroy;
 	storage->v.mailbox_open = acl_mailbox_open;
 	storage->v.mailbox_create = acl_mailbox_create;
-	storage->v.mailbox_delete = acl_mailbox_delete;
-	storage->v.mailbox_rename = acl_mailbox_rename;
 
 	acl_mailbox_list_set_storage(storage);
 



More information about the dovecot-cvs mailing list