[svn-commits] eliel: branch eliel/cli-permissions r159086 - /team/eliel/cli-permissions/main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Nov 25 07:08:03 CST 2008


Author: eliel
Date: Tue Nov 25 07:08:03 2008
New Revision: 159086

URL: http://svn.digium.com/view/asterisk?view=rev&rev=159086
Log:
Allow the possibility to set the permit or deny string as a regular expression like:
permit=channel originate SIP/[0-9]* extension *


Modified:
    team/eliel/cli-permissions/main/cli.c

Modified: team/eliel/cli-permissions/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/eliel/cli-permissions/main/cli.c?view=diff&rev=159086&r1=159085&r2=159086
==============================================================================
--- team/eliel/cli-permissions/main/cli.c (original)
+++ team/eliel/cli-permissions/main/cli.c Tue Nov 25 07:08:03 2008
@@ -167,7 +167,8 @@
 	struct usergroup_cli_perm *user_perm;
 	struct cli_perm *perm;
 	/* set to the default permissions general option. */
-	int isallowg = cli_default_perm, isallowu = -1;
+	int isallowg = cli_default_perm, isallowu = -1, ispattern;
+	regex_t regexbuf;
 
 	/* if uid == -1 or gid == -1 do not check permissions.
 	   if uid == -2 and gid == -2 is because rasterisk client didn't send
@@ -187,7 +188,16 @@
 		}
 		AST_LIST_TRAVERSE(user_perm->perms, perm, list) {
 			if (strcasecmp(perm->command, "all") && strncasecmp(perm->command, command, strlen(perm->command))) {
-				continue;
+				/* if the perm->command is a pattern, check it against command. */
+				ispattern = !regcomp(&regexbuf, perm->command, REG_EXTENDED | REG_NOSUB);
+				if (ispattern && regexec(&regexbuf, command, 0, NULL, 0)) {
+					regfree(&regexbuf);
+					continue;
+				}
+				if (!ispattern) {
+					continue;
+				}
+				regfree(&regexbuf);
 			}
 			if (user_perm->uid == uid) {
 				/* this is a user definition. */




More information about the svn-commits mailing list