lua-users home
lua-l archive

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

On 13/01/2010, at 3:48 AM, Dravonk wrote:

> It would be
>  file = assert ( (path))
>  source = file:read ("*all")
>  file:close ()
>  func = loadin (env, source, "@"..path)

This proposed solution assumes you want to be available. If I want to replicate:

func = loadfile(path)
setfenv(func, env)

... but have sandboxed out, is there another solution? The reason for sandboxing out is, for one thing, you can read arbitrary user files on disk (eg. files with passwords in them), and for another, you can open files for output. However loadfile cannot write to disk, and is restricted to reading files that have Lua code in them.

Doing this doesn't work:

in env do
  func = loadfile(path)

- Nick