[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Simple Lua for scripts
- From: Ben Sunshine-Hill <sneftel@...>
- Date: Mon, 22 Aug 2005 11:12:24 -0700
That's accomplished with setfenv.
On 8/22/05, Alain <email@example.com> wrote:
> Aaron Brown escreveu:
> > Alain wrote:
> >>I want to include Lua scripts in screen objects. My
> >>concern is that I want to limit accessibility to too many
> >>LUA commands, I want to limit the commands that he can
> > If I understand what you're trying to do, it can be done
> > easily in stock Lua. First use loadstring() to turn the
> > user's code into a function (this is where you catch any
> > syntax errors). Then use setfenv() to keep the function
> > from accessing any dangerous globals. This second step is
> > explained in section 14.3 of Programming in Lua:
> > <http://www.lua.org/pil/14.3.html>
> Ok, that was very usefull information and I will probably use both. But
> what I intended is something more restrictive. I want a syntax checker
> that forbids access to many lua functions, just saying ok/notok. I am
> thinking of a lexical analysis with only minimal lua syntax or something
> like that...
> The problem is that LUA is a powerfull language, and I don't want users
> with all that power because I am the one who will have to give support
> to the program. That means that if the user puts some statement in his
> script he can do more that was intended fot him to do.
That's accomplished with setfenv. Just only put the safe functions in
the environment that is set for the function.