[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Environments
- From: Eva Schmidt <es@...>
- Date: Wed, 21 Mar 2007 17:44:58 +0100
Hello,
I've got a question about the environment mechanism in Lua.
I want to execute a little script from another script using loadfile(). Because
of the fact that I cannot make sure that this script doesn't contain code I
don't want to be executed (like os.exit() or something) I tried to just allow
certain functions using an environment like that:
-- create local environment for loadstring()
local fenv = {}
fenv.print = _G.print
setfenv (loadstring, fenv)
result, error = loadstring (s)
With this environment it should be possible to just call the printing function
within the chunk to be loaded. Maybe this approach is too naive - Lua forbits
changing the environment for the function loadstring() ;-(
Does anybody have some idea how I can force Lua to allow the executing of some
special functions and to prohibit other functions at the same time?
thanks for help!
Eva