lua-users home
lua-l archive

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


Sweet ;) Thanx!

-----Original Message-----
From: Roberto Ierusalimschy [mailto:roberto@inf.puc-rio.br]
Sent: Wednesday, September 24, 2003 1:52 PM
To: Lua list
Subject: Re: LUA 4.x - filesystem access limit? 


> 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