Commit 14507457 authored by zhaozhao.zz's avatar zhaozhao.zz
Browse files

ACL: show categories in COMMAND reply

Adding another new filed categories at the end of
command reply, it's easy to read and distinguish
flags and categories, also compatible with old format.
parent a65094da
...@@ -1480,3 +1480,15 @@ NULL ...@@ -1480,3 +1480,15 @@ NULL
addReplySubcommandSyntaxError(c); addReplySubcommandSyntaxError(c);
} }
} }
void addReplyCommandCategories(client *c, struct redisCommand *cmd) {
int flagcount = 0;
void *flaglen = addReplyDeferredLen(c);
for (int j = 0; ACLCommandCategories[j].flag != 0; j++) {
if (cmd->flags & ACLCommandCategories[j].flag) {
addReplyStatusFormat(c, "@%s", ACLCommandCategories[j].name);
flagcount++;
}
}
setDeferredSetLen(c, flaglen, flagcount);
}
...@@ -3698,8 +3698,8 @@ void addReplyCommand(client *c, struct redisCommand *cmd) { ...@@ -3698,8 +3698,8 @@ void addReplyCommand(client *c, struct redisCommand *cmd) {
if (!cmd) { if (!cmd) {
addReplyNull(c); addReplyNull(c);
} else { } else {
/* We are adding: command name, arg count, flags, first, last, offset */ /* We are adding: command name, arg count, flags, first, last, offset, categories */
addReplyArrayLen(c, 6); addReplyArrayLen(c, 7);
addReplyBulkCString(c, cmd->name); addReplyBulkCString(c, cmd->name);
addReplyLongLong(c, cmd->arity); addReplyLongLong(c, cmd->arity);
...@@ -3729,6 +3729,8 @@ void addReplyCommand(client *c, struct redisCommand *cmd) { ...@@ -3729,6 +3729,8 @@ void addReplyCommand(client *c, struct redisCommand *cmd) {
addReplyLongLong(c, cmd->firstkey); addReplyLongLong(c, cmd->firstkey);
addReplyLongLong(c, cmd->lastkey); addReplyLongLong(c, cmd->lastkey);
addReplyLongLong(c, cmd->keystep); addReplyLongLong(c, cmd->keystep);
addReplyCommandCategories(c,cmd);
} }
} }
......
...@@ -1748,6 +1748,7 @@ char *ACLSetUserStringError(void); ...@@ -1748,6 +1748,7 @@ char *ACLSetUserStringError(void);
int ACLLoadConfiguredUsers(void); int ACLLoadConfiguredUsers(void);
sds ACLDescribeUser(user *u); sds ACLDescribeUser(user *u);
void ACLLoadUsersAtStartup(void); void ACLLoadUsersAtStartup(void);
void addReplyCommandCategories(client *c, struct redisCommand *cmd);
/* Sorted sets data type */ /* Sorted sets data type */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment