lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sat, Jun 7, 2008 at 5:42 PM, Shmuel Zeigerman <> wrote:
Abhinav Lele wrote:
But I want selectively allow different libraries in the lua environment. How can this be achieved ?

 lua_pushcfunction(L, luaopen_string);

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: = 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 ?

 local permitted = { lfs = true, lpeg = true, }
 local oldrequire = require
 require = function(libname)
   if not permitted[libname] then
     error("library `"..libname.."' not permitted")
   return oldrequire(libname)