Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
e8bf9b03
You need to sign in or sign up before continuing.
Commit
e8bf9b03
authored
Jan 24, 2019
by
antirez
Browse files
ACL: ACLSetUserCommandBitsForCategory() low level API.
parent
f99e0f59
Changes
1
Show whitespace changes
Inline
Side-by-side
src/acl.c
View file @
e8bf9b03
...
...
@@ -199,6 +199,25 @@ void ACLSetUserCommandBit(user *u, unsigned long id, int value) {
u
->
allowed_commands
[
word
]
&=
~
bit
;
}
/* This is like ACLSetUserCommandBit(), but instead of setting the specified
* ID, it will check all the commands in the category specified as argument,
* and will set all the bits corresponding to such commands to the specified
* value. Since the category passed by the user may be non existing, the
* function returns C_ERR if the category was not found, or C_OK if it was
* found and the operation was performed. */
int
ACLSetUserCommandBitsForCategory
(
user
*
u
,
const
char
*
category
,
int
value
)
{
uint64_t
cflag
=
ACLGetCommandCategoryFlagByName
(
category
);
if
(
!
cflag
)
return
C_ERR
;
dictIterator
*
di
=
dictGetIterator
(
server
.
orig_commands
);
dictEntry
*
de
;
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
struct
redisCommand
*
cmd
=
dictGetVal
(
de
);
if
(
cmd
->
flags
&
cflag
)
ACLSetUserCommandBit
(
u
,
cmd
->
id
,
value
);
}
dictReleaseIterator
(
di
);
return
C_OK
;
}
/* Get a command from the original command table, that is not affected
* by the command renaming operations: we base all the ACL work from that
* table, so that ACLs are valid regardless of command renaming. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment