bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch/* Copyright (c) 2011-2018 Dovecot authors, see the included COPYING file */
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen#include "lib.h"
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen#include "str.h"
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen#include "module-dir.h"
facd0971af3c905a3838ba14abc5682f285c9464Timo Sirainen#include "imap-util.h"
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen#include "acl-plugin.h"
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen#include "acl-api-private.h"
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen#include "acl-lookup-dict.h"
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen#include "doveadm-print.h"
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen#include "doveadm-mail.h"
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenstruct doveadm_acl_cmd_context {
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct doveadm_mail_cmd_context ctx;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen bool get_match_me;
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen enum acl_modify_mode modify_mode;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen};
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
bd63b5b860658b01b1f46f26d406e1e4a9dc019aTimo Sirainenconst char *doveadm_acl_plugin_version = DOVECOT_ABI_VERSION;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenvoid doveadm_acl_plugin_init(struct module *module);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenvoid doveadm_acl_plugin_deinit(void);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenstatic int
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainencmd_acl_mailbox_open(struct doveadm_mail_cmd_context *ctx,
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen struct mail_user *user, const char *mailbox,
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct mailbox **box_r)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct acl_user *auser = ACL_USER_CONTEXT(user);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct mail_namespace *ns;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct mailbox *box;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen if (auser == NULL) {
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen i_error("ACL not enabled for %s", user->username);
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen doveadm_mail_failed_error(ctx, MAIL_ERROR_NOTFOUND);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen return -1;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen }
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen ns = mail_namespace_find(user->namespaces, mailbox);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen box = mailbox_alloc(ns->list, mailbox,
4145cbac82bfc0c8bfeceeca0ef841700117930cTimo Sirainen MAILBOX_FLAG_READONLY | MAILBOX_FLAG_IGNORE_ACLS);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen if (mailbox_open(box) < 0) {
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen i_error("Can't open mailbox %s: %s", mailbox,
bf7dc750b95039981c0e9d728f313d50cf38a156Martti Rannanjärvi mailbox_get_last_internal_error(box, NULL));
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen doveadm_mail_failed_mailbox(ctx, box);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen mailbox_free(&box);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen return -1;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen }
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen *box_r = box;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen return 0;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenstatic void cmd_acl_get_right(const struct acl_rights *rights)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen string_t *str;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen doveadm_print(acl_rights_get_id(rights));
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen if (rights->global)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_print("global");
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen else
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_print("");
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen str = t_str_new(256);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen if (rights->rights != NULL)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen str_append(str, t_strarray_join(rights->rights, " "));
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen if (rights->neg_rights != NULL) {
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen if (str_len(str) > 0)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen str_append_c(str, ' ');
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen str_append_c(str, '-');
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen str_append(str, t_strarray_join(rights->neg_rights, " -"));
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen }
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_print(str_c(str));
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainenstatic int cmd_acl_get_mailbox(struct doveadm_acl_cmd_context *ctx,
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen struct mailbox *box)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct acl_object *aclobj = acl_mailbox_get_aclobj(box);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct acl_backend *backend;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct acl_object_list_iter *iter;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct acl_rights rights;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen int ret;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen backend = acl_mailbox_list_get_backend(box->list);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen iter = acl_object_list_init(aclobj);
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi while (acl_object_list_next(iter, &rights)) T_BEGIN {
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen if (!ctx->get_match_me ||
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen acl_backend_rights_match_me(backend, &rights))
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen cmd_acl_get_right(&rights);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen } T_END;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi if ((ret = acl_object_list_deinit(&iter))<0) {
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen i_error("ACL iteration failed");
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen doveadm_mail_failed_error(&ctx->ctx, MAIL_ERROR_TEMP);
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen }
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen return ret;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainenstatic int
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainencmd_acl_get_run(struct doveadm_mail_cmd_context *_ctx,
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct mail_user *user)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct doveadm_acl_cmd_context *ctx =
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen (struct doveadm_acl_cmd_context *)_ctx;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen const char *mailbox = _ctx->args[0];
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct mailbox *box;
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen int ret;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen if (cmd_acl_mailbox_open(_ctx, user, mailbox, &box) < 0)
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen return -1;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen ret = cmd_acl_get_mailbox(ctx, box);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen mailbox_free(&box);
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen return ret;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenstatic bool cmd_acl_get_parse_arg(struct doveadm_mail_cmd_context *_ctx, int c)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct doveadm_acl_cmd_context *ctx =
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen (struct doveadm_acl_cmd_context *)_ctx;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen switch (c) {
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen case 'm':
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen ctx->get_match_me = TRUE;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen break;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen default:
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen return FALSE;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen }
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen return TRUE;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenstatic void cmd_acl_get_init(struct doveadm_mail_cmd_context *ctx ATTR_UNUSED,
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen const char *const args[])
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen if (args[0] == NULL)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_mail_help_name("acl get");
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_print_header("id", "ID", 0);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_print_header("global", "Global", 0);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_print_header("rights", "Rights", 0);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenstatic struct doveadm_mail_cmd_context *
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainencmd_acl_get_alloc(void)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct doveadm_acl_cmd_context *ctx;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen ctx = doveadm_mail_cmd_alloc(struct doveadm_acl_cmd_context);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen ctx->ctx.getopt_args = "m";
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen ctx->ctx.v.parse_arg = cmd_acl_get_parse_arg;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen ctx->ctx.v.run = cmd_acl_get_run;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen ctx->ctx.v.init = cmd_acl_get_init;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen return &ctx->ctx;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainenstatic int
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainencmd_acl_rights_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen const char *mailbox = ctx->args[0];
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct mailbox *box;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct acl_object *aclobj;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen const char *const *rights;
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen int ret = 0;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen if (cmd_acl_mailbox_open(ctx, user, mailbox, &box) < 0)
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen return -1;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen aclobj = acl_mailbox_get_aclobj(box);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen if (acl_object_get_my_rights(aclobj, pool_datastack_create(),
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen &rights) < 0) {
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen doveadm_mail_failed_error(ctx, MAIL_ERROR_TEMP);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen i_error("Failed to get rights");
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen ret = -1;
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen } else {
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_print(t_strarray_join(rights, " "));
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen }
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen mailbox_free(&box);
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen return ret;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenstatic void cmd_acl_rights_init(struct doveadm_mail_cmd_context *ctx ATTR_UNUSED,
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen const char *const args[])
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen if (args[0] == NULL)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_mail_help_name("acl rights");
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_print_header("rights", "Rights", 0);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenstatic struct doveadm_mail_cmd_context *
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainencmd_acl_rights_alloc(void)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct doveadm_mail_cmd_context *ctx;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen ctx->v.run = cmd_acl_rights_run;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen ctx->v.init = cmd_acl_rights_init;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_print_init(DOVEADM_PRINT_TYPE_TABLE);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen return ctx;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainenstatic int
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainencmd_acl_mailbox_update(struct mailbox *box,
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen const struct acl_rights_update *update)
be78bc833cb886e7ec24045f101b5565f2378b74Timo Sirainen{
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen struct mailbox_transaction_context *t;
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen int ret;
be78bc833cb886e7ec24045f101b5565f2378b74Timo Sirainen
0dab9cb35a976c49b28a11e28d5570f5191f1a7aMartti Rannanjärvi t = mailbox_transaction_begin(box, MAILBOX_TRANSACTION_FLAG_EXTERNAL,
0dab9cb35a976c49b28a11e28d5570f5191f1a7aMartti Rannanjärvi __func__);
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen ret = acl_mailbox_update_acl(t, update);
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen if (mailbox_transaction_commit(&t) < 0)
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen ret = -1;
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen return ret;
be78bc833cb886e7ec24045f101b5565f2378b74Timo Sirainen}
be78bc833cb886e7ec24045f101b5565f2378b74Timo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainenstatic int
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainencmd_acl_set_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen struct doveadm_acl_cmd_context *ctx =
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen (struct doveadm_acl_cmd_context *)_ctx;
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen const char *mailbox = _ctx->args[0], *id = _ctx->args[1];
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen const char *const *rights = _ctx->args + 2;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct mailbox *box;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen struct acl_rights_update update;
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen const char *error;
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen int ret;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen if (cmd_acl_mailbox_open(_ctx, user, mailbox, &box) < 0)
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen return -1;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
efe78d3ba24fc866af1c79b9223dc0809ba26cadStephan Bosch i_zero(&update);
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen update.modify_mode = ctx->modify_mode;
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen update.neg_modify_mode = ctx->modify_mode;
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen if (acl_rights_update_import(&update, id, rights, &error) < 0)
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen i_fatal_status(EX_USAGE, "%s", error);
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen if ((ret = cmd_acl_mailbox_update(box, &update)) < 0) {
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen i_error("Failed to set ACL: %s",
bf7dc750b95039981c0e9d728f313d50cf38a156Martti Rannanjärvi mailbox_get_last_internal_error(box, NULL));
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen doveadm_mail_failed_error(_ctx, MAIL_ERROR_TEMP);
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen }
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen mailbox_free(&box);
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen return ret;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenstatic void cmd_acl_set_init(struct doveadm_mail_cmd_context *ctx ATTR_UNUSED,
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen const char *const args[])
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen if (str_array_length(args) < 3)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen doveadm_mail_help_name("acl set");
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenstatic struct doveadm_mail_cmd_context *
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainencmd_acl_change_alloc(enum acl_modify_mode modify_mode)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen struct doveadm_acl_cmd_context *ctx;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen ctx = doveadm_mail_cmd_alloc(struct doveadm_acl_cmd_context);
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen ctx->ctx.v.run = cmd_acl_set_run;
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen ctx->ctx.v.init = cmd_acl_set_init;
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen ctx->modify_mode = modify_mode;
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen return &ctx->ctx;
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen}
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainenstatic struct doveadm_mail_cmd_context *cmd_acl_set_alloc(void)
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen{
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen return cmd_acl_change_alloc(ACL_MODIFY_MODE_REPLACE);
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen}
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainenstatic struct doveadm_mail_cmd_context *cmd_acl_add_alloc(void)
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen{
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen return cmd_acl_change_alloc(ACL_MODIFY_MODE_ADD);
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen}
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainenstatic struct doveadm_mail_cmd_context *cmd_acl_remove_alloc(void)
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen{
efa7704816f76574c0b1d196ebee20c4d80e1c62Timo Sirainen return cmd_acl_change_alloc(ACL_MODIFY_MODE_REMOVE);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainenstatic int
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainencmd_acl_delete_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user)
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen{
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen const char *mailbox = ctx->args[0], *id = ctx->args[1];
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen struct mailbox *box;
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen struct acl_rights_update update;
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen const char *error;
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen int ret = 0;
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen if (cmd_acl_mailbox_open(ctx, user, mailbox, &box) < 0)
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen return -1;
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen
efe78d3ba24fc866af1c79b9223dc0809ba26cadStephan Bosch i_zero(&update);
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen if (acl_rights_update_import(&update, id, NULL, &error) < 0)
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen i_fatal_status(EX_USAGE, "%s", error);
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen if ((ret = cmd_acl_mailbox_update(box, &update)) < 0) {
eb4d4f557fa75aa2a47639e9deb75a21f44eb42aTimo Sirainen i_error("Failed to delete ACL: %s",
bf7dc750b95039981c0e9d728f313d50cf38a156Martti Rannanjärvi mailbox_get_last_internal_error(box, NULL));
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen doveadm_mail_failed_error(ctx, MAIL_ERROR_TEMP);
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen }
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen mailbox_free(&box);
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen return ret;
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen}
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainenstatic void cmd_acl_delete_init(struct doveadm_mail_cmd_context *ctx ATTR_UNUSED,
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen const char *const args[])
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen{
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen if (str_array_length(args) < 2)
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen doveadm_mail_help_name("acl delete");
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen}
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainenstatic struct doveadm_mail_cmd_context *
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainencmd_acl_delete_alloc(void)
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen{
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen struct doveadm_mail_cmd_context *ctx;
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context);
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen ctx->v.run = cmd_acl_delete_run;
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen ctx->v.init = cmd_acl_delete_init;
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen return ctx;
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen}
3aa600b8467f5cec0fd2e0a76c4815973ca61e1fTimo Sirainen
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainenstatic int
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainencmd_acl_recalc_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user)
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen{
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen struct acl_user *auser = ACL_USER_CONTEXT(user);
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen if (auser == NULL) {
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen i_error("ACL not enabled for %s", user->username);
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen doveadm_mail_failed_error(ctx, MAIL_ERROR_NOTFOUND);
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen return -1;
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen }
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen if (acl_lookup_dict_rebuild(auser->acl_lookup_dict) < 0) {
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen i_error("Failed to recalculate ACL dicts");
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen doveadm_mail_failed_error(ctx, MAIL_ERROR_TEMP);
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen return -1;
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen }
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen return 0;
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen}
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainenstatic struct doveadm_mail_cmd_context *
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainencmd_acl_recalc_alloc(void)
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen{
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen struct doveadm_mail_cmd_context *ctx;
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context);
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen ctx->v.run = cmd_acl_recalc_run;
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen return ctx;
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen}
f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fbaTimo Sirainen
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainenstatic int
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainencmd_acl_debug_mailbox_open(struct doveadm_mail_cmd_context *ctx,
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen struct mail_user *user, const char *mailbox,
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen struct mailbox **box_r)
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen{
88a4bd48b03c451596414c16f72c0f4cc31b4745Aki Tuomi struct acl_user *auser = ACL_USER_CONTEXT_REQUIRE(user);
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen struct mail_namespace *ns;
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen struct mailbox *box;
737561538a2dcdcda948a1da2830a612d8263a23Timo Sirainen const char *path, *errstr;
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen enum mail_error error;
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen
737561538a2dcdcda948a1da2830a612d8263a23Timo Sirainen ns = mail_namespace_find(user->namespaces, mailbox);
737561538a2dcdcda948a1da2830a612d8263a23Timo Sirainen box = mailbox_alloc(ns->list, mailbox,
4145cbac82bfc0c8bfeceeca0ef841700117930cTimo Sirainen MAILBOX_FLAG_READONLY | MAILBOX_FLAG_IGNORE_ACLS);
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen if (mailbox_open(box) < 0) {
bf7dc750b95039981c0e9d728f313d50cf38a156Martti Rannanjärvi errstr = mail_storage_get_last_internal_error(box->storage, &error);
9fc97c8aa8190df87624d214bcc5d0b5362bec93Timo Sirainen errstr = t_strdup(errstr);
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen doveadm_mail_failed_error(ctx, error);
9fc97c8aa8190df87624d214bcc5d0b5362bec93Timo Sirainen
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen if (error != MAIL_ERROR_NOTFOUND ||
9fc97c8aa8190df87624d214bcc5d0b5362bec93Timo Sirainen mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX,
9fc97c8aa8190df87624d214bcc5d0b5362bec93Timo Sirainen &path) <= 0)
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen i_error("Can't open mailbox %s: %s", mailbox, errstr);
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen else {
02076e06658a2f1ee2d6bb76944dc1b5d12e1d7dTimo Sirainen i_error("Mailbox '%s' in namespace '%s' doesn't exist in %s",
02076e06658a2f1ee2d6bb76944dc1b5d12e1d7dTimo Sirainen box->name, ns->prefix, path);
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen }
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen mailbox_free(&box);
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen return -1;
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen }
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen if (auser == NULL) {
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen i_info("ACL not enabled for user %s, mailbox can be accessed",
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen user->username);
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen doveadm_mail_failed_error(ctx, MAIL_ERROR_NOTFOUND);
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen mailbox_free(&box);
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen return -1;
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen }
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen *box_r = box;
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen return 0;
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen}
376ed81e5532835eea0e31002d7298843c335b12Timo Sirainen
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainenstatic bool cmd_acl_debug_mailbox(struct mailbox *box, bool *retry_r)
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen{
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen struct mail_namespace *ns = mailbox_get_namespace(box);
88a4bd48b03c451596414c16f72c0f4cc31b4745Aki Tuomi struct acl_user *auser = ACL_USER_CONTEXT_REQUIRE(ns->user);
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen struct acl_object *aclobj = acl_mailbox_get_aclobj(box);
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen struct acl_backend *backend = acl_mailbox_list_get_backend(box->list);
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen struct acl_mailbox_list_context *iter;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen struct acl_lookup_dict_iter *diter;
02076e06658a2f1ee2d6bb76944dc1b5d12e1d7dTimo Sirainen const char *const *rights, *name, *path;
7b39597853fc030086b5237169e677173f9aab62Timo Sirainen enum mail_flags private_flags_mask;
facd0971af3c905a3838ba14abc5682f285c9464Timo Sirainen string_t *str;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen int ret;
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen bool all_ok = TRUE;
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen *retry_r = FALSE;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
02076e06658a2f1ee2d6bb76944dc1b5d12e1d7dTimo Sirainen i_info("Mailbox '%s' is in namespace '%s'",
02076e06658a2f1ee2d6bb76944dc1b5d12e1d7dTimo Sirainen box->name, box->list->ns->prefix);
02076e06658a2f1ee2d6bb76944dc1b5d12e1d7dTimo Sirainen if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_MAILBOX, &path) > 0)
02076e06658a2f1ee2d6bb76944dc1b5d12e1d7dTimo Sirainen i_info("Mailbox path: %s", path);
02076e06658a2f1ee2d6bb76944dc1b5d12e1d7dTimo Sirainen
7b39597853fc030086b5237169e677173f9aab62Timo Sirainen private_flags_mask = mailbox_get_private_flags_mask(box);
7b39597853fc030086b5237169e677173f9aab62Timo Sirainen if (private_flags_mask == 0)
facd0971af3c905a3838ba14abc5682f285c9464Timo Sirainen i_info("All message flags are shared across users in mailbox");
facd0971af3c905a3838ba14abc5682f285c9464Timo Sirainen else {
facd0971af3c905a3838ba14abc5682f285c9464Timo Sirainen str = t_str_new(64);
7b39597853fc030086b5237169e677173f9aab62Timo Sirainen imap_write_flags(str, private_flags_mask, NULL);
facd0971af3c905a3838ba14abc5682f285c9464Timo Sirainen i_info("Per-user private flags in mailbox: %s", str_c(str));
facd0971af3c905a3838ba14abc5682f285c9464Timo Sirainen }
facd0971af3c905a3838ba14abc5682f285c9464Timo Sirainen
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen /* check if user has lookup right */
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen if (acl_object_get_my_rights(aclobj, pool_datastack_create(),
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen &rights) < 0)
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen i_fatal("Failed to get rights");
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
7be1a5530fcb414588fbe90eaed65eff83e84737Timo Sirainen if (rights[0] == NULL)
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen i_info("User %s has no rights for mailbox", ns->user->username);
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen else {
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen i_info("User %s has rights: %s",
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen ns->user->username, t_strarray_join(rights, " "));
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen }
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen if (!str_array_find(rights, MAIL_ACL_LOOKUP)) {
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen i_error("User %s is missing 'lookup' right",
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen ns->user->username);
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen return FALSE;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen }
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen /* check if mailbox is listable */
3e0bae44b65f5c46989fcef3d1e07203f496327eTimo Sirainen if (ns->type == MAIL_NAMESPACE_TYPE_PRIVATE) {
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen i_info("Mailbox in user's private namespace");
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen return TRUE;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen }
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen iter = acl_backend_nonowner_lookups_iter_init(backend);
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi while (acl_backend_nonowner_lookups_iter_next(iter, &name)) {
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen if (strcmp(name, box->name) == 0)
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen break;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen }
37c72fa0cd3f1d74d79b64afb3fb6da5ffd4fe3aAki Tuomi if ((ret = acl_backend_nonowner_lookups_iter_deinit(&iter))<0)
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen i_fatal("ACL non-owner iteration failed");
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen if (ret == 0) {
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen i_error("Mailbox not found from dovecot-acl-list, rebuilding");
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen if (acl_backend_nonowner_lookups_rebuild(backend) < 0)
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen i_fatal("dovecot-acl-list rebuilding failed");
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen all_ok = FALSE;
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen *retry_r = TRUE;
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen } else {
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen i_info("Mailbox found from dovecot-acl-list");
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen }
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
3e0bae44b65f5c46989fcef3d1e07203f496327eTimo Sirainen if (ns->type == MAIL_NAMESPACE_TYPE_PUBLIC) {
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen i_info("Mailbox is in public namespace");
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen return TRUE;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen }
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen if (!acl_lookup_dict_is_enabled(auser->acl_lookup_dict)) {
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen i_error("acl_lookup_dict not enabled");
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen return FALSE;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen }
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen /* shared namespace. see if it's in acl lookup dict */
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen diter = acl_lookup_dict_iterate_visible_init(auser->acl_lookup_dict);
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen while ((name = acl_lookup_dict_iterate_visible_next(diter)) != NULL) {
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen if (strcmp(name, ns->owner->username) == 0)
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen break;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen }
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen if (acl_lookup_dict_iterate_visible_deinit(&diter) < 0)
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen i_fatal("ACL shared dict iteration failed");
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen if (name == NULL) {
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen i_error("User %s not found from ACL shared dict, rebuilding",
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen ns->owner->username);
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen if (acl_lookup_dict_rebuild(auser->acl_lookup_dict) < 0)
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen i_fatal("ACL lookup dict rebuild failed");
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen all_ok = FALSE;
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen *retry_r = TRUE;
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen } else {
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen i_info("User %s found from ACL shared dict",
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen ns->owner->username);
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen }
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen return all_ok;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen}
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainenstatic int
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainencmd_acl_debug_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user)
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen{
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen const char *mailbox = ctx->args[0];
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen struct mailbox *box;
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen bool ret, retry;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen if (cmd_acl_debug_mailbox_open(ctx, user, mailbox, &box) < 0)
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen return -1;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen ret = cmd_acl_debug_mailbox(box, &retry);
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen if (!ret && retry) {
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen i_info("Retrying after rebuilds:");
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen ret = cmd_acl_debug_mailbox(box, &retry);
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen }
6bd9ffc5d782e160c8542d53b26864ed973c8f66Timo Sirainen if (ret)
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen i_info("Mailbox %s is visible in LIST", box->vname);
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen else
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen i_info("Mailbox %s is NOT visible in LIST", box->vname);
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen mailbox_free(&box);
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen return 0;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen}
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainenstatic void cmd_acl_debug_init(struct doveadm_mail_cmd_context *ctx ATTR_UNUSED,
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen const char *const args[])
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen{
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen if (args[0] == NULL)
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen doveadm_mail_help_name("acl debug");
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen}
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainenstatic struct doveadm_mail_cmd_context *
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainencmd_acl_debug_alloc(void)
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen{
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen struct doveadm_mail_cmd_context *ctx;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context);
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen ctx->v.run = cmd_acl_debug_run;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen ctx->v.init = cmd_acl_debug_init;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen return ctx;
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen}
7c598f384223a1364e8040c1e2a4cad8d00edde6Timo Sirainen
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomistatic struct doveadm_cmd_ver2 acl_commands[] = {
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi{
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .name = "acl get",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .mail_cmd = cmd_acl_get_alloc,
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX "[-m] <mailbox>",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_START
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_MAIL_COMMON
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('m', "match-me", CMD_PARAM_BOOL, 0)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "mailbox", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_END
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi},
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi{
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .name = "acl rights",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .mail_cmd = cmd_acl_rights_alloc,
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX "<mailbox>",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_START
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_MAIL_COMMON
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "mailbox", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_END
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi},
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi{
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .name = "acl set",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .mail_cmd = cmd_acl_set_alloc,
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX "<mailbox> <id> <right> [<right> ...]",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_START
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_MAIL_COMMON
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "mailbox", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "id", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "right", CMD_PARAM_ARRAY, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_END
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi},
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi{
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .name = "acl add",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .mail_cmd = cmd_acl_add_alloc,
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX "<mailbox> <id> <right> [<right> ...]",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_START
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_MAIL_COMMON
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "mailbox", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "id", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "right", CMD_PARAM_ARRAY, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_END
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi},
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi{
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .name = "acl remove",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .mail_cmd = cmd_acl_remove_alloc,
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX "<mailbox> <id> <right> [<right> ...]",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_START
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_MAIL_COMMON
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "mailbox", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "id", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "right", CMD_PARAM_ARRAY, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_END
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi},
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi{
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .name = "acl delete",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .mail_cmd = cmd_acl_delete_alloc,
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX "<mailbox> <id>",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_START
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_MAIL_COMMON
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "mailbox", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "id", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_END
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi},
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi{
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .name = "acl recalc",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .mail_cmd = cmd_acl_recalc_alloc,
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX,
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_START
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_MAIL_COMMON
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_END
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi},
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi{
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .name = "acl debug",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .mail_cmd = cmd_acl_debug_alloc,
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi .usage = DOVEADM_CMD_MAIL_USAGE_PREFIX "<mailbox>",
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_START
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_MAIL_COMMON
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAM('\0', "mailbox", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki TuomiDOVEADM_CMD_PARAMS_END
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen};
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenvoid doveadm_acl_plugin_init(struct module *module ATTR_UNUSED)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen unsigned int i;
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen for (i = 0; i < N_ELEMENTS(acl_commands); i++)
57a2881cb841fdfeb0631f8065070bbc547d4618Aki Tuomi doveadm_cmd_register_ver2(&acl_commands[i]);
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainenvoid doveadm_acl_plugin_deinit(void)
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen{
7d8afd1e15bdf23b5fd13aa9ac9606aca2797125Timo Sirainen}