ACL: create the user pattern list ASAP.
This commit is contained in:
parent
cd486b983b
commit
edada0e438
@ -107,11 +107,9 @@ user *ACLCreateUser(const char *name, size_t namelen) {
|
|||||||
u->flags = 0;
|
u->flags = 0;
|
||||||
u->allowed_subcommands = NULL;
|
u->allowed_subcommands = NULL;
|
||||||
u->passwords = listCreate();
|
u->passwords = listCreate();
|
||||||
|
u->patterns = listCreate();
|
||||||
listSetMatchMethod(u->passwords,ACLListMatchSds);
|
listSetMatchMethod(u->passwords,ACLListMatchSds);
|
||||||
u->patterns = NULL; /* Just created users cannot access to any key, however
|
listSetMatchMethod(u->patterns,ACLListMatchSds);
|
||||||
if the "~*" directive was enabled to match all the
|
|
||||||
keys, the user will be flagged with the ALLKEYS
|
|
||||||
flag. */
|
|
||||||
memset(u->allowed_commands,0,sizeof(u->allowed_commands));
|
memset(u->allowed_commands,0,sizeof(u->allowed_commands));
|
||||||
raxInsert(Users,(unsigned char*)name,namelen,u,NULL);
|
raxInsert(Users,(unsigned char*)name,namelen,u,NULL);
|
||||||
return u;
|
return u;
|
||||||
@ -338,7 +336,7 @@ int ACLCheckCommandPerm(client *c) {
|
|||||||
listRewind(u->passwords,&li);
|
listRewind(u->passwords,&li);
|
||||||
|
|
||||||
/* Test this key against every pattern. */
|
/* Test this key against every pattern. */
|
||||||
match = 0;
|
int match = 0;
|
||||||
while((ln = listNext(&li))) {
|
while((ln = listNext(&li))) {
|
||||||
sds pattern = listNodeValue(ln);
|
sds pattern = listNodeValue(ln);
|
||||||
size_t plen = sdslen(pattern);
|
size_t plen = sdslen(pattern);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user