changeset 12775:5dea44b3d133

doveadm: Added acl delete command.
author Timo Sirainen <tss@iki.fi>
date Fri, 04 Mar 2011 17:56:11 +0200
parents cb393d8a1fd7
children 6b0f4dc0fac6
files src/plugins/acl/doveadm-acl.c
diffstat 1 files changed, 43 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/acl/doveadm-acl.c	Fri Mar 04 17:51:46 2011 +0200
+++ b/src/plugins/acl/doveadm-acl.c	Fri Mar 04 17:56:11 2011 +0200
@@ -290,6 +290,48 @@
 	return ctx;
 }
 
+static void
+cmd_acl_delete_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user)
+{
+	const char *mailbox = ctx->args[0], *id = ctx->args[1];
+	struct mailbox *box;
+	struct acl_object *aclobj;
+	struct acl_rights_update update;
+
+	if (cmd_acl_mailbox_open(user, mailbox, &box) < 0)
+		return;
+
+	memset(&update, 0, sizeof(update));
+	update.modify_mode = ACL_MODIFY_MODE_CLEAR;
+	update.neg_modify_mode = ACL_MODIFY_MODE_CLEAR;
+
+	if (acl_identifier_parse(id, &update.rights) < 0)
+		i_fatal("Invalid ID: %s", id);
+
+	aclobj = acl_mailbox_get_aclobj(box);
+	if (acl_object_update(aclobj, &update) < 0)
+		i_error("Failed to set ACL");
+	mailbox_free(&box);
+}
+
+static void cmd_acl_delete_init(struct doveadm_mail_cmd_context *ctx ATTR_UNUSED,
+				const char *const args[])
+{
+	if (str_array_length(args) < 2)
+		doveadm_mail_help_name("acl delete");
+}
+
+static struct doveadm_mail_cmd_context *
+cmd_acl_delete_alloc(void)
+{
+	struct doveadm_mail_cmd_context *ctx;
+
+	ctx = doveadm_mail_cmd_alloc(struct doveadm_mail_cmd_context);
+	ctx->v.run = cmd_acl_delete_run;
+	ctx->v.init = cmd_acl_delete_init;
+	return ctx;
+}
+
 static bool cmd_acl_debug_mailbox(struct mailbox *box)
 {
 	struct mail_namespace *ns = mailbox_get_namespace(box);
@@ -413,6 +455,7 @@
 	{ cmd_acl_get_alloc, "acl get", "[-m] <mailbox>" },
 	{ cmd_acl_rights_alloc, "acl rights", "<mailbox>" },
 	{ cmd_acl_set_alloc, "acl set", "<mailbox> <id> <rights>" },
+	{ cmd_acl_delete_alloc, "acl delete", "<mailbox> <id>" },
 	{ cmd_acl_debug_alloc, "acl debug", "<mailbox>" }
 };