This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 850558 - dhcpd.service hardwires dhcpd configuration file
dhcpd.service hardwires dhcpd configuration file
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: dhcp (Show other bugs)
17
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Tomas Hozza
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-21 16:17 EDT by Michal Jaegermann
Modified: 2013-03-26 10:20 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-08-24 09:00:34 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Michal Jaegermann 2012-08-21 16:17:03 EDT
Description of problem:

'man dhcpd' explicitely says:
...
       -cf config-file
              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).

Additional info:
All the above applies to /usr/lib/systemd/system/dhcpd6.service as well
Comment 1 Jiri Popelka 2012-08-22 05:33:46 EDT
Hi Michal,

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.
See
https://fedoraproject.org/wiki/Packaging:Systemd#EnvironmentFiles_and_support_for_.2Fetc.2Fsysconfig_files

> 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.
Comment 2 Michal Jaegermann 2012-08-22 13:10:59 EDT
(In reply to comment #1)

> See
> https://fedoraproject.org/wiki/Packaging:
> Systemd#EnvironmentFiles_and_support_for_.2Fetc.2Fsysconfig_files

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.
Comment 3 Michal Jaegermann 2012-08-22 16:36:07 EDT
(In reply to comment #1)
> The preferred way to
> customize a service file is to copy it to /etc/systemd/system and modify
> there.

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.
Comment 4 Tomas Hozza 2012-08-24 09:00:34 EDT
Hi Michal,

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.
Comment 5 Fedora Update System 2012-09-13 11:25:49 EDT
dhcp-4.2.4-15.P2.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/dhcp-4.2.4-15.P2.fc18
Comment 6 Fedora Update System 2012-09-17 19:13:34 EDT
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.
Comment 7 Michal Jaegermann 2013-03-25 14:21:26 EDT
(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:

[Unit]
Description=DHCPv4 Server Daemon
Documentation=man:dhcpd(8) man:dhcpd.conf(5)
After=network.target
After=time-sync.target

[Service]
EnvironmentFile=/etc/sysconfig/dhcpd
ExecStart=/usr/sbin/dhcpd -f -user dhcpd -group dhcpd --no-pid $DHCPDARGS

[Install]
WantedBy=multi-user.target

with a default /etc/sysconfig/dhcpd containing

DHCPDARGS="-cf /etc/dhcp/dhcpd.conf"

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.
Comment 8 Jiri Popelka 2013-03-26 10:20:19 EDT
That's quite unlikely, sorry Michal.
See also bug #909733.

Note You need to log in before you can comment on or make changes to this bug.