dovecot-2.0: doveadm acl set: Require non-standard rights to be ...

dovecot at dovecot.org dovecot at dovecot.org
Fri Mar 4 21:22:17 EET 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/d757b13d84ff
changeset: 12657:d757b13d84ff
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Mar 04 21:21:37 2011 +0200
description:
doveadm acl set: Require non-standard rights to be prefixed with ':' char.

diffstat:

 src/plugins/acl/doveadm-acl.c |  25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diffs (42 lines):

diff -r 81d799f52912 -r d757b13d84ff src/plugins/acl/doveadm-acl.c
--- a/src/plugins/acl/doveadm-acl.c	Fri Mar 04 20:59:31 2011 +0200
+++ b/src/plugins/acl/doveadm-acl.c	Fri Mar 04 21:21:37 2011 +0200
@@ -220,6 +220,17 @@
 	return ctx;
 }
 
+static bool is_standard_right(const char *name)
+{
+	unsigned int i;
+
+	for (i = 0; all_mailbox_rights[i] != NULL; i++) {
+		if (strcmp(all_mailbox_rights[i], name) == 0)
+			return TRUE;
+	}
+	return FALSE;
+}
+
 static void
 cmd_acl_set_run(struct doveadm_mail_cmd_context *ctx, struct mail_user *user)
 {
@@ -252,9 +263,17 @@
 			right++;
 			dest = &dest_neg_rights;
 		}
-		if (strcmp(right, "all") != 0)
-			array_append(dest, &right, 1);
-		else {
+		if (strcmp(right, "all") != 0) {
+			if (*right == ':') {
+				/* non-standard right */
+				right++;
+				array_append(dest, &right, 1);
+			} else if (is_standard_right(right)) {
+				array_append(dest, &right, 1);
+			} else {
+				i_fatal("Invalid right '%s'", right);
+			}
+		} else {
 			for (j = 0; all_mailbox_rights[j] != NULL; j++)
 				array_append(dest, &all_mailbox_rights[j], 1);
 		}


More information about the dovecot-cvs mailing list