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
db307275
Commit
db307275
authored
Feb 07, 2019
by
antirez
Browse files
ACL: ACLLoadFromFile(): several errors fixed to make it work.
parent
d26c9b53
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/acl.c
View file @
db307275
...
@@ -1141,8 +1141,8 @@ sds ACLLoadFromFile(const char *filename) {
...
@@ -1141,8 +1141,8 @@ sds ACLLoadFromFile(const char *filename) {
argv
=
sdssplitargs
(
lines
[
i
],
&
argc
);
argv
=
sdssplitargs
(
lines
[
i
],
&
argc
);
if
(
argv
==
NULL
)
{
if
(
argv
==
NULL
)
{
errors
=
sdscatprintf
(
errors
,
errors
=
sdscatprintf
(
errors
,
"%d: unbalanced quotes in acl line. "
,
"%
s:%
d: unbalanced quotes in acl line. "
,
linenum
);
server
.
acl_filename
,
linenum
);
continue
;
continue
;
}
}
...
@@ -1155,8 +1155,8 @@ sds ACLLoadFromFile(const char *filename) {
...
@@ -1155,8 +1155,8 @@ sds ACLLoadFromFile(const char *filename) {
/* The line should start with the "user" keyword. */
/* The line should start with the "user" keyword. */
if
(
strcmp
(
argv
[
0
],
"user"
)
||
argc
<
2
)
{
if
(
strcmp
(
argv
[
0
],
"user"
)
||
argc
<
2
)
{
errors
=
sdscatprintf
(
errors
,
errors
=
sdscatprintf
(
errors
,
"%
d: line
should start with user keyword followed "
"%
s:%d
should start with user keyword followed "
"by the username. "
,
"by the username. "
,
server
.
acl_filename
,
linenum
);
linenum
);
sdsfreesplitres
(
argv
,
argc
);
sdsfreesplitres
(
argv
,
argc
);
continue
;
continue
;
...
@@ -1170,14 +1170,18 @@ sds ACLLoadFromFile(const char *filename) {
...
@@ -1170,14 +1170,18 @@ sds ACLLoadFromFile(const char *filename) {
if
(
ACLSetUser
(
fakeuser
,
argv
[
j
],
sdslen
(
argv
[
j
]))
!=
C_OK
)
{
if
(
ACLSetUser
(
fakeuser
,
argv
[
j
],
sdslen
(
argv
[
j
]))
!=
C_OK
)
{
char
*
errmsg
=
ACLSetUserStringError
();
char
*
errmsg
=
ACLSetUserStringError
();
errors
=
sdscatprintf
(
errors
,
errors
=
sdscatprintf
(
errors
,
"%
d: error in ACL
: %s. "
,
"%
s:%d
: %s. "
,
linenum
,
errmsg
);
server
.
acl_filename
,
linenum
,
errmsg
);
continue
;
continue
;
}
}
}
}
if
(
j
!=
argc
)
{
/* Apply the rule to the new users set only if so far there
* are no errors, otherwise it's useless since we are going
* to discard the new users set anyway. */
if
(
sdslen
(
errors
)
!=
0
)
{
sdsfreesplitres
(
argv
,
argc
);
sdsfreesplitres
(
argv
,
argc
);
continue
;
/* Error in ACL rules, don't apply. */
continue
;
}
}
/* We can finally lookup the user and apply the rule. If the
/* We can finally lookup the user and apply the rule. If the
...
@@ -1192,7 +1196,7 @@ sds ACLLoadFromFile(const char *filename) {
...
@@ -1192,7 +1196,7 @@ sds ACLLoadFromFile(const char *filename) {
/* Note that the same rules already applied to the fake user, so
/* Note that the same rules already applied to the fake user, so
* we just assert that everything goess well: it should. */
* we just assert that everything goess well: it should. */
for
(
j
=
2
;
j
<
argc
;
j
++
)
for
(
j
=
2
;
j
<
argc
;
j
++
)
serverAssert
(
ACLSetUser
(
fakeuser
,
argv
[
j
],
sdslen
(
argv
[
j
]))
==
C_OK
);
serverAssert
(
ACLSetUser
(
u
,
argv
[
j
],
sdslen
(
argv
[
j
]))
==
C_OK
);
sdsfreesplitres
(
argv
,
argc
);
sdsfreesplitres
(
argv
,
argc
);
}
}
...
...
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