6

Possible Duplicates:
How can I limit lua possibilities (calling OS functions, modules, etc.)
How can I create a secure Lua sandbox?

luaL_openlibs(m_pState);

I use this function to load all the libs.I would like to skip all the dangerous libs like IO but I just cant find any documentation on how to disable a lib.

How do I disable certain libs? Are there more dangerous libs that can gain the script access to the system?

Community
  • 1
  • 1
Milkman
  • 87
  • 1
  • 3
  • 5
    There are a number of SO questions on this already. For example, [How can I create a secure Lua sandbox?](http://stackoverflow.com/questions/1224708/how-can-i-create-a-secure-lua-sandbox) and [How can I limit lua possibilities (calling OS functions, modules, etc.)](http://stackoverflow.com/questions/3627954/how-can-i-limit-lua-possibilities-calling-os-functions-modules-etc). [See here](http://lua-users.org/wiki/SandBoxes) as well – Alex Aug 08 '11 at 04:39

1 Answers1

4

Add a copy of linit.c to your project and remove any libraries that you deem dangerous. To remove individual functions, set them to nil. See also the source of the Lua demo.

lhf
  • 70,581
  • 9
  • 108
  • 149