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
8f16e1ea
Commit
8f16e1ea
authored
Feb 01, 2019
by
antirez
Browse files
ACL: implement ACLAppendUserForLoading().
parent
b8323d98
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/acl.c
View file @
8f16e1ea
...
...
@@ -933,6 +933,24 @@ int ACLCheckCommandPerm(client *c) {
* and, in that case, the error will be emitted later, because certain
* commands may be defined later once modules are loaded. */
int
ACLAppendUserForLoading
(
sds
*
argv
,
int
argc
)
{
if
(
argc
<
2
||
strcasecmp
(
argv
[
0
],
"user"
))
return
C_ERR
;
/* Try to apply the user rules in a fake user to see if they
* are actually valid. */
user
fu
=
{
0
};
user
*
fakeuser
=
&
fu
;
for
(
int
j
=
2
;
j
<
argc
;
j
++
)
{
if
(
ACLSetUser
(
fakeuser
,
argv
[
j
],
sdslen
(
argv
[
j
]))
==
C_ERR
)
{
if
(
errno
!=
ENOENT
)
return
C_ERR
;
}
}
/* Rules look valid, let's append the user to the list. */
sds
*
copy
=
zmalloc
(
sizeof
(
sds
)
*
argc
);
for
(
int
j
=
1
;
j
<
argc
;
j
++
)
copy
[
j
-
1
]
=
sdsdup
(
argv
[
j
]);
copy
[
argc
-
1
]
=
NULL
;
listAddNodeTail
(
UsersToLoad
,
copy
);
return
C_OK
;
}
/* =============================================================================
...
...
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