Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
8d3e063a
Commit
8d3e063a
authored
Nov 03, 2010
by
antirez
Browse files
added support for command renaming/suppression in redis.conf
parent
1b1f47c9
Changes
3
Hide whitespace changes
Inline
Side-by-side
redis.conf
View file @
8d3e063a
...
@@ -125,6 +125,22 @@ dir ./
...
@@ -125,6 +125,22 @@ dir ./
#
#
# requirepass foobared
# requirepass foobared
# Command renaming.
#
# It is possilbe to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# of hard to guess so that it will be still available for internal-use
# tools but not available for general clients.
#
# Example:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# It is also possilbe to completely kill a command renaming it into
# an empty string:
#
# rename-command CONFIG ""
################################### LIMITS ####################################
################################### LIMITS ####################################
# Set the max number of connected clients at the same time. By default there
# Set the max number of connected clients at the same time. By default there
...
...
src/config.c
View file @
8d3e063a
...
@@ -214,16 +214,40 @@ void loadServerConfig(char *filename) {
...
@@ -214,16 +214,40 @@ void loadServerConfig(char *filename) {
server
.
vm_pages
=
memtoll
(
argv
[
1
],
NULL
);
server
.
vm_pages
=
memtoll
(
argv
[
1
],
NULL
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"vm-max-threads"
)
&&
argc
==
2
)
{
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"vm-max-threads"
)
&&
argc
==
2
)
{
server
.
vm_max_threads
=
strtoll
(
argv
[
1
],
NULL
,
10
);
server
.
vm_max_threads
=
strtoll
(
argv
[
1
],
NULL
,
10
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"hash-max-zipmap-entries"
)
&&
argc
==
2
){
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"hash-max-zipmap-entries"
)
&&
argc
==
2
)
{
server
.
hash_max_zipmap_entries
=
memtoll
(
argv
[
1
],
NULL
);
server
.
hash_max_zipmap_entries
=
memtoll
(
argv
[
1
],
NULL
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"hash-max-zipmap-value"
)
&&
argc
==
2
){
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"hash-max-zipmap-value"
)
&&
argc
==
2
)
{
server
.
hash_max_zipmap_value
=
memtoll
(
argv
[
1
],
NULL
);
server
.
hash_max_zipmap_value
=
memtoll
(
argv
[
1
],
NULL
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"list-max-ziplist-entries"
)
&&
argc
==
2
){
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"list-max-ziplist-entries"
)
&&
argc
==
2
){
server
.
list_max_ziplist_entries
=
memtoll
(
argv
[
1
],
NULL
);
server
.
list_max_ziplist_entries
=
memtoll
(
argv
[
1
],
NULL
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"list-max-ziplist-value"
)
&&
argc
==
2
){
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"list-max-ziplist-value"
)
&&
argc
==
2
)
{
server
.
list_max_ziplist_value
=
memtoll
(
argv
[
1
],
NULL
);
server
.
list_max_ziplist_value
=
memtoll
(
argv
[
1
],
NULL
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"set-max-intset-entries"
)
&&
argc
==
2
){
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"set-max-intset-entries"
)
&&
argc
==
2
)
{
server
.
set_max_intset_entries
=
memtoll
(
argv
[
1
],
NULL
);
server
.
set_max_intset_entries
=
memtoll
(
argv
[
1
],
NULL
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"rename-command"
)
&&
argc
==
3
)
{
struct
redisCommand
*
cmd
=
lookupCommand
(
argv
[
1
]);
int
retval
;
if
(
!
cmd
)
{
err
=
"No such command in rename-command"
;
goto
loaderr
;
}
/* If the target command name is the emtpy string we just
* remove it from the command table. */
retval
=
dictDelete
(
server
.
commands
,
argv
[
1
]);
redisAssert
(
retval
==
DICT_OK
);
/* Otherwise we re-add the command under a different name. */
if
(
sdslen
(
argv
[
2
])
!=
0
)
{
sds
copy
=
sdsdup
(
argv
[
2
]);
retval
=
dictAdd
(
server
.
commands
,
copy
,
cmd
);
if
(
retval
!=
DICT_OK
)
{
sdsfree
(
copy
);
err
=
"Target command name already exists"
;
goto
loaderr
;
}
}
}
else
{
}
else
{
err
=
"Bad directive or wrong number of arguments"
;
goto
loaderr
;
err
=
"Bad directive or wrong number of arguments"
;
goto
loaderr
;
}
}
...
...
src/redis.c
View file @
8d3e063a
...
@@ -799,6 +799,14 @@ void initServerConfig() {
...
@@ -799,6 +799,14 @@ void initServerConfig() {
R_PosInf
=
1
.
0
/
R_Zero
;
R_PosInf
=
1
.
0
/
R_Zero
;
R_NegInf
=
-
1
.
0
/
R_Zero
;
R_NegInf
=
-
1
.
0
/
R_Zero
;
R_Nan
=
R_Zero
/
R_Zero
;
R_Nan
=
R_Zero
/
R_Zero
;
/* Command table -- we intiialize it here as it is part of the
* initial configuration, since command names may be changed via
* redis.conf using the rename-command directive. */
server
.
commands
=
dictCreate
(
&
commandTableDictType
,
NULL
);
populateCommandTable
();
server
.
delCommand
=
lookupCommandByCString
(
"del"
);
server
.
multiCommand
=
lookupCommandByCString
(
"multi"
);
}
}
void
initServer
()
{
void
initServer
()
{
...
@@ -814,12 +822,6 @@ void initServer() {
...
@@ -814,12 +822,6 @@ void initServer() {
redisLog
(
REDIS_WARNING
,
"Can't open /dev/null: %s"
,
server
.
neterr
);
redisLog
(
REDIS_WARNING
,
"Can't open /dev/null: %s"
,
server
.
neterr
);
exit
(
1
);
exit
(
1
);
}
}
server
.
commands
=
dictCreate
(
&
commandTableDictType
,
NULL
);
populateCommandTable
();
server
.
delCommand
=
lookupCommandByCString
(
"del"
);
server
.
multiCommand
=
lookupCommandByCString
(
"multi"
);
server
.
clients
=
listCreate
();
server
.
clients
=
listCreate
();
server
.
slaves
=
listCreate
();
server
.
slaves
=
listCreate
();
server
.
monitors
=
listCreate
();
server
.
monitors
=
listCreate
();
...
...
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