[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua sandbox environment
- From: Shmuel Zeigerman <shmuz@...>
- Date: Sat, 07 Jun 2008 15:12:26 +0300
Abhinav Lele wrote:
But I want selectively allow different libraries in the lua environment.
How can this be achieved ?
lua_pushcfunction(L, luaopen_string);
lua_call(L,0,0);
Do so for every library you want to load.
Is the following approach okay :
to remove library io
executing the statement io=nil
Additionally, to prevent it from being require'd:
package.loaded.io = nil
Also I want strict control over what require keyword can load. So does
this imply, that I need to change lua code, and if so where ?
do
local permitted = { lfs = true, lpeg = true, }
local oldrequire = require
require = function(libname)
if not permitted[libname] then
error("library `"..libname.."' not permitted")
end
return oldrequire(libname)
end
end
--
Shmuel