Re: Single-instance daemons

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cameron Simpson

    Re: Single-instance daemons

    On 12Nov2008 14:07, Jeff McNeil <jeff@jmcneil.n etwrote:
    | On Nov 12, 4:57 pm, Jeffrey Barish <jeff_bar...@ea rthlink.netwrot e:
    | 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 <nameis 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 <cs@zip.com.auD oD#743


    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.
Working...