@@ -375,12 +375,13 @@ int ACLUserCanExecuteFutureCommands(user *u) {
375
375
* to skip the command bit explicit test. */
376
376
void ACLSetUserCommandBit (user * u , unsigned long id , int value ) {
377
377
uint64_t word , bit ;
378
- if (value == 0 ) u -> flags &= ~USER_FLAG_ALLCOMMANDS ;
379
378
if (ACLGetCommandBitCoordinates (id ,& word ,& bit ) == C_ERR ) return ;
380
- if (value )
379
+ if (value ) {
381
380
u -> allowed_commands [word ] |= bit ;
382
- else
381
+ } else {
383
382
u -> allowed_commands [word ] &= ~bit ;
383
+ u -> flags &= ~USER_FLAG_ALLCOMMANDS ;
384
+ }
384
385
}
385
386
386
387
/* This is like ACLSetUserCommandBit(), but instead of setting the specified
@@ -845,7 +846,6 @@ int ACLSetUser(user *u, const char *op, ssize_t oplen) {
845
846
errno = ENOENT ;
846
847
return C_ERR ;
847
848
}
848
- unsigned long id = ACLGetCommandID (copy );
849
849
850
850
/* The subcommand cannot be empty, so things like DEBUG|
851
851
* are syntax errors of course. */
@@ -858,6 +858,7 @@ int ACLSetUser(user *u, const char *op, ssize_t oplen) {
858
858
/* The command should not be set right now in the command
859
859
* bitmap, because adding a subcommand of a fully added
860
860
* command is probably an error on the user side. */
861
+ unsigned long id = ACLGetCommandID (copy );
861
862
if (ACLGetUserCommandBit (u ,id ) == 1 ) {
862
863
zfree (copy );
863
864
errno = EBUSY ;
0 commit comments