While I have added those options in 2.0.0, I felt that it's not the purpose of a program to perform these operations. Even though there are common unix features, they also break unix philosophy of doing only one thing right.
UID and GID¶
Handling UID/GID switching from code requires number of checks. We need to check if
setuid are available and with appropriate headers.
Some systems already have a
daemon utility to run a program in background specifying a user to run as.
Exemple on FreeBSD:
daemon -u nobody irccd -v
The daemonize process was very early in the previous code. And when debugging I was always specifying the
-f flag to be sure irccd does not run in background. Unfortunately I forgot many times and I got multiple daemon trying to connect in many servers. This was quite frustrating even though I understand it's my own issue.
But as explained above, there is already a
daemon tool to actually spawn a process into a daemon, there is also
nohub or simple tmux for some people.
Daemon has also been considered deprecated by macOS and therefore a warning was issued at compile time that requires a special compiler flag to disable a warning and I hate to disable warnings.
In my opinion, it's the business of a service manager to spawn a process into the background and taking care of it. Systemd by default assume programs do not fork by themselves unless you specify
Type=forking in the unit file.
Irccd no longers write it's own process id into a file. For the same reasons above, I think it's the responsability of the service manager to track its process and be sure it's still running.
What does that change for me?¶
Irccd 3.0.0 will come with a service file for FreeBSD and to configure the user/group of the service FreeBSD already used the convention
program_group in the /etc/rc.conf. That means you will able to change its UID/GID like this:
irccd_enable="YES" irccd_user="nobody" irccd_group="nobody"
for systemd, the unit file won't set a user/group by default for now because it's very hard to determine portable user and group across the distributions. But with systemd override support, you will be able to set
Remember, the unix philosophy prefers to delegate as much as possible functions that could be handled by external tools. This changes has removed a high number of
#ifdef and CMake checks, keeping the code cleaner.
The whole change has removed around 343 lines of code.