Bug 196449 - dns/nsd Problem with pidfile in chrooted environment
Summary: dns/nsd Problem with pidfile in chrooted environment
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-02 21:21 UTC by Adam Zaleski
Modified: 2015-02-08 02:43 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (jaap)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Zaleski 2015-01-02 21:21:07 UTC
Hello

There is a problem with dns/nsd startup script. 
This script reads pidfile location from configfile.
However if NSD is started in chrooted environemnent
then startup script can't locate pidfile and stop the daemon.

I tried to configure pidfile location to /var/run/nsd in nsd.conf
and then created this directory under relative path to chroot directory 
but it didn't help as  nsd-checkconf checks whether pidfile is 
relative to chroot or no:

[root@ns348344 ~]# /usr/local/sbin/nsd-checkconf -o pidfile /usr/local/etc/nsd/nsd.conf
/usr/local/etc/nsd/nsd.conf: pidfile /var/run/nsd/nsd.pid is not relative to chroot /usr/local/etc/nsd/.
/usr/local/etc/nsd/nsd.conf: 1 semantic errors in 1 zones, 1 keys.
[root@ns348344 ~]#

The best would be read to variable from config if chroot is in use  by issuing
/usr/local/sbin/nsd-checkconf -o chroot /usr/local/etc/nsd/nsd.conf
and then concatenate this path to pidfile location to get the real path.


Also I found out that removing pidfile variable from startup script solves the problem and pidfiles are automatically discovered. It seems that /etc/rc.subr does some magic over that.
Comment 1 Bugzilla Automation freebsd_committer freebsd_triage 2015-01-02 21:21:07 UTC
Maintainer CC'd
Comment 2 Jaap Akkerhuis 2015-01-05 15:56:08 UTC
Omitting the pidfile causes subr.rc to hunt with ps for the PID.

A workaround is to  specify the full path, including the chroot directory of the pidifle in the nsd.conf, so that will be with these parameters

    pidfile: "/usr/local/etc/nsd/var/run/nsd/nsd.pid"

I'll send a patch for the script ASAP
Comment 3 Jaap Akkerhuis 2015-02-03 14:14:58 UTC
Just Released nsd 4.1.1 (See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197291) which should fix this problem.
Comment 4 Erwin Lansing freebsd_committer freebsd_triage 2015-02-08 02:43:20 UTC
Fixed in the update to 4.1.1