Marko Kevac
Marko Kevac

Reputation: 2982

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

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.

Upvotes: 3

Views: 2489

Answers (3)

Jonathan Zrake
Jonathan Zrake

Reputation: 603

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

Upvotes: 0

lhf
lhf

Reputation: 72312

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.

Upvotes: 2

Related Questions