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
72e8a080
Commit
72e8a080
authored
Feb 07, 2019
by
antirez
Browse files
ACL: fix and complete ACLLoadFromFile() loading step.
parent
bbdf0233
Changes
1
Show whitespace changes
Inline
Side-by-side
src/acl.c
View file @
72e8a080
...
...
@@ -1095,10 +1095,12 @@ sds ACLLoadFromFile(const char *filename) {
}
/* The line should start with the "user" keyword. */
if
(
strcmp
(
argv
[
0
],
"user"
))
{
if (strcmp(argv[0],"user")
|| argc < 2
) {
errors = sdscatprintf(errors,
"%d: line should start with user keyword. "
,
"%d: line should start with user keyword followed "
"by the username. ",
linenum);
sdsfreesplitres(argv,argc);
continue;
}
...
...
@@ -1115,9 +1117,26 @@ sds ACLLoadFromFile(const char *filename) {
continue;
}
}
if
(
j
!=
argc
)
continue
;
/* Error in ACL rules, don't apply. */
if (j != argc) {
sdsfreesplitres(argv,argc);
continue; /* Error in ACL rules, don't apply. */
}
/* We can finally lookup the user and apply the rule. If the
* user already exists we always reset it to start. */
user *u = ACLCreateUser(argv[1],sdslen(argv[1]));
if (!u) {
u = ACLGetUserByName(argv[1],sdslen(argv[1]));
serverAssert(u != NULL);
ACLSetUser(u,"reset",-1);
}
/* We can finally lookup the user and apply the rule. */
/* Note that the same rules already applied to the fake user, so
* we just assert that everything goess well: it should. */
for (j = 2; j < argc; j++)
serverAssert(ACLSetUser(fakeuser,argv[j],sdslen(argv[j]) == C_OK);
sdsfreesplitres(argv,argc);
}
ACLFreeUser(fakeuser);
...
...
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