mirror of
https://github.com/fluencelabs/redis
synced 2025-04-01 23:31:03 +00:00
ACL: reset the subcommands table on +@all / -@all.
This also is a bugfix because after -@all the previously enabled subcommands would remain valid.
This commit is contained in:
parent
097d57f56e
commit
7fb9e2b4ce
13
src/acl.c
13
src/acl.c
@ -248,6 +248,17 @@ void ACLResetSubcommandsForCommand(user *u, unsigned long id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Flush the entire table of subcommands. This is useful on +@all, -@all
|
||||||
|
* or similar to return back to the minimal memory usage (and checks to do)
|
||||||
|
* for the user. */
|
||||||
|
void ACLResetSubcommands(user *u) {
|
||||||
|
if (u->allowed_subcommands == NULL) return;
|
||||||
|
for (int j = 0; j < USER_COMMAND_BITS_COUNT; j++)
|
||||||
|
if (u->allowed_subcommands[j]) zfree(u->allowed_subcommands[j]);
|
||||||
|
zfree(u->allowed_subcommands);
|
||||||
|
u->allowed_subcommands = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set user properties according to the string "op". The following
|
/* Set user properties according to the string "op". The following
|
||||||
* is a description of what different strings will do:
|
* is a description of what different strings will do:
|
||||||
*
|
*
|
||||||
@ -330,11 +341,13 @@ int ACLSetUser(user *u, const char *op, ssize_t oplen) {
|
|||||||
{
|
{
|
||||||
memset(u->allowed_commands,255,sizeof(u->allowed_commands));
|
memset(u->allowed_commands,255,sizeof(u->allowed_commands));
|
||||||
u->flags |= USER_FLAG_ALLCOMMANDS;
|
u->flags |= USER_FLAG_ALLCOMMANDS;
|
||||||
|
ACLResetSubcommands(u);
|
||||||
} else if (!strcasecmp(op,"nocommands") ||
|
} else if (!strcasecmp(op,"nocommands") ||
|
||||||
!strcasecmp(op,"-@all"))
|
!strcasecmp(op,"-@all"))
|
||||||
{
|
{
|
||||||
memset(u->allowed_commands,0,sizeof(u->allowed_commands));
|
memset(u->allowed_commands,0,sizeof(u->allowed_commands));
|
||||||
u->flags &= ~USER_FLAG_ALLCOMMANDS;
|
u->flags &= ~USER_FLAG_ALLCOMMANDS;
|
||||||
|
ACLResetSubcommands(u);
|
||||||
} else if (!strcasecmp(op,"nopass")) {
|
} else if (!strcasecmp(op,"nopass")) {
|
||||||
u->flags |= USER_FLAG_NOPASS;
|
u->flags |= USER_FLAG_NOPASS;
|
||||||
listEmpty(u->passwords);
|
listEmpty(u->passwords);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user