lua-users home
lua-l archive

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

On 22-Aug-05, at 8:31 PM, Alain wrote:

Rici Lake escreveu:
So put down that book on yacc :) and just do it the simple way.

No so fast... What you said is perfect for security and I will include it. Simple and easy :)

But there remains on problem: I want to present users with a more simple syntax for the language. Not only for simplicity but for discipline too. There must be a way to do it.

Sure. You could write your own language. But I have a hard time figuring out what could be simpler than Lua. What syntactic constructs would you like to eliminate? (I emphasize the word syntactic here -- I understand the issue with spelling errors on global variables. That one is actually pretty simple to detect; the easiest way is to compile the function and then run it through luac and look for GETGLOBAL/SETGLOBAL lines. Or you could just copy the luac printing code; it's pretty straightforward.)

You sai in another message: "Trust your users. That may be hard, but it's worth it in the long run." Well I don't trust them, it is sad but it is a fact of life: users are dangerous, agressive creatures.

If you really feel that way, then I would advise that you get out of tech support. The pay's lousy and the work's repetitive. The only reward is the joy of helping people learn, and if you don't find joy in that, neither will they, and you'll all end up frustrated. Trust me on this -- I spent a lot of years doing tech support, and I miss it sometimes, but I saw a lot of my coworkers get really frustrated, and unnecessarily so. I personally *hate* the word "users"; I always made a point of saying "colleagues". Which I suspect was another frustration for my colleagues in tech support.

As For sandboxing, I understand that I can apply this principle for the whole screen, am I correct? This way, the whole application will be safer, or if I remove all dangerous functions is enough?

Every time you do a lua_open (i.e. every screen), you need to load a set of libraries. Presumably, you will do this with some wrapper function, so it should be easy to customise. Edit the list of libraries and/or edit the luaL_reg's of functions which they install. This is also where you will install your own functions and globals. Whatever you put into the Lua state is all there is; lua_open does not install a single function.

If all the scripts for a screen are written by the same user, it shouldn't be necessary to sandbox them from each other, as you say. In fact, it might be useful to them to be able to use globals (you can, however, give each script a separate globals table if that's useful to you).