dovecot-2.0: doveadm: Added acl delete command.

dovecot at dovecot.org dovecot at dovecot.org
Fri Mar 4 17:56:15 EET 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/20b173d061d9
changeset: 12637:20b173d061d9
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Mar 04 17:56:11 2011 +0200
description:
doveadm: Added acl delete command.

diffstat:

 src/plugins/acl/doveadm-acl.c |  43 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diffs (60 lines):

diff -r 6c4f67202ebf -r 20b173d061d9 src/plugins/acl/doveadm-acl.c
--- 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
@@ -292,6 +292,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);
@@ -415,6 +457,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>" }
 };
 


More information about the dovecot-cvs mailing list