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
b166c41e
Commit
b166c41e
authored
Feb 04, 2019
by
antirez
Browse files
ACL: make ACLAppendUserForLoading() able to report bad argument.
parent
21e84cda
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/acl.c
View file @
b166c41e
...
...
@@ -931,9 +931,16 @@ int ACLCheckCommandPerm(client *c) {
*
* Note that this function cannot stop in case of commands that are not found
* 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
;
* commands may be defined later once modules are loaded.
*
* When an error is detected and C_ERR is returned, the function populates
* by reference (if not set to NULL) the argc_err argument with the index
* of the argv vector that caused the error. */
int
ACLAppendUserForLoading
(
sds
*
argv
,
int
argc
,
int
*
argc_err
)
{
if
(
argc
<
2
||
strcasecmp
(
argv
[
0
],
"user"
))
{
if
(
argc_err
)
*
argc_err
=
0
;
return
C_ERR
;
}
/* Try to apply the user rules in a fake user to see if they
* are actually valid. */
...
...
@@ -947,6 +954,7 @@ int ACLAppendUserForLoading(sds *argv, int argc) {
if
(
ACLSetUser
(
fakeuser
,
argv
[
j
],
sdslen
(
argv
[
j
]))
==
C_ERR
)
{
if
(
errno
!=
ENOENT
)
{
ACLFreeUser
(
fakeuser
);
if
(
argc_err
)
*
argc_err
=
j
;
return
C_ERR
;
}
}
...
...
src/config.c
View file @
b166c41e
...
...
@@ -792,7 +792,8 @@ void loadServerConfigFromString(char *config) {
goto
loaderr
;
}
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"user"
)
&&
argc
>=
2
)
{
if
(
ACLAppendUserForLoading
(
argv
,
argc
)
==
C_ERR
)
{
int
argc_err
;
if
(
ACLAppendUserForLoading
(
argv
,
argc
,
&
argc_err
)
==
C_ERR
)
{
err
=
"Syntax error in user declaration"
;
goto
loaderr
;
}
...
...
src/server.h
View file @
b166c41e
...
...
@@ -1738,7 +1738,7 @@ int ACLCheckCommandPerm(client *c);
int
ACLSetUser
(
user
*
u
,
const
char
*
op
,
ssize_t
oplen
);
sds
ACLDefaultUserFirstPassword
(
void
);
uint64_t
ACLGetCommandCategoryFlagByName
(
const
char
*
name
);
int
ACLAppendUserForLoading
(
sds
*
argv
,
int
argc
);
int
ACLAppendUserForLoading
(
sds
*
argv
,
int
argc
,
int
*
argc_err
);
/* Sorted sets data type */
...
...
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