[Dnsmasq-discuss] patch to support systemd socket activation
simon at thekelleys.org.uk
Mon Nov 14 20:15:25 GMT 2011
On 14/11/11 09:19, 微菜 wrote:
> Hi there,
> I was once send it to our maintainers the patch for 2.57.
> Now I've rebased it to 2.59 and resend it here for discussion.
I remember the previous discussion. In the meantime, support for systemd
activation support has been added to the Debian package of dnsmasq. That
uses DBus activation and doesn't require any extra code in dnsmasq itself.
The dnsmasq.service file looks like this: some of it is Debian specific,
but it gives the general idea.
Description=A lightweight DHCP and caching DNS server
# Test the config file and refuse starting if it is not valid.
# Enable DBus by default because we use DBus activation.
# Drop privileges and become the 'dnsmasq' user. It is recommended by
# dnsmasq upstream to run dnsmasq as an isolated user that does not run
# any other processes, owns no files and has no shell. The default
# 'nobody' user has a shell and might be used for other processes.
# Debian-specific: add /etc/dnsmasq.d to config search path (with the
# exception of .dpkg-*). Packages such as libvirt leave config files
# --pid-file without argument disables writing a PIDfile, we don't need
ExecStart=/usr/sbin/dnsmasq -k \
-7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new \
ExecReload=/bin/kill -HUP $MAINPID
> This patch enables dnsmasq to support systemd socket activation.
> #systemctl enable dnsmasq.socket
> #systemctl enable dnsmasq-tftp.socket
> Then if some one try to access tftp or local DNS, dnsmasq will be
> started automatically.
> I didn't test DHCP functionality, so I did't come up with
> dnsmasq-dhcp.socket. sorry for the in-convenience.
I'm not a systemd expert, by any means, (I didn't write the code above)
but I'd like to understand the advantages and problems with the two
methods of activation (DBus and socket)
More information about the Dnsmasq-discuss