3

I am using Lua as a script language inside my C application.

It suits me well, but I can't understand how can I limit Lua not to call system functions, include other modules, etc.

I want Lua to be able to call only functions that are allowed by me, because user can do all kind of bad things with full Lua + Lua modules power.

Marko Kevac
  • 2,902
  • 30
  • 47
  • 3
    possible duplicate of [How can I create a secure Lua sandbox?](http://stackoverflow.com/questions/1224708/how-can-i-create-a-secure-lua-sandbox) – Judge Maygarden Sep 02 '10 at 15:48

3 Answers3

6

Take a look at the Simple Sandbox on the Lua-users wiki: http://lua-users.org/wiki/SandBoxes

Related SO discussions:

Community
  • 1
  • 1
Corbin March
  • 25,526
  • 6
  • 73
  • 100
2

Sandbox is the term you're looking for. In a nutshell, only export to Lua the functions you want the users to call. It's that simple, really.

lhf
  • 70,581
  • 9
  • 108
  • 149
0

You can accomplish this by not loading the os or package modules. Rather than using luaL_openlibs, see this post.

Community
  • 1
  • 1
Jonathan Zrake
  • 603
  • 6
  • 9