Bug 850558 - dhcpd.service hardwires dhcpd configuration file
Summary: dhcpd.service hardwires dhcpd configuration file
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: dhcp
Version: 17
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Tomáš Hozza
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-08-21 20:17 UTC by Michal Jaegermann
Modified: 2017-04-04 14:28 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-08-24 13:00:34 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1416517 0 medium CLOSED Cannot specify extra options to dhcpd 2021-02-22 00:41:40 UTC

Internal Links: 1416517

Description Michal Jaegermann 2012-08-21 20:17:03 UTC
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 09:33:46 UTC
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 17:10:59 UTC
(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 20:36:07 UTC
(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 Tomáš Hozza 2012-08-24 13:00:34 UTC
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 15:25:49 UTC
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 23:13:34 UTC
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 18:21:26 UTC
(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 14:20:19 UTC
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.