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
7b4f3cc3
Commit
7b4f3cc3
authored
Jan 24, 2019
by
antirez
Browse files
ACL: + and - opcode for categories implemented.
parent
e8bf9b03
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/acl.c
View file @
7b4f3cc3
...
@@ -299,8 +299,8 @@ void ACLResetSubcommandsForCommand(user *u, unsigned long id) {
...
@@ -299,8 +299,8 @@ void ACLResetSubcommandsForCommand(user *u, unsigned long id) {
* When an error is returned, errno is set to the following values:
* When an error is returned, errno is set to the following values:
*
*
* EINVAL: The specified opcode is not understood.
* EINVAL: The specified opcode is not understood.
* ENOENT: The command name provided with + or - is not
known.
* ENOENT: The command name
or command category
provided with + or - is not
*/
* known.
*/
int
ACLSetUser
(
user
*
u
,
const
char
*
op
,
ssize_t
oplen
)
{
int
ACLSetUser
(
user
*
u
,
const
char
*
op
,
ssize_t
oplen
)
{
if
(
oplen
==
-
1
)
oplen
=
strlen
(
op
);
if
(
oplen
==
-
1
)
oplen
=
strlen
(
op
);
if
(
!
strcasecmp
(
op
,
"on"
))
{
if
(
!
strcasecmp
(
op
,
"on"
))
{
...
@@ -414,6 +414,12 @@ int ACLSetUser(user *u, const char *op, ssize_t oplen) {
...
@@ -414,6 +414,12 @@ int ACLSetUser(user *u, const char *op, ssize_t oplen) {
ACLSetUserCommandBit
(
u
,
id
,
0
);
ACLSetUserCommandBit
(
u
,
id
,
0
);
u
->
flags
&=
~
USER_FLAG_ALLCOMMANDS
;
u
->
flags
&=
~
USER_FLAG_ALLCOMMANDS
;
ACLResetSubcommandsForCommand
(
u
,
id
);
ACLResetSubcommandsForCommand
(
u
,
id
);
}
else
if
((
op
[
0
]
==
'+'
||
op
[
0
]
==
'-'
)
&&
op
[
1
]
==
'@'
)
{
int
bitval
=
op
[
0
]
==
'+'
?
1
:
0
;
if
(
ACLSetUserCommandBitsForCategory
(
u
,
op
+
2
,
bitval
)
==
C_ERR
)
{
errno
=
ENOENT
;
return
C_ERR
;
}
}
else
if
(
!
strcasecmp
(
op
,
"reset"
))
{
}
else
if
(
!
strcasecmp
(
op
,
"reset"
))
{
serverAssert
(
ACLSetUser
(
u
,
"resetpass"
,
-
1
)
==
C_OK
);
serverAssert
(
ACLSetUser
(
u
,
"resetpass"
,
-
1
)
==
C_OK
);
serverAssert
(
ACLSetUser
(
u
,
"resetkeys"
,
-
1
)
==
C_OK
);
serverAssert
(
ACLSetUser
(
u
,
"resetkeys"
,
-
1
)
==
C_OK
);
...
@@ -620,8 +626,10 @@ void aclCommand(client *c) {
...
@@ -620,8 +626,10 @@ void aclCommand(client *c) {
for
(
int
j
=
3
;
j
<
c
->
argc
;
j
++
)
{
for
(
int
j
=
3
;
j
<
c
->
argc
;
j
++
)
{
if
(
ACLSetUser
(
u
,
c
->
argv
[
j
]
->
ptr
,
sdslen
(
c
->
argv
[
j
]
->
ptr
))
!=
C_OK
)
{
if
(
ACLSetUser
(
u
,
c
->
argv
[
j
]
->
ptr
,
sdslen
(
c
->
argv
[
j
]
->
ptr
))
!=
C_OK
)
{
char
*
errmsg
=
"wrong format"
;
char
*
errmsg
=
"wrong format"
;
if
(
errno
==
ENOENT
)
errmsg
=
"unknown command name in ACL"
;
if
(
errno
==
ENOENT
)
if
(
errno
==
EINVAL
)
errmsg
=
"syntax error"
;
errmsg
=
"unknown command or category name in ACL"
;
else
if
(
errno
==
EINVAL
)
errmsg
=
"syntax error"
;
addReplyErrorFormat
(
c
,
addReplyErrorFormat
(
c
,
"Error in ACL SETUSER modifier '%s': %s"
,
"Error in ACL SETUSER modifier '%s': %s"
,
(
char
*
)
c
->
argv
[
j
]
->
ptr
,
errmsg
);
(
char
*
)
c
->
argv
[
j
]
->
ptr
,
errmsg
);
...
...
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