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
f78b3ede
Commit
f78b3ede
authored
Jan 16, 2019
by
antirez
Browse files
ACL: key matching implemented.
parent
0db42d4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/acl.c
View file @
f78b3ede
...
...
@@ -330,6 +330,29 @@ int ACLCheckCommandPerm(client *c) {
if
(
!
(
c
->
user
->
flags
&
USER_FLAG_ALLKEYS
)
&&
(
c
->
cmd
->
getkeys_proc
||
c
->
cmd
->
firstkey
))
{
int
numkeys
;
int
*
keyidx
=
getKeysFromCommand
(
c
->
cmd
,
c
->
argv
,
c
->
argc
,
&
numkeys
);
for
(
int
j
=
0
;
j
<
numkeys
;
j
++
)
{
listIter
li
;
listNode
*
ln
;
listRewind
(
u
->
passwords
,
&
li
);
/* Test this key against every pattern. */
match
=
0
;
while
((
ln
=
listNext
(
&
li
)))
{
sds
pattern
=
listNodeValue
(
ln
);
size_t
plen
=
sdslen
(
pattern
);
int
idx
=
keyidx
[
j
];
if
(
stringmatchlen
(
pattern
,
plen
,
c
->
argv
[
idx
]
->
ptr
,
sdslen
(
c
->
argv
[
idx
]
->
ptr
),
0
))
{
match
=
1
;
break
;
}
}
if
(
!
match
)
return
C_ERR
;
}
getKeysFreeResult
(
keyidx
);
}
/* If we survived all the above checks, the user can execute the
...
...
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