lua-users home
lua-l archive

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


> Im using lua 4 in my server appz and I would like to limit filesystem
> access to a scope of certain directory only (i.e. the server appz root
> directory). Right now anybody can access whole filesystem tree from
> scripts.

The "standard" technique is to redefine the open functions. Something
like the following:

-- redefine `readfrom'
function readfrom (name)
  if not isOk(name) then
    error("cannot open file " .. name)
  end
  return %readfrom(name)   -- call the original `readfrom'
end

   ...  -- the same for writeto, etc.

-- Roberto