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
90fae58b
Commit
90fae58b
authored
Feb 04, 2020
by
antirez
Browse files
ACL LOG: make max log entries configurable.
parent
64a73e92
Changes
4
Show whitespace changes
Inline
Side-by-side
src/acl.c
View file @
90fae58b
...
...
@@ -1576,6 +1576,12 @@ void addACLLogEntry(client *c, int reason, int keypos, sds username) {
/* Add it to our list of entires. We'll have to trim the list
* to its maximum size. */
listAddNodeHead
(
ACLLog
,
le
);
while
(
listLength
(
ACLLog
)
>
server
.
acllog_max_len
)
{
listNode
*
ln
=
listLast
(
ACLLog
);
ACLLogEntry
*
le
=
listNodeValue
(
ln
);
ACLFreeLogEntry
(
le
);
listDelNode
(
ACLLog
,
ln
);
}
}
}
...
...
src/config.c
View file @
90fae58b
...
...
@@ -2233,6 +2233,7 @@ standardConfig configs[] = {
/* Unsigned Long configs */
createULongConfig
(
"active-defrag-max-scan-fields"
,
NULL
,
MODIFIABLE_CONFIG
,
1
,
LONG_MAX
,
server
.
active_defrag_max_scan_fields
,
1000
,
INTEGER_CONFIG
,
NULL
,
NULL
),
/* Default: keys with more than 1000 fields will be processed separately */
createULongConfig
(
"slowlog-max-len"
,
NULL
,
MODIFIABLE_CONFIG
,
0
,
LONG_MAX
,
server
.
slowlog_max_len
,
128
,
INTEGER_CONFIG
,
NULL
,
NULL
),
createULongConfig
(
"acllog-max-len"
,
NULL
,
MODIFIABLE_CONFIG
,
0
,
LONG_MAX
,
server
.
acllog_max_len
,
128
,
INTEGER_CONFIG
,
NULL
,
NULL
),
/* Long Long configs */
createLongLongConfig
(
"lua-time-limit"
,
NULL
,
MODIFIABLE_CONFIG
,
0
,
LONG_MAX
,
server
.
lua_time_limit
,
5000
,
INTEGER_CONFIG
,
NULL
,
NULL
),
/* milliseconds */
...
...
src/server.h
View file @
90fae58b
...
...
@@ -1385,6 +1385,7 @@ struct redisServer {
dict
*
latency_events
;
/* ACLs */
char
*
acl_filename
;
/* ACL Users file. NULL if not configured. */
unsigned
long
acllog_max_len
;
/* Maximum length of the ACL LOG list. */
/* Assert & bug reporting */
const
char
*
assert_failed
;
const
char
*
assert_file
;
...
...
tests/unit/acl.tcl
View file @
90fae58b
...
...
@@ -237,4 +237,15 @@ start_server {tags {"acl"}} {
assert
{[
dict get $entry object
]
eq
{
AUTH
}}
assert
{[
dict get $entry username
]
eq
{
antirez
}}
}
test
{
ACL LOG entries are limited to a maximum amount
}
{
r ACL LOG RESET
r CONFIG SET acllog-max-len 5
r AUTH antirez foo
for
{
set j 0
}
{
$j
< 10
}
{
incr j
}
{
catch
{
r SET obj:$j 123
}
}
r AUTH default
""
assert
{[
llength
[
r ACL LOG
]]
== 5
}
}
}
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