enum mail_attribute_type type, const char *key,
const struct mail_attribute_value *value)
{
- struct acl_mailbox *abox = ACL_CONTEXT(t->box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(t->box);
if (acl_have_attribute_rights(t->box) < 0)
return -1;
enum mail_attribute_type type, const char *key,
struct mail_attribute_value *value_r)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
if (acl_have_attribute_rights(box) < 0)
return -1;
acl_attribute_iter_init(struct mailbox *box, enum mail_attribute_type type,
const char *prefix)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
struct acl_mailbox_attribute_iter *aiter;
aiter = i_new(struct acl_mailbox_attribute_iter, 1);
{
struct acl_mailbox_attribute_iter *aiter =
(struct acl_mailbox_attribute_iter *)iter;
- struct acl_mailbox *abox = ACL_CONTEXT(iter->box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(iter->box);
const char *key;
if (aiter->super == NULL)
{
struct acl_mailbox_attribute_iter *aiter =
(struct acl_mailbox_attribute_iter *)iter;
- struct acl_mailbox *abox = ACL_CONTEXT(iter->box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(iter->box);
int ret = aiter->failed ? -1 : 0;
if (aiter->super != NULL) {
#include <sys/stat.h>
#define ACL_MAIL_CONTEXT(obj) \
- MODULE_CONTEXT(obj, acl_mail_module)
+ MODULE_CONTEXT_REQUIRE(obj, acl_mail_module)
struct acl_transaction_context {
union mailbox_transaction_module_context module_ctx;
struct acl_object *acl_mailbox_get_aclobj(struct mailbox *box)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
return abox->aclobj;
}
int acl_mailbox_right_lookup(struct mailbox *box, unsigned int right_idx)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(box->list);
int ret;
static bool acl_is_readonly(struct mailbox *box)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
enum acl_storage_rights save_right;
if (abox->module_ctx.super.is_readonly(box))
static void acl_mailbox_free(struct mailbox *box)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
acl_object_deinit(&abox->aclobj);
abox->module_ctx.super.free(box);
static void acl_mailbox_copy_acls_from_parent(struct mailbox *box)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(box->list);
struct acl_object *parent_aclobj;
struct acl_object_list_iter *iter;
acl_mailbox_create(struct mailbox *box, const struct mailbox_update *update,
bool directory)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
int ret;
if (!mailbox_is_autocreated(box)) {
static int
acl_mailbox_update(struct mailbox *box, const struct mailbox_update *update)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
int ret;
ret = acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_ADMIN);
static int
acl_mailbox_delete(struct mailbox *box)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
int ret;
ret = acl_mailbox_right_lookup(box, ACL_STORAGE_RIGHT_DELETE);
static int
acl_mailbox_rename(struct mailbox *src, struct mailbox *dest)
{
- struct acl_mailbox *abox = ACL_CONTEXT(src);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(src);
int ret;
/* renaming requires rights to delete the old mailbox */
acl_save_begin(struct mail_save_context *ctx, struct istream *input)
{
struct mailbox *box = ctx->transaction->box;
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
enum acl_storage_rights save_right;
save_right = (box->flags & MAILBOX_FLAG_POST_SESSION) != 0 ?
acl_copy(struct mail_save_context *ctx, struct mail *mail)
{
struct mailbox_transaction_context *t = ctx->transaction;
- struct acl_mailbox *abox = ACL_CONTEXT(t->box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(t->box);
if (!acl_copy_has_rights(ctx, mail)) {
mailbox_save_cancel(&ctx);
return -1;
}
+ i_assert(abox != NULL);
+
ret = abox->module_ctx.super.transaction_commit(ctx, changes_r);
if (abox->no_read_right) {
/* don't allow IMAP client to see what UIDs the messages got */
static int acl_mailbox_exists(struct mailbox *box, bool auto_boxes,
enum mailbox_existence *existence_r)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
const char *const *rights;
unsigned int i;
static int acl_mailbox_open_check_acl(struct mailbox *box)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
struct acl_mailbox_list *alist = ACL_LIST_CONTEXT(box->list);
const unsigned int *idx_arr = alist->rights.acl_storage_right_idx;
enum acl_storage_rights open_right;
static int acl_mailbox_open(struct mailbox *box)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
if (acl_mailbox_open_check_acl(box) < 0)
return -1;
enum mailbox_status_items items,
struct mailbox_status *status_r)
{
- struct acl_mailbox *abox = ACL_CONTEXT(box);
+ struct acl_mailbox *abox = ACL_CONTEXT_REQUIRE(box);
if (abox->module_ctx.super.get_status(box, items, status_r) < 0)
return -1;