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
80f98772
Commit
80f98772
authored
Feb 07, 2019
by
antirez
Browse files
ACL: load ACL file at startup. Prevent silly configurations.
parent
db307275
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/acl.c
View file @
80f98772
...
...
@@ -1227,6 +1227,39 @@ sds ACLLoadFromFile(const char *filename) {
}
}
/* This function is called once the server is already running, modules are
* loaded, and we are ready to start, in order to load the ACLs either from
* the pending list of users defined in redis.conf, or from the ACL file.
* The function will just exit with an error if the user is trying to mix
* both the loading methods. */
void
ACLLoadUsersAtStartup
(
void
)
{
if
(
server
.
acl_filename
[
0
]
!=
'\0'
&&
listLength
(
UsersToLoad
)
!=
0
)
{
serverLog
(
LL_WARNING
,
"Configuring Redis with users defined in redis.conf and at "
"the same setting an ACL file path is invalid. This setup "
"is very likely to lead to configuration errors and security "
"holes, please define either an ACL file or declare users "
"directly in your redis.conf, but not both."
);
exit
(
1
);
}
if
(
ACLLoadConfiguredUsers
()
==
C_ERR
)
{
serverLog
(
LL_WARNING
,
"Critical error while loading ACLs. Exiting."
);
exit
(
1
);
}
if
(
server
.
acl_filename
[
0
]
!=
'\0'
)
{
sds
errors
=
ACLLoadFromFile
(
server
.
acl_filename
);
if
(
errors
)
{
serverLog
(
LL_WARNING
,
"Aborting Redis startup because of ACL errors: %s"
,
errors
);
sdsfree
(
errors
);
exit
(
1
);
}
}
}
/* =============================================================================
* ACL related commands
* ==========================================================================*/
...
...
src/server.c
View file @
80f98772
...
...
@@ -4908,11 +4908,7 @@ int main(int argc, char **argv) {
linuxMemoryWarnings
();
#endif
moduleLoadFromQueue
();
if
(
ACLLoadConfiguredUsers
()
==
C_ERR
)
{
serverLog
(
LL_WARNING
,
"Critical error while loading ACLs. Exiting."
);
exit
(
1
);
}
ACLLoadUsersAtStartup
();
loadDataFromDisk
();
if
(
server
.
cluster_enabled
)
{
if
(
verifyClusterConfigWithData
()
==
C_ERR
)
{
...
...
src/server.h
View file @
80f98772
...
...
@@ -1746,6 +1746,7 @@ int ACLAppendUserForLoading(sds *argv, int argc, int *argc_err);
char
*
ACLSetUserStringError
(
void
);
int
ACLLoadConfiguredUsers
(
void
);
sds
ACLDescribeUser
(
user
*
u
);
void
ACLLoadUsersAtStartup
(
void
);
/* 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