summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2019-01-16 13:50:00 +0100
committerantirez <antirez@gmail.com>2019-01-16 13:50:00 +0100
commitdbae371090780b81ccecfc0d24aa46715b873f36 (patch)
tree9e09ac1011621b8b956289d2ed0641f4fc6b868a
parentf78b3ede2735397704fd452619efcbdac37254f6 (diff)
downloadredis-dbae371090780b81ccecfc0d24aa46715b873f36.tar.gz
ACL: create the user pattern list ASAP.
-rw-r--r--src/acl.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/acl.c b/src/acl.c
index edc75de6d..c656b3f62 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -107,11 +107,9 @@ user *ACLCreateUser(const char *name, size_t namelen) {
u->flags = 0;
u->allowed_subcommands = NULL;
u->passwords = listCreate();
+ u->patterns = listCreate();
listSetMatchMethod(u->passwords,ACLListMatchSds);
- u->patterns = NULL; /* Just created users cannot access to any key, however
- if the "~*" directive was enabled to match all the
- keys, the user will be flagged with the ALLKEYS
- flag. */
+ listSetMatchMethod(u->patterns,ACLListMatchSds);
memset(u->allowed_commands,0,sizeof(u->allowed_commands));
raxInsert(Users,(unsigned char*)name,namelen,u,NULL);
return u;
@@ -338,7 +336,7 @@ int ACLCheckCommandPerm(client *c) {
listRewind(u->passwords,&li);
/* Test this key against every pattern. */
- match = 0;
+ int match = 0;
while((ln = listNext(&li))) {
sds pattern = listNodeValue(ln);
size_t plen = sdslen(pattern);