[Bug 1824433] [NEW] dhcpd ignores $CONFIG_FILE in /etc/default/isc-dhcp-server
Norman Wilson
norman at teach.cs.toronto.edu
Thu Apr 11 21:56:16 UTC 2019
Public bug reported:
Package isc-dhcp-server 4.3.3 on Ubuntu 16.04 LTS.
On earlier (pre-systemd) systems, one could point dhcpd at a
configuration file in any location by setting
CONFIG_FILE=/new/path/dhcpd.conf in /etc/default/isc-dhcp-server. In
this version such setting is ignored; dhcpd always uses the default
/etc/dhcp/dhcpd.conf.
In more formulaeic terms:
Put CONFIG_FILE=/var/dhcpconf/mydhcp.conf in /etc/default/isc-dhcp-server.
I expect that when service isc-dhcp-server is next started, it will use that configuration file.
In fact it still uses /etc/dhcp/dhcpd.conf.
The problem can be worked around by making /etc/dhcp/dhcpd.conf a
symlink to the desired config file, but why have /etc/default/isc-dhcp-
server at all if it doesn't work?
The offending code is in /lib/systemd/system/isc-dhcp-server.service.
Here is a relevant extract:
[Service]
EnvironmentFile=/etc/default/isc-dhcp-server
RuntimeDirectory=dhcp-server
# The leases files need to be root:dhcpd even when dropping privileges
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; \
exec dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf $CONFIG_FILE $INTERFACES'
/etc/default/isc-dhcp-server is correctly read as an EnvironmentFile,
but the ExecStart command unconditionally sets CONFIG_FILE, discarding
any value from the /etc/default file.
One fix might be to change the first few lines of the ExecStart to check
whether $CONFIG_FILE has been set, and perhaps whether it is still the
default value:
ExecStart=/bin/sh -ec '\
case $CONFIG_FILE in \
""|/etc/dhcp/dhcpd.conf) \
CONFIG_FILE=/etc/dhcp/dhcpd.conf; \
if [ -f /etc/ltsp/dhcpd.conf ]; then CONFIG_FILE=/etc/ltsp/dhcpd.conf; fi; \
;; \
esac
Or it might make more sense to let whatever package is in charge of ltsp
configuration append CONFIG_FILE=/etc/ltsp/dhcpd.conf to /etc/defaults
/isc-dhcp-server, and replace the lines above with a simple
ExecStart=/bin/sh -ec '\
CONFIG_FILE=${CONFIG_FILE:-/etc/dhcp/dhcpd.conf}; \
Either way, a fix would be appreciated.
** Affects: isc-dhcp (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to isc-dhcp in Ubuntu.
https://bugs.launchpad.net/bugs/1824433
Title:
dhcpd ignores $CONFIG_FILE in /etc/default/isc-dhcp-server
Status in isc-dhcp package in Ubuntu:
New
Bug description:
Package isc-dhcp-server 4.3.3 on Ubuntu 16.04 LTS.
On earlier (pre-systemd) systems, one could point dhcpd at a
configuration file in any location by setting
CONFIG_FILE=/new/path/dhcpd.conf in /etc/default/isc-dhcp-server. In
this version such setting is ignored; dhcpd always uses the default
/etc/dhcp/dhcpd.conf.
In more formulaeic terms:
Put CONFIG_FILE=/var/dhcpconf/mydhcp.conf in /etc/default/isc-dhcp-server.
I expect that when service isc-dhcp-server is next started, it will use that configuration file.
In fact it still uses /etc/dhcp/dhcpd.conf.
The problem can be worked around by making /etc/dhcp/dhcpd.conf a
symlink to the desired config file, but why have /etc/default/isc-
dhcp-server at all if it doesn't work?
The offending code is in /lib/systemd/system/isc-dhcp-server.service.
Here is a relevant extract:
[Service]
EnvironmentFile=/etc/default/isc-dhcp-server
RuntimeDirectory=dhcp-server
# The leases files need to be root:dhcpd even when dropping privileges
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; \
exec dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf $CONFIG_FILE $INTERFACES'
/etc/default/isc-dhcp-server is correctly read as an EnvironmentFile,
but the ExecStart command unconditionally sets CONFIG_FILE, discarding
any value from the /etc/default file.
One fix might be to change the first few lines of the ExecStart to
check whether $CONFIG_FILE has been set, and perhaps whether it is
still the default value:
ExecStart=/bin/sh -ec '\
case $CONFIG_FILE in \
""|/etc/dhcp/dhcpd.conf) \
CONFIG_FILE=/etc/dhcp/dhcpd.conf; \
if [ -f /etc/ltsp/dhcpd.conf ]; then CONFIG_FILE=/etc/ltsp/dhcpd.conf; fi; \
;; \
esac
Or it might make more sense to let whatever package is in charge of
ltsp configuration append CONFIG_FILE=/etc/ltsp/dhcpd.conf to
/etc/defaults/isc-dhcp-server, and replace the lines above with a
simple
ExecStart=/bin/sh -ec '\
CONFIG_FILE=${CONFIG_FILE:-/etc/dhcp/dhcpd.conf}; \
Either way, a fix would be appreciated.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/isc-dhcp/+bug/1824433/+subscriptions
More information about the foundations-bugs
mailing list