[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Modify Lua interpreter to implement a sandbox script language
- From: Andrew Gierth <andrew@...>
- Date: Tue, 04 Sep 2018 12:44:22 +0100
>>>>> "Dirk" == Dirk Laurie <dirk.laurie@gmail.com> writes:
>> Some of the base functions are essentially part of the language -
>> especially select(), pairs(), ipairs(), type(), pcall(), error(),
>> assert(), tonumber(), tostring(). Without at least those, writing
>> any nontrivial code will be hard.
Dirk> In fact, without tostring, print() does not work.
Dirk> (Monkey-patching print by changing tostring is an amusing
Dirk> pastime.)
In my sandbox, print() does not call _G.tostring() :-)
Dirk> I would add the string library to "essentially part of the
Dirk> language", but you can't hide that without invoking
Dirk> debug.setmetatable.
If you don't call luaopen_string then the string metatable is never set
up.
In my case I have no need to hide it, but I _do_ need to protect the
metatable itself from tampering, so I do the equivalent of
getmetatable("").__metatable = true
--
Andrew.