diff options
author | antirez <antirez@gmail.com> | 2012-04-23 10:43:24 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2012-04-23 10:43:24 +0200 |
commit | a3f990818d649d16c0a26be4e18845d540875af8 (patch) | |
tree | 2ab728f0d6c307d7d9b0bf63433e1b2a71856598 /src/scripting.c | |
parent | eb6e7eb94df3f29b33dcdf40b1790dadc7f37f50 (diff) | |
download | redis-a3f990818d649d16c0a26be4e18845d540875af8.tar.gz |
Remove loadfile() access from the scripting engine.
Diffstat (limited to 'src/scripting.c')
-rw-r--r-- | src/scripting.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/scripting.c b/src/scripting.c index 4c7de33bf..a5f5683e1 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -412,6 +412,13 @@ void luaLoadLibraries(lua_State *lua) { #endif } +/* Remove a functions that we don't want to expose to the Redis scripting + * environment. */ +void luaRemoveUnsupportedFunctions(lua_State *lua) { + lua_pushnil(lua); + lua_setglobal(lua,"loadfile"); +} + /* This function installs metamethods in the global table _G that prevent * the creation of globals accidentally. * @@ -455,7 +462,9 @@ void scriptingEnableGlobalsProtection(lua_State *lua) { * See scriptingReset() for more information. */ void scriptingInit(void) { lua_State *lua = lua_open(); + luaLoadLibraries(lua); + luaRemoveUnsupportedFunctions(lua); /* Initialize a dictionary we use to map SHAs to scripts. * This is useful for replication, as we need to replicate EVALSHA |