lua-users home
lua-l archive

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

> Not for files, something that's been mentioned before recently: you'd
> have to use the io library explicitly, and you could have any number
> of valid reasons to not include that.. But I don't see anything useful
> coming out of letting, say, a sandboxed module load things into the
> global environment instead of its own.

I do not see why Lua should provide a function that you can build
yourself, only to save a few lines in the construction of some very
specifics sandboxes. E.g.,

  local setupvalue, loadfile = debug.setupvalue, loadfile
  function myloadfile (fn, env)
    local f, err = loadfile(fn)
    if not f then return f, err end
    setupvalue(f, 1, env)
    return f

(BTW, loadfile is quite insecure to be allowed in sandboxes, as it
may load binary files that can crash your program.)

-- Roberto