Bug 222151 - net/dhcpd doesn't start without discouraged -c flag
Summary: net/dhcpd doesn't start without discouraged -c flag
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Torsten Zuehlsdorff
URL:
Keywords: easy
Depends on:
Blocks:
 
Reported: 2017-09-08 20:40 UTC by mwlucas
Modified: 2019-03-04 10:04 UTC (History)
5 users (show)

See Also:
koobs: maintainer-feedback+
tz: merge-quarterly-


Attachments
rc.d script patch for defining interfaces in rc.conf without overwriting default flags (570 bytes, patch)
2018-03-06 21:04 UTC, Dries Michiels
no flags Details | Diff
Use PREFIX/etc/dhcpd.conf by default, dhcpd_flags="" (1.21 KB, patch)
2018-03-08 14:22 UTC, Nikola Kolev
koue: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mwlucas 2017-09-08 20:40:38 UTC
Running the latest dhcpd package, dhcpd-6.0.20170207, on -current

Configured /usr/local/etc/dhcpd.conf. Enabled in rc.conf. Ran service dhcpd start. It did not start. /var/log/messages shows

Sep  8 12:28:27 zfs3 dhcpd: Can't open /etc/dhcpd.conf: No such file or directory
Sep  8 12:28:27 zfs3 dhcpd: exiting.

Easy enough, right? Change the config file location on the command line. But -c includes the text: "this option should be used only for testing database files in a non-production environment."

So copy the config to /etc? No, violates pkg config rules

I don't know the correct answer, but I have a couple suggestions:

- make -c /usr/local/etc/dhcpd.conf the default
- add a patch to change the default config file location

Thanks!
Comment 1 Nikola Kolev 2017-09-09 10:51:33 UTC
Hi Michael,

In the port tree 'files/dhcpd.in' is the start-stop script for the dhcpd daemon. %%PREFIX%% variable in the same 'PREFIX' variable passed during compilation. In the 'Makefile' of the the port 'MAKE_ARGS' passes default 'PREFIX' value which is '/usr/local'.

Starting the daemon with the rc start-stop script executes:
/usr/local/sbin/daemon -c /usr/local/etc/dhcpd.conf

I'm running FreeBSD 11.0 and the latest version the ports tree and the daemon starts as its expected. No message 'this option should be used only for testing databases files in a non-production environment.' show up. I assume on FreeBSD-current there is some change in handling environment variables. I will investigate it but at the moment I will not provide patch because the port works as its expected on FreeBSD-stable.

Thanks,
Nikola
Comment 2 mwlucas 2017-09-09 14:15:34 UTC
For clarity:

The warning on -c is in the man page, not in program output.
Comment 3 Nikola Kolev 2017-09-09 14:58:21 UTC
According to the manul page:

-c config-file
    Use an alternate configuration file, config-file. Because of the importance of using the same lease database at all times when running dhcpd in production, this option should be used only for testing database files in a non-production environment.

dhcpd daemon is ported from OpenBSD. On OpenBSD by default the configuration file is /etc/dhcpd.conf. On FreeBSD by default the configuration file is /usr/local/etc/dhcpd.conf or ${PREFIX}/etc/dhcpd.conf if ${PREFIX} has different value. This parameter can be changed by 'dhcpd_flags' in /etc/rc.conf. The manual page recommends to use single configuration file because of the lease database. If using default dhcpd flags on FreeBSD it will always use ${PREFIX}/etc/dhcpd.conf and there will be no problem like mixing lease database.
Comment 4 Walter Schwarzenfeld freebsd_triage 2018-02-12 18:34:41 UTC
Status?
Comment 5 Dries Michiels 2018-03-06 20:31:40 UTC
The problem is that the rc.d script does not take -c /usr/local/etc/dhcpd.conf with its flags when you overwrite them in rc.conf. If you want to specify additional flags to dhcpd you will have to start them with "-c /usr/local/etc/dhcpd.conf" in rc.conf.

for example:
 dhcpd_enable="YES"
 dhcpd_flags="-c /usr/local/etc/dhcpd.conf extraflagshere"

I feel like the rc.d script should be extended to always give the program the following flags: "-c /usr/local/etc/dhcpd.conf" and then the extra flags should be passed by dhcpd_flags="extraflagshere".

Could this be implemented? Or a similar dhcpd_interfaces="" in rc.conf as isc-dhcpd. The interfaces should just be appended to the start command.

I'll take a look at this when time permits.
Comment 6 Dries Michiels 2018-03-06 21:04:08 UTC
Created attachment 191263 [details]
rc.d script patch for defining interfaces in rc.conf without overwriting default flags

This should fix the overwrite of the default config file location. Interfaces can now be specified in rc.conf under "dhcpd_interfaces" and are appended to the start command.
Comment 7 Nikola Kolev 2018-03-08 14:22:30 UTC
Created attachment 191310 [details]
Use PREFIX/etc/dhcpd.conf by default, dhcpd_flags=""

Hi,

Thanks for reporting this issue. With the following patch dhcpd will start using PREFIX/etc/dhcpd.conf by default and dhcpd_flags can be used for additional flags.
Comment 8 Dries Michiels 2018-03-08 15:32:41 UTC
Awesome fix. Much better than mine. 
When can this be committed?
Comment 9 Kubilay Kocak freebsd_committer freebsd_triage 2018-03-09 04:18:56 UTC
Comment on attachment 191263 [details]
rc.d script patch for defining interfaces in rc.conf without overwriting default flags

Obsolete non-maintainer submitted or approved patch.
Comment 10 Dries Michiels 2018-03-16 17:28:12 UTC
Can someone commit this patch please?
Comment 11 Dries Michiels 2018-03-26 09:50:44 UTC
Any updates?
Comment 12 commit-hook freebsd_committer 2018-05-25 14:04:56 UTC
A commit references this bug:

Author: tz
Date: Fri May 25 14:04:07 UTC 2018
New revision: 470842
URL: https://svnweb.freebsd.org/changeset/ports/470842

Log:
  net/dhcpd: doesn't start without discouraged -c flag

  Remove discouraged -c flag from rc-file.
  Also use PREFIX in config file

  PR:		222151
  Submitted by:	Nikola Kolev <koue@chaosophia.net>
  Reported by:	mwlucas@michaelwlucas.com
  Approved by:	Nikola Kolev <koue@chaosophia.net>
  MFC after:	2018Q2

Changes:
  head/net/dhcpd/Makefile
  head/net/dhcpd/files/dhcpd.in
Comment 13 Torsten Zuehlsdorff freebsd_committer 2018-06-05 14:26:00 UTC
Committed, thanks! :)

Also i don't think that an MFH is really needed. The PR is several month old and the fix will go into the next quarterly within 3 weeks. So i don't see any need to rush. ;)
Comment 14 Nikola Kolev 2019-03-04 10:04:38 UTC
@Eugene Grosbein remove 225262 as related PR. 225262 is about net/dhcp[C]d