mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
ACL: implement ACL SAVE.
This commit is contained in:
parent
484af7aa7a
commit
91aecf0138
28
src/acl.c
28
src/acl.c
@ -1491,18 +1491,26 @@ void aclCommand(client *c) {
|
|||||||
} else {
|
} else {
|
||||||
addReplyNull(c);
|
addReplyNull(c);
|
||||||
}
|
}
|
||||||
|
} else if (server.acl_filename[0] == '\0' &&
|
||||||
|
(!strcasecmp(sub,"load") || !strcasecmp(sub,"save")))
|
||||||
|
{
|
||||||
|
addReplyError(c,"This Redis instance is not configured to use an ACL file. You may want to specify users via the ACL SETUSER command and then issue a CONFIG REWRITE (assuming you have a Redis configuration file set) in order to store users in the Redis configuration.");
|
||||||
|
return;
|
||||||
} else if (!strcasecmp(sub,"load") && c->argc == 2) {
|
} else if (!strcasecmp(sub,"load") && c->argc == 2) {
|
||||||
if (server.acl_filename[0] == '\0') {
|
sds errors = ACLLoadFromFile(server.acl_filename);
|
||||||
addReplyError(c,"This Redis instance is not configured to use an ACL file. You may want to specify users via the ACL SETUSER command and then issue a CONFIG REWRITE (assuming you have a Redis configuration file set) in order to store users in the Redis configuration.");
|
if (errors == NULL) {
|
||||||
return;
|
addReply(c,shared.ok);
|
||||||
} else {
|
} else {
|
||||||
sds errors = ACLLoadFromFile(server.acl_filename);
|
addReplyError(c,errors);
|
||||||
if (errors == NULL) {
|
sdsfree(errors);
|
||||||
addReply(c,shared.ok);
|
}
|
||||||
} else {
|
} else if (!strcasecmp(sub,"save") && c->argc == 2) {
|
||||||
addReplyError(c,errors);
|
if (ACLSaveToFile(server.acl_filename) == C_OK) {
|
||||||
sdsfree(errors);
|
addReply(c,shared.ok);
|
||||||
}
|
} else {
|
||||||
|
addReplyError(c,"There was an error trying to save the ACLs. "
|
||||||
|
"Please check the server logs for more "
|
||||||
|
"information");
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(sub,"cat") && c->argc == 2) {
|
} else if (!strcasecmp(sub,"cat") && c->argc == 2) {
|
||||||
void *dl = addReplyDeferredLen(c);
|
void *dl = addReplyDeferredLen(c);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user