lua-users home
lua-l archive

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


>> Is there any possibility to restrict file access from scripts to
>> specified paths only without modifying the lua source code ?

Wim Couwenberg:
> You can redefine (in Lua) the lua functions that take a filename argument
> to check for validity of the path first.
> For lua 5.0: loadfile | dofile | io.open | io.input | io.output | io.lines

There seems to be a variety of places to intercept. Perhaps there should be
a single internal function (eg, "io.checkpath") that all these functions
use. It could take the specified path and return the real path (or nil if
the specified path is invalid).

It could be used to restrict access to full paths (returns argument
unchanged unless access is invalid) or to redirect access (prepending a full
path onto the argument).

*cheers*
Peter Hill.