Skip to content

Commit 23a85ba

Browse files
authored
Merge pull request redis#7276 from hujiecs/fix-clear-all-command-flag-in-acl
fix clear USER_FLAG_ALLCOMMANDS flag in acl
2 parents d949e8f + edc1f7b commit 23a85ba

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/acl.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,13 @@ int ACLUserCanExecuteFutureCommands(user *u) {
375375
* to skip the command bit explicit test. */
376376
void ACLSetUserCommandBit(user *u, unsigned long id, int value) {
377377
uint64_t word, bit;
378-
if (value == 0) u->flags &= ~USER_FLAG_ALLCOMMANDS;
379378
if (ACLGetCommandBitCoordinates(id,&word,&bit) == C_ERR) return;
380-
if (value)
379+
if (value) {
381380
u->allowed_commands[word] |= bit;
382-
else
381+
} else {
383382
u->allowed_commands[word] &= ~bit;
383+
u->flags &= ~USER_FLAG_ALLCOMMANDS;
384+
}
384385
}
385386

386387
/* This is like ACLSetUserCommandBit(), but instead of setting the specified
@@ -845,7 +846,6 @@ int ACLSetUser(user *u, const char *op, ssize_t oplen) {
845846
errno = ENOENT;
846847
return C_ERR;
847848
}
848-
unsigned long id = ACLGetCommandID(copy);
849849

850850
/* The subcommand cannot be empty, so things like DEBUG|
851851
* are syntax errors of course. */
@@ -858,6 +858,7 @@ int ACLSetUser(user *u, const char *op, ssize_t oplen) {
858858
/* The command should not be set right now in the command
859859
* bitmap, because adding a subcommand of a fully added
860860
* command is probably an error on the user side. */
861+
unsigned long id = ACLGetCommandID(copy);
861862
if (ACLGetUserCommandBit(u,id) == 1) {
862863
zfree(copy);
863864
errno = EBUSY;

0 commit comments

Comments
 (0)