Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
e8d00577
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e8d00577
编写于
1月 28, 2020
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ACL LOG: implement ACL LOG subcommadn skeleton.
上级
3e9e27e9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
0 deletion
+37
-0
src/acl.c
src/acl.c
+37
-0
未找到文件。
src/acl.c
浏览文件 @
e8d00577
...
@@ -1477,6 +1477,11 @@ typedef struct aclLogEntry {
...
@@ -1477,6 +1477,11 @@ typedef struct aclLogEntry {
sds
cinfo
;
/* Client info (last client if updated). */
sds
cinfo
;
/* Client info (last client if updated). */
}
aclLogEntry
;
}
aclLogEntry
;
/* Adds a new entry in the ACL log, making sure to delete the old entry
* if we reach the maximum length allowed for the log. This function attempts
* to find similar entries in the current log in order to bump the counter of
* the log entry instead of creating many entries for very similar ACL
* rules issues. */
void
addACLLogEntry
(
client
*
c
,
int
reason
,
int
keypos
)
{
void
addACLLogEntry
(
client
*
c
,
int
reason
,
int
keypos
)
{
/* Create a new entry. */
/* Create a new entry. */
struct
aclLogEntry
*
le
=
zmalloc
(
sizeof
(
*
le
));
struct
aclLogEntry
*
le
=
zmalloc
(
sizeof
(
*
le
));
...
@@ -1518,6 +1523,7 @@ void addACLLogEntry(client *c, int reason, int keypos) {
...
@@ -1518,6 +1523,7 @@ void addACLLogEntry(client *c, int reason, int keypos) {
* ACL GETUSER <username>
* ACL GETUSER <username>
* ACL GENPASS
* ACL GENPASS
* ACL WHOAMI
* ACL WHOAMI
* ACL LOG [<count> | RESET]
*/
*/
void
aclCommand
(
client
*
c
)
{
void
aclCommand
(
client
*
c
)
{
char
*
sub
=
c
->
argv
[
1
]
->
ptr
;
char
*
sub
=
c
->
argv
[
1
]
->
ptr
;
...
@@ -1704,6 +1710,36 @@ void aclCommand(client *c) {
...
@@ -1704,6 +1710,36 @@ void aclCommand(client *c) {
char
pass
[
32
];
/* 128 bits of actual pseudo random data. */
char
pass
[
32
];
/* 128 bits of actual pseudo random data. */
getRandomHexChars
(
pass
,
sizeof
(
pass
));
getRandomHexChars
(
pass
,
sizeof
(
pass
));
addReplyBulkCBuffer
(
c
,
pass
,
sizeof
(
pass
));
addReplyBulkCBuffer
(
c
,
pass
,
sizeof
(
pass
));
}
else
if
(
!
strcasecmp
(
sub
,
"log"
)
&&
(
c
->
argc
==
2
||
c
->
argc
==
3
))
{
long
count
=
10
;
/* Number of entries to emit by default. */
/* Parse the only argument that LOG may have: it could be either
* the number of entires the user wants to display, or alternatively
* the "RESET" command in order to flush the old entires. */
if
(
c
->
argc
==
3
)
{
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"reset"
))
{
/* TODO: reset the log. */
addReply
(
c
,
shared
.
ok
);
return
;
}
else
if
(
getLongFromObjectOrReply
(
c
,
c
->
argv
[
2
],
&
count
,
NULL
)
!=
C_OK
)
{
return
;
}
if
(
count
<
0
)
count
=
0
;
}
/* Fix the count according to the number of entries we got. */
if
((
size_t
)
count
>
listLength
(
ACLLog
))
count
=
listLength
(
ACLLog
);
addReplyArrayLen
(
c
,
count
);
listIter
li
;
listNode
*
ln
;
listRewind
(
ACLLog
,
&
li
);
while
(
count
--
&&
(
ln
=
listNext
(
&
li
))
!=
NULL
)
{
addReplyLongLong
(
c
,
1234
);
}
}
else
if
(
!
strcasecmp
(
sub
,
"help"
))
{
}
else
if
(
!
strcasecmp
(
sub
,
"help"
))
{
const
char
*
help
[]
=
{
const
char
*
help
[]
=
{
"LOAD -- Reload users from the ACL file."
,
"LOAD -- Reload users from the ACL file."
,
...
@@ -1716,6 +1752,7 @@ void aclCommand(client *c) {
...
@@ -1716,6 +1752,7 @@ void aclCommand(client *c) {
"CAT <category> -- List commands inside category."
,
"CAT <category> -- List commands inside category."
,
"GENPASS -- Generate a secure user password."
,
"GENPASS -- Generate a secure user password."
,
"WHOAMI -- Return the current connection username."
,
"WHOAMI -- Return the current connection username."
,
"LOG [<count> | RESET] -- Show the ACL log entries."
,
NULL
NULL
};
};
addReplyHelp
(
c
,
help
);
addReplyHelp
(
c
,
help
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录