From: Timo Sirainen Date: Mon, 14 Jan 2013 11:01:33 +0000 (+0200) Subject: doveadm acl: Added "recalc" command to rebuild acl_lookup_dict for the user. X-Git-Tag: 2.1.14~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6aaa31ebed57cbb3a44fa5b0b21e7dee0470fba;p=thirdparty%2Fdovecot%2Fcore.git doveadm acl: Added "recalc" command to rebuild acl_lookup_dict for the user. --- diff --git a/src/plugins/acl/doveadm-acl.c b/src/plugins/acl/doveadm-acl.c index 8c0e62e2f1..e37dac10ec 100644 --- a/src/plugins/acl/doveadm-acl.c +++ b/src/plugins/acl/doveadm-acl.c @@ -398,6 +398,34 @@ cmd_acl_delete_alloc(void) return ctx; } +static int +cmd_acl_recalc_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user) +{ + struct acl_user *auser = ACL_USER_CONTEXT(user); + + if (auser == NULL) { + i_error("ACL not enabled for %s", user->username); + doveadm_mail_failed_error(ctx, MAIL_ERROR_NOTFOUND); + return -1; + } + if (acl_lookup_dict_rebuild(auser->acl_lookup_dict) < 0) { + i_error("Failed to recalculate ACL dicts"); + doveadm_mail_failed_error(ctx, MAIL_ERROR_TEMP); + return -1; + } + return 0; +} + +static struct doveadm_mail_cmd_context * +cmd_acl_recalc_alloc(void) +{ + struct doveadm_mail_cmd_context *ctx; + + ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context); + ctx->v.run = cmd_acl_recalc_run; + return ctx; +} + static int cmd_acl_debug_mailbox_open(struct doveadm_mail_cmd_context *ctx, struct mail_user *user, const char *mailbox, @@ -591,6 +619,7 @@ static struct doveadm_mail_cmd acl_commands[] = { { cmd_acl_add_alloc, "acl add", " [ ...]" }, { cmd_acl_remove_alloc, "acl remove", " [ ...]" }, { cmd_acl_delete_alloc, "acl delete", " " }, + { cmd_acl_recalc_alloc, "acl recalc", "" }, { cmd_acl_debug_alloc, "acl debug", "" } };