Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
e7d15e48
Commit
e7d15e48
authored
Jan 11, 2019
by
antirez
Browse files
ACL: implement to first trivial opcodes in ACLSetUser().
parent
aced0328
Changes
1
Show whitespace changes
Inline
Side-by-side
src/acl.c
View file @
e7d15e48
...
...
@@ -127,15 +127,38 @@ user *ACLCreateUser(const char *name, size_t namelen) {
* disabled command. Note that this form is not
* allowed as negative like -DEBUG|SEGFAULT, but
* only additive starting with "+".
* ~<pattern>
Set
a pattern of keys that can be mentioned as part of
* ~<pattern>
Add
a pattern of keys that can be mentioned as part of
* commands. For instance ~* allows all the keys. The pattern
* is a glob-style pattern like the one of KEYS.
* It is possible to specify multiple patterns.
* ><password> Add this passowrd to the list of valid password for the user.
* For example >mypass will add "mypass" to the list.
* <<password> Remove this password from the list of valid passwords.
* allkeys Alias for ~*
* resetpass Flush the list of allowed passwords.
* resetkeys Flush the list of allowed keys patterns.
* reset Performs the following actions: resetpass, resetkeys, off,
* -@all. The user returns to the same state it has immediately
* after its creation.
*
* The function returns C_OK if the action to perform was understood because
* the 'op' string made sense. Otherwise C_ERR is returned if the operation
* is unknown or has some syntax error.
*/
void
ACLSetUser
(
user
*
u
,
const
char
*
op
)
{
int
ACLSetUser
(
user
*
u
,
const
char
*
op
)
{
if
(
!
strcasecmp
(
op
,
"on"
))
{
u
->
flags
|=
USER_FLAG_ENABLED
;
}
else
if
(
!
strcasecmp
(
op
,
"off"
))
{
u
->
flags
&=
~
USER_FLAG_ENABLED
;
}
else
if
(
!
strcasecmp
(
op
,
"allkeys"
)
||
!
strcasecmp
(
op
,
"~*"
))
{
memset
(
u
->
allowed_subcommands
,
255
,
sizeof
(
u
->
allowed_commands
));
u
->
flags
|=
USER_FLAG_ALLKEYS
;
}
else
{
return
C_ERR
;
}
return
C_OK
;
}
/* Initialization of the ACL subsystem. */
...
...
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