Red Hat Bugzilla – Bug 850558
dhcpd.service hardwires dhcpd configuration file
Last modified: 2017-04-04 10:28:24 EDT
Description of problem:
'man dhcpd' explicitely says:
Path to alternate configuration file.
Despite of the above /usr/lib/systemd/system/dhcpd.service has in it:
ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid $DHCPDARGS
So if one has indeed a configuration file specified in /etc/sysconfig/dhcpd (with a help of DHCPDARGS) then a running process looks like that:
/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid -cf <alternate_config> <whatever_else>
At this moment that happens to work as intended but it relies on particulars of an argument parsing by dhcpd and there are no guarantees that this will be like that in the future. Before dhcpd.service a startup script for dhcpd was careful enough to check what is in $DHCPDARGS and emit an options string accordingly.
One possible solution would be to drop "-cf /etc/dhcp/dhcpd.conf" from
'ExecStart= ...'. This is a default and it will be used anyway if not explicitely overriden with '-cf ...'. Another to move as many options as possible to 'DHCPDARGS=...' in /etc/sysconfig/dhcpd so they can be edited there as needed. Yet another one to have 'option_helper' to check $DHCPDARGS, produce needed option string and have something like
'ExecStart=/usr/sbin/dhcpd $(option_helper)' in a service file.
Version-Release number of selected component (if applicable):
dhcp-4.2.4-9.P1.fc17 (and others).
All the above applies to /usr/lib/systemd/system/dhcpd6.service as well
you are right and your suggested solutions make sense but I have even one another, see later.
(In reply to comment #0)
> One possible solution would be to drop "-cf /etc/dhcp/dhcpd.conf" from
> 'ExecStart= ...'. This is a default and it will be used anyway if not
> explicitely overriden with '-cf ...'.
This is how it used to be until 4.2.4-0.5.rc1.
I added the -cf to dhcpd.service file as a work-around to bug #819325.
The reason was that 'service dhcpd status' now shows what configuration file the daemon actually reads.
> Another to move as many options as
> possible to 'DHCPDARGS=...' in /etc/sysconfig/dhcpd so they can be edited
> there as needed.
The /etc/sysconfig/dhcpd and $DHCPDARGS are a relic of SysV Initscripts.
And I actually think it's time to remove them at all. The preferred way to customize a service file is to copy it to /etc/systemd/system and modify there.
> Yet another one to have 'option_helper' to check
> $DHCPDARGS, produce needed option string and have something like
> 'ExecStart=/usr/sbin/dhcpd $(option_helper)' in a service file.
The same as above comment.
(In reply to comment #1)
That says "Either approach is valid in Fedora". :-)
If you mean "roll your own" second to the last paragraph in that section then this does not strike me as a good design. Not that I am at all surprised.
There is also a small matter of upgrading an existing, working, installation and not springing surprises with that.
(In reply to comment #1)
> The preferred way to
> customize a service file is to copy it to /etc/systemd/system and modify
One other thing why this is VERY BAD. If you will follow "the preferred way" then you are condemned in perpetuity for checking if a file you copied did not change for whatever reasons and some may be important. I already have seen systems where something like that was done one time or another for debugging purposes and forgotten. This is shifting costs of misdesign on users/administrators.
Because the /etc/sysconfig/dhcpd and $DHCPDARGS are a relic of SysV Initscripts and it is preferred to customize the service file and because we consider DHCP service files to be stable, we decided to remove Environment Files and DHCPDARGS. Changes will be applied to the next release.
dhcp-4.2.4-15.P2.fc18 has been submitted as an update for Fedora 18.
dhcp-4.2.4-15.P2.fc18 has been pushed to the Fedora 18 stable repository. If problems still persist, please make note of it in this bug report.
(In reply to comment #4)
> Because the /etc/sysconfig/dhcpd and $DHCPDARGS are a relic of SysV
> Initscripts and it is preferred to customize the service file
Not really. After I read more of systemd documentation and looked at more of "real life" systemd units examples I am quite convinced that dhcpd.service file should look somewhat like this:
Description=DHCPv4 Server Daemon
ExecStart=/usr/sbin/dhcpd -f -user dhcpd -group dhcpd --no-pid $DHCPDARGS
with a default /etc/sysconfig/dhcpd containing
Of course a split between "fixed" and "configurable" options does not have to be like here but it seems to be reasonable.
On a Fedora 18 installation I checked 41 systemd units is using an explicitely documented 'EnvironmentFile' so it hardly can be called a relic. I strongly suggest that you reconsider.
That's quite unlikely, sorry Michal.
See also bug #909733.