From 911fcaed790d31748651d7838feaa25b04abcfa2 Mon Sep 17 00:00:00 2001 From: Nicolas Favre-Felix Date: Sun, 6 Mar 2011 15:53:05 +0100 Subject: [PATCH] Added match-all pattern for ACLs --- README.markdown | 2 +- acl.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 749ce23..73cb9e2 100644 --- a/README.markdown +++ b/README.markdown @@ -98,7 +98,7 @@ Examples: "enabled": ["SET", "DEL"] } -ACLs are interpreted in order, later authorizations superseding earlier ones if a client matches several. +ACLs are interpreted in order, later authorizations superseding earlier ones if a client matches several. The special value "*" matches all commands. # JSON output JSON is the default output format. Each command returns a JSON object with the command as a key and the result as a value. diff --git a/acl.c b/acl.c index 34db0bf..a2242ae 100644 --- a/acl.c +++ b/acl.c @@ -67,6 +67,9 @@ acl_allow_command(struct cmd *cmd, struct conf *cfg, struct evhttp_request *rq) if(strncasecmp(a->enabled.commands[i], cmd_name, cmd_len) == 0) { authorized = 1; } + if(strncasecmp(a->enabled.commands[i], "*", 1) == 0) { + authorized = 1; + } } /* go through unauthorized commands */ @@ -74,6 +77,9 @@ acl_allow_command(struct cmd *cmd, struct conf *cfg, struct evhttp_request *rq) if(strncasecmp(a->disabled.commands[i], cmd_name, cmd_len) == 0) { authorized = 0; } + if(strncasecmp(a->disabled.commands[i], "*", 1) == 0) { + authorized = 0; + } } }