How can I limit lua possibilities (calling OS functions, modules, etc.)

后端 未结 3 862
广开言路
广开言路 2021-01-21 22:50

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 mo

相关标签:
3条回答
  • 2021-01-21 23:12

    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.

    0 讨论(0)
  • 2021-01-21 23:23

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

    0 讨论(0)
  • 2021-01-21 23:37

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

    Related SO discussions:

    • Is there anyway to avoid this security issue in Lua?
    • How can I create a secure Lua sandbox?
    • How to execute an untrusted Lua file in its own environment from the C API
    0 讨论(0)
提交回复
热议问题