未验证 提交 fd7484cd 编写于 作者: S Salvatore Sanfilippo 提交者: GitHub

Merge pull request #5836 from soloestoy/fix-acl-warning

ACL: show categories in COMMAND reply
......@@ -1446,7 +1446,7 @@ void aclCommand(client *c) {
} else if (!strcasecmp(sub,"cat") && c->argc == 3) {
uint64_t cflag = ACLGetCommandCategoryFlagByName(c->argv[2]->ptr);
if (cflag == 0) {
addReplyErrorFormat(c, "Unknown category '%s'", c->argv[2]->ptr);
addReplyErrorFormat(c, "Unknown category '%s'", (char*)c->argv[2]->ptr);
return;
}
int arraylen = 0;
......@@ -1480,3 +1480,15 @@ NULL
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) {
if (!cmd) {
addReplyNull(c);
} else {
/* We are adding: command name, arg count, flags, first, last, offset */
addReplyArrayLen(c, 6);
/* We are adding: command name, arg count, flags, first, last, offset, categories */
addReplyArrayLen(c, 7);
addReplyBulkCString(c, cmd->name);
addReplyLongLong(c, cmd->arity);
......@@ -3729,6 +3729,8 @@ void addReplyCommand(client *c, struct redisCommand *cmd) {
addReplyLongLong(c, cmd->firstkey);
addReplyLongLong(c, cmd->lastkey);
addReplyLongLong(c, cmd->keystep);
addReplyCommandCategories(c,cmd);
}
}
......
......@@ -1748,6 +1748,7 @@ char *ACLSetUserStringError(void);
int ACLLoadConfiguredUsers(void);
sds ACLDescribeUser(user *u);
void ACLLoadUsersAtStartup(void);
void addReplyCommandCategories(client *c, struct redisCommand *cmd);
/* Sorted sets data type */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册