On 12Nov2008 14:07, Jeff McNeil <[EMAIL PROTECTED]> wrote:
| On Nov 12, 4:57 pm, Jeffrey Barish <[EMAIL PROTECTED]> wrote:
| > As per Stevens/Rago, "file and record locking provides a convenient
| > mutual-exclusion mechanism".  They note the convention of putting the lock
| > file in /var/run in a file called <name>.pid, where <name> is the name of
| > the daemon and content is the pid.  Seems like a good suggestion as I see
| > pid files from many other daemons there.  However, /var/run is owned by
| > root, so it is not possible to write in it without root permission.[...]
| 
| Sure, start the daemon as root, write the appropriate files, and then
| drop permissions using os.setegid and then os.seteuid. [...]

Or, more simply, get root to make an empty pid file once and chown it to
the daemon user. Then the daemon can rewrite the file as needed. You need
to move to truncating the file instead of removing it on daemon shutdown,
but that is trivial. And no mucking with privileges, like starting the
daemon as root instead of directly as the daemon user, need be done.

Cheers,
-- 
Cameron Simpson <[EMAIL PROTECTED]> DoD#743
http://www.cskk.ezoshosting.com/cs/

They said it couldn't be done/they said nobody could do it/
But he tried the thing that couldn't be done!/He tried - and he couldn't do it.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to