Ubuntu 18.04 here, no apparmor.

Directory /run is on tempfs, so it is empty at start.
I suppose PID file /run/dhcp-server/dhcpd.pid can't be created because 
directory /run/dhcp-server is missing at startup and I haven't found where it 
will be created.

I've fixed systemd unit "/lib/systemd/system/isc-dhcp-server.service" by 
creating the needed "/run/dhcp-server" folder before starting dhcpd:
-----------------
[Unit]
Description=ISC DHCP IPv4 server
Documentation=man:dhcpd(8)
Wants=network-online.target
After=network-online.target
After=time-sync.target
ConditionPathExists=/etc/default/isc-dhcp-server
ConditionPathExists=|/etc/ltsp/dhcpd.conf
ConditionPathExists=|/etc/dhcp/dhcpd.conf

[Service]
EnvironmentFile=/etc/default/isc-dhcp-server
RuntimeDirectory=dhcp-server
# The leases files need to be root:dhcpd even when dropping privileges
ExecStartPre=/bin/mkdir -p /run/dhcp-server
ExecStart=/bin/sh -ec '\
    CONFIG_FILE=/etc/dhcp/dhcpd.conf; \
    if [ -f /etc/ltsp/dhcpd.conf ]; then CONFIG_FILE=/etc/ltsp/dhcpd.conf; fi; \
    [ -e /var/lib/dhcp/dhcpd.leases ] || touch /var/lib/dhcp/dhcpd.leases; \
    chown root:dhcpd /var/lib/dhcp /var/lib/dhcp/dhcpd.leases; \
    chmod 775 /var/lib/dhcp ; chmod 664 /var/lib/dhcp/dhcpd.leases; \
    if [ ! -d /run/dhcp-server ]; then mkdir -p /run/dhcp-server ; chown dhcpd 
/run/dhcp-server ; chmod 775 /run/dhcp-server; fi; \
    exec dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid 
-cf $CONFIG_FILE $INTERFACES'

[Install]
WantedBy=multi-user.target
-----------------

Still need to fix hardcoded PID filename instead of /etc/default/isc-
dhcp-server value...

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1448657

Title:
  isc-dhcp-server: Can't create PID file /run/dhcp-server/dhcpd.pid:
  Permission denied

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/isc-dhcp/+bug/1448657/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to