zeromq/zbroker — pull request #66 by hintjens (2014-05-05 09:57:45+00:00)
Title: Implement process lockfile and run user/group

- sets effective UID, typically root
- grabs write lock on server/lockfile (e.g. /var/run/zbroker.pid)
- dumps PID into lockfile
- sets group and/or user from server/group, server/user
- else sets back to real UID

Note, does not work using normal 'make' as zbroker isn't the real binary.
Here is how I build/test:

MAIN=zbroker
sudo rm $MAIN
gcc -g -o $MAIN \
$MAIN.c \
zpipes_msg.c zpipes_client.c zpipes_server.c \
-lczmq -lzmq -lzyre -luuid -lsodium
test $? -ne 0 && exit

sudo chown root $MAIN
sudo chgrp root $MAIN
sudo chmod +s $MAIN
./$MAIN

Note example of zbroker.cfg:

server
timeout = 10 # Client connection timeout
background = 0 # Run as background process
workdir = . # Working directory for daemon
animate = 1 # Do we animate or not?
user = ph # Run as this user
group = ph # Run as this group
lockfile = /var/run/zbroker.pid

Fixes #52
Fixes #53