dovecot-2.0: acl: When creating a new child mailbox, copy parent...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Jun 28 06:32:53 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/43254b30c17f
changeset: 9549:43254b30c17f
user: Timo Sirainen <tss at iki.fi>
date: Sat Jun 27 23:32:46 2009 -0400
description:
acl: When creating a new child mailbox, copy parent's ACLs to it.
diffstat:
1 file changed, 25 insertions(+), 1 deletion(-)
src/plugins/acl/acl-mailbox.c | 26 +++++++++++++++++++++++++-
diffs (43 lines):
diff -r ac0a9729fe3c -r 43254b30c17f src/plugins/acl/acl-mailbox.c
--- a/src/plugins/acl/acl-mailbox.c Sat Jun 27 23:32:31 2009 -0400
+++ b/src/plugins/acl/acl-mailbox.c Sat Jun 27 23:32:46 2009 -0400
@@ -103,6 +103,26 @@ static void acl_mailbox_close(struct mai
abox->module_ctx.super.close(box);
}
+static void acl_mailbox_copy_acls_from_parent(struct mailbox *box)
+{
+ struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(box->list);
+ struct acl_object *parent_aclobj;
+ struct acl_object_list_iter *iter;
+ struct acl_rights_update update;
+
+ memset(&update, 0, sizeof(update));
+ update.modify_mode = ACL_MODIFY_MODE_REPLACE;
+ update.neg_modify_mode = ACL_MODIFY_MODE_REPLACE;
+
+ parent_aclobj = acl_object_init_from_parent(alist->rights.backend,
+ box->name);
+ iter = acl_object_list_init(parent_aclobj);
+ while (acl_object_list_next(iter, &update.rights) > 0)
+ (void)acl_object_update(abox->aclobj, &update);
+ acl_object_list_deinit(&iter);
+ acl_object_deinit(&parent_aclobj);
+}
static int
acl_mailbox_create(struct mailbox *box, const struct mailbox_update *update,
bool directory)
@@ -123,7 +143,11 @@ acl_mailbox_create(struct mailbox *box,
MAIL_ERRSTR_NO_PERMISSION);
return -1;
}
- return abox->module_ctx.super.create(box, update, directory);
+ if (abox->module_ctx.super.create(box, update, directory) < 0)
+ return -1;
+
+ acl_mailbox_copy_acls_from_parent(box);
+ return 0;
}
static int
More information about the dovecot-cvs
mailing list