Lines Matching refs:box

27 struct acl_object *acl_mailbox_get_aclobj(struct mailbox *box)
29 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
34 int acl_mailbox_right_lookup(struct mailbox *box, unsigned int right_idx)
36 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
42 struct acl_mailbox_list *alist = ACL_LIST_CONTEXT_REQUIRE(box->list);
49 mail_storage_set_internal_error(box->storage);
53 mail_storage_set_error(box->storage, MAIL_ERROR_PERM,
58 static bool acl_is_readonly(struct mailbox *box)
60 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
63 if (abox->module_ctx.super.is_readonly(box))
66 save_right = (box->flags & MAILBOX_FLAG_POST_SESSION) != 0 ?
68 if (acl_mailbox_right_lookup(box, save_right) > 0)
70 if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_EXPUNGE) > 0)
73 if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE) > 0)
75 if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_DELETED) > 0)
77 if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_SEEN) > 0)
83 static void acl_mailbox_free(struct mailbox *box)
85 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
88 abox->module_ctx.super.free(box);
91 static void acl_mailbox_copy_acls_from_parent(struct mailbox *box)
93 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
94 struct acl_mailbox_list *alist = ACL_LIST_CONTEXT_REQUIRE(box->list);
104 box->name);
117 acl_mailbox_create(struct mailbox *box, const struct mailbox_update *update,
120 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
123 if (!mailbox_is_autocreated(box)) {
125 ret = acl_mailbox_list_have_right(box->list, box->name, TRUE,
134 mail_storage_set_internal_error(box->storage);
140 mail_storage_set_error(box->storage, MAIL_ERROR_PERM,
149 ret = abox->module_ctx.super.create_box(box, update, directory);
152 acl_mailbox_copy_acls_from_parent(box);
157 acl_mailbox_update(struct mailbox *box, const struct mailbox_update *update)
159 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
162 ret = acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_ADMIN);
165 return abox->module_ctx.super.update_box(box, update);
168 static void acl_mailbox_fail_not_found(struct mailbox *box)
172 ret = acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_LOOKUP);
174 mail_storage_set_error(box->storage, MAIL_ERROR_PERM,
177 mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
178 T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname));
183 acl_mailbox_delete(struct mailbox *box)
185 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
188 ret = acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_DELETE);
191 acl_mailbox_fail_not_found(box);
195 return abox->module_ctx.super.delete_box(box);
235 acl_get_write_rights(struct mailbox *box,
240 ret = acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE);
245 ret = acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_SEEN);
250 ret = acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_DELETED);
271 if (acl_get_write_rights(_mail->box, &acl_flags, &acl_flag_seen,
312 ret = acl_mailbox_right_lookup(_mail->box, ACL_STORAGE_RIGHT_WRITE);
329 ret = acl_mailbox_right_lookup(_mail->box, ACL_STORAGE_RIGHT_EXPUNGE);
343 struct acl_mailbox *abox = ACL_CONTEXT(_mail->box);
362 acl_save_get_flags(struct mailbox *box, enum mail_flags *flags,
367 if (acl_get_write_rights(box, &acl_flags, &acl_flag_seen,
390 struct mailbox *box = ctx->transaction->box;
391 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
394 save_right = (box->flags & MAILBOX_FLAG_POST_SESSION) != 0 ?
396 if (acl_mailbox_right_lookup(box, save_right) <= 0)
398 if (acl_save_get_flags(box, &ctx->data.flags,
408 struct mailbox *destbox = ctx->transaction->box;
412 if (acl_mailbox_right_lookup(mail->box,
431 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(t->box);
445 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(ctx->box);
462 static int acl_mailbox_exists(struct mailbox *box, bool auto_boxes,
465 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
482 return abox->module_ctx.super.exists(box, auto_boxes,
489 static int acl_mailbox_open_check_acl(struct mailbox *box)
491 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
492 struct acl_mailbox_list *alist = ACL_LIST_CONTEXT_REQUIRE(box->list);
498 if ((box->flags & MAILBOX_FLAG_IGNORE_ACLS) != 0 ||
499 (box->list->ns->flags & NAMESPACE_FLAG_NOACL) != 0 ||
503 if ((box->flags & MAILBOX_FLAG_SAVEONLY) != 0) {
504 open_right = (box->flags & MAILBOX_FLAG_POST_SESSION) != 0 ?
506 } else if (box->deleting) {
516 acl_mailbox_fail_not_found(box);
531 static int acl_mailbox_open(struct mailbox *box)
533 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
535 if (acl_mailbox_open_check_acl(box) < 0)
538 return abox->module_ctx.super.open(box);
541 static int acl_mailbox_get_status(struct mailbox *box,
545 struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
547 if (abox->module_ctx.super.get_status(box, items, status_r) < 0)
551 if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE) <= 0) {
556 if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_DELETED) <= 0)
558 if (acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_WRITE_SEEN) <= 0)
564 void acl_mailbox_allocated(struct mailbox *box)
566 struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(box->list);
567 struct mailbox_vfuncs *v = box->vlast;
569 bool ignore_acls = (box->flags & MAILBOX_FLAG_IGNORE_ACLS) != 0;
576 if (mail_namespace_is_shared_user_root(box->list->ns)) {
582 abox = p_new(box->pool, struct acl_mailbox, 1);
584 box->vlast = &abox->module_ctx.super;
588 mailbox_get_name(box));
610 MODULE_CONTEXT_SET(box, acl_storage_module, abox);
647 aclobj = acl_mailbox_get_aclobj(t->box);
649 mailbox_set_critical(t->box, "Failed to set ACL");