[svn-commits] mjordan: trunk r381949 - in /trunk: ./ main/manager.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Feb 24 10:27:50 CST 2013


Author: mjordan
Date: Sun Feb 24 10:27:47 2013
New Revision: 381949

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=381949
Log:
Don't display the AMI ALL class authorization for users if they don't have it

When converting AMI class authorizations to a string representation, the
method always appends the ALL class authorization. This is especially
important for events, as they should always communicate that class
authorization - even if the event itself does not specify ALL as a class
authorization for itself. (Events have always assumed that the ALL class
authorization is implied when they are raised)

Unfortunately, this did mean that specifying a user with restricted class
authorizations would show up in the 'manager show user' CLI command as
having the ALL class authorization.

Rather then modifying the existing string manipulation function, this patch
adds a function that will only return a string if the field being compared
explicitly matches class authorization field it is being compared against.
This prevents ALL from being returned unless it is actually specified for
the user.

(closes issue ASTERISK-20397)
Reported by: Johan Wilfer
........

Merged revisions 381939 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 381943 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/main/manager.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager.c?view=diff&rev=381949&r1=381948&r2=381949
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Sun Feb 24 10:27:47 2013
@@ -1357,7 +1357,30 @@
 	return 1;
 }
 
-/*! \brief Convert authority code to a list of options */
+/*! \brief Convert authority code to a list of options for a user. This will only
+ * display those authority codes that have an explicit match on authority */
+static const char *user_authority_to_str(int authority, struct ast_str **res)
+{
+	int i;
+	char *sep = "";
+
+	ast_str_reset(*res);
+	for (i = 0; i < ARRAY_LEN(perms) - 1; i++) {
+		if ((authority & perms[i].num) == perms[i].num) {
+			ast_str_append(res, 0, "%s%s", sep, perms[i].label);
+			sep = ",";
+		}
+	}
+
+	if (ast_str_strlen(*res) == 0)	/* replace empty string with something sensible */
+		ast_str_append(res, 0, "<none>");
+
+	return ast_str_buffer(*res);
+}
+
+
+/*! \brief Convert authority code to a list of options. Note that the EVENT_FLAG_ALL
+ * authority will always be returned. */
 static const char *authority_to_str(int authority, struct ast_str **res)
 {
 	int i;
@@ -1756,8 +1779,8 @@
 		(user->username ? user->username : "(N/A)"),
 		(user->secret ? "<Set>" : "(N/A)"),
 		((user->acl && !ast_acl_list_is_empty(user->acl)) ? "yes" : "no"),
-		authority_to_str(user->readperm, &rauthority),
-		authority_to_str(user->writeperm, &wauthority),
+		user_authority_to_str(user->readperm, &rauthority),
+		user_authority_to_str(user->writeperm, &wauthority),
 		(user->displayconnects ? "yes" : "no"));
 	ast_cli(a->fd, "      Variables: \n");
 		for (v = user->chanvars ; v ; v = v->next) {




More information about the svn-commits mailing list