[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua bug - loadfile gets stdin confused
- From: roberto@... (Roberto Ierusalimschy)
- Date: Wed, 18 Apr 2007 15:53:01 -0300
> Closing, or at least re-opening to /dev/null or similar, the standard
> file handles is essential if you're writing a daemon that chroots and
> drops privileges, otherwise you had FDs open as root.
To write such deamon, you will need a Posix library (or something
similar). Then that library can offer some secure way to close the
standard files. For instance, the daemon can close the file descriptors
(instead of the handles). Unlike file handles, file descriptors seem to
have a well-defined behavior even when closed (e.g., EBADF errors).
As Ross pointed out, the ability to close stdin together with its use
in several places in Lua is wrong. So, either we should check that
stdin is valid (how??) whenever we use it, or we drop its use
altogether, or we avoid it being closed. For what the standard Lua
distribution is aimed, the last option seems the most reasonable.
-- Roberto