Bug 72713 - [patch] dhcpd fails to start with dhcpd_chroot_enable="YES"
Summary: [patch] dhcpd fails to start with dhcpd_chroot_enable="YES"
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Pav Lucistnik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-14 23:10 UTC by Hilko Meyer
Modified: 2004-10-17 14:00 UTC (History)
0 users

See Also:


Attachments
dhcp.diff (397 bytes, patch)
2004-10-14 23:10 UTC, Hilko Meyer
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hilko Meyer 2004-10-14 23:10:30 UTC
net/isc-dhcp3-server fails to start with
the following settings in /etc/rc.conf

dhcpd_enable="YES"
dhcpd_flags="-q"
dhcpd_conf="/usr/local/etc/dhcpd.conf"
dhcpd_withumask="022"
dhcpd_chuser_enable="YES"
dhcpd_withuser="dhcpd"
dhcpd_withgroup="dhcpd"
dhcpd_chroot_enable="YES"
dhcpd_devfs_enable="YES"
dhcpd_rootdir="/var/db/dhcpd"

/usr/local/etc/rc.d/isc-dhcpd.sh start yeilds the following
failure:

rmdir: /var/db/dhcpd: Directory not empty
rc.d/isc-dhcpd.sh: WARNING: unable to remove directory /var/db/dhcpd
mount: /var/db/dhcpd/dev: No such file or directory
rc.d/isc-dhcpd.sh: ERROR: unable to mount /var/db/dhcpd/dev

The error is caused by the deletion of /var/db/dhcpd/dev at once after
its creation in the setup_chroot () function in the start script.

How-To-Repeat: 
Set dhcpd_chroot_enable="YES" in /etc/rc.conf and start the dhcpd with
the installed start-script
Comment 1 Pav Lucistnik freebsd_committer freebsd_triage 2004-10-15 15:48:31 UTC
Dear maintainer of FreeBSD port net/isc-dhcp3-server, please take a look
at

http://www.freebsd.org/cgi/query-pr.cgi?q=72713

Do you approve this patch?

-- 
Pav Lucistnik <pav@oook.cz>
              <pav@FreeBSD.org>

May your arrow always find its mark.
Comment 2 Pav Lucistnik freebsd_committer freebsd_triage 2004-10-15 15:48:38 UTC
State Changed
From-To: open->feedback

Asked maintainer for approval. 


Comment 3 Pav Lucistnik freebsd_committer freebsd_triage 2004-10-15 15:48:38 UTC
Responsible Changed
From-To: freebsd-ports-bugs->pav

Handle.
Comment 4 Cyrille Lefevre 2004-10-16 02:17:38 UTC
> Dear maintainer of FreeBSD port net/isc-dhcp3-server, please take a look
> at
> 
> http://www.freebsd.org/cgi/query-pr.cgi?q=72713
> 
> Do you approve this patch?

I prefer this one :) well, .../_ is a hack until I add getopts to
safe_* functions one day. thanks anyway.

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/net/isc-dhcp3-server/Makefile,v
retrieving revision 1.103
diff -u -I$Id.*$ -I$.+BSD.*$ -r1.103 Makefile
--- Makefile	13 Oct 2004 00:17:49 -0000	1.103
+++ Makefile	16 Oct 2004 01:15:19 -0000
@@ -8,7 +8,7 @@
 
 PORTNAME=	dhcp
 PORTVERSION=	3.0.1.r14
-PORTREVISION=	5
+PORTREVISION=	6
 CATEGORIES=	net
 MASTER_SITES=	${MASTER_SITE_ISC}
 MASTER_SITE_SUBDIR=	dhcp dhcp/dhcp-3.0-history
Index: files/isc-dhcpd.sh.sample
===================================================================
RCS file: /home/ncvs/ports/net/isc-dhcp3-server/files/isc-dhcpd.sh.sample,v
retrieving revision 1.10
diff -u -I$Id.*$ -I$.+BSD.*$ -r1.10 isc-dhcpd.sh.sample
--- files/isc-dhcpd.sh.sample	13 Oct 2004 00:17:49 -0000	1.10
+++ files/isc-dhcpd.sh.sample	16 Oct 2004 01:15:20 -0000
@@ -443,7 +443,7 @@
 {
 	if checkyesno paranoia && checkyesno dhcpd_chroot_enable; then
 		safe_mkdir ${_dhcpd_rootdir} ${_dhcpd_devdir}/_ ${_dhcpd_confdir}
-		safe_rmdir ${_dhcpd_devdir}/_	# /_, so, .../dev is root owned.
+		# XXX /_ hack! so, .../dev is root owned.
 		if checkyesno dhcpd_devfs_enable; then
 			safe_mount ${_dhcpd_devdir}
 		else
@@ -540,7 +540,7 @@
 		safe_remove ${_dhcpd_conffile}
 		if checkyesno dhcpd_devfs_enable; then
 			safe_umount ${_dhcpd_devdir}
-			safe_rmdir ${_dhcpd_devdir}
+			safe_rmdir ${_dhcpd_devdir}/_ # XXX /_ hack!
 		else
 			safe_remove ${_dhcpd_devdir}
 		fi

Cyrille Lefevre
-- 
mailto:cyrille.lefevre@laposte.net
Comment 5 Cyrille Lefevre 2004-10-16 02:47:02 UTC
forgot the following unrelated fix :

Index: files/isc-dhcpd.sh.sample
===================================================================
RCS file: /home/ncvs/ports/net/isc-dhcp3-server/files/isc-dhcpd.sh.sample,v
retrieving revision 1.10
diff -u -I$Id.*$ -I$.+BSD.*$ -r1.10 isc-dhcpd.sh.sample
--- files/isc-dhcpd.sh.sample	13 Oct 2004 00:17:49 -0000	1.10
+++ files/isc-dhcpd.sh.sample	16 Oct 2004 01:46:31 -0000
@@ -268,7 +268,7 @@
 	local _user _group _home _shell _gecos
 
 	_user=$1 _group=$2 _gecos=${3:-"& daemon"}
-	_home=${4:-/nonexistent} _shell=${5:-/sbin/nologin}
+	_home=${4:-/nonexistent} _shell=${5:-/usr/sbin/nologin}
 
 	if [ -n "${_group}" ]; then
 		if pw group show ${_group} 2>/dev/null; then

Cyrille Lefevre
-- 
mailto:cyrille.lefevre@laposte.net
Comment 6 Pav Lucistnik freebsd_committer freebsd_triage 2004-10-16 11:07:06 UTC
V so, 16. 10. 2004 v 03:47, Cyrille Lefevre pí¹e:

> forgot the following unrelated fix :
> 
> Index: files/isc-dhcpd.sh.sample
> ===================================================================
> RCS file: /home/ncvs/ports/net/isc-dhcp3-server/files/isc-dhcpd.sh.sample,v
> retrieving revision 1.10
> diff -u -I$Id.*$ -I$.+BSD.*$ -r1.10 isc-dhcpd.sh.sample
> --- files/isc-dhcpd.sh.sample	13 Oct 2004 00:17:49 -0000	1.10
> +++ files/isc-dhcpd.sh.sample	16 Oct 2004 01:46:31 -0000
> @@ -268,7 +268,7 @@
>  	local _user _group _home _shell _gecos
>  
>  	_user=$1 _group=$2 _gecos=${3:-"& daemon"}
> -	_home=${4:-/nonexistent} _shell=${5:-/sbin/nologin}
> +	_home=${4:-/nonexistent} _shell=${5:-/usr/sbin/nologin}
>  
>  	if [ -n "${_group}" ]; then
>  		if pw group show ${_group} 2>/dev/null; then


What about FreeBSD 4.x users who still have /sbin/nologin?
Should this change be conditional on ${OSVERSION} perhaps?

-- 
Pav Lucistnik <pav@oook.cz>
              <pav@FreeBSD.org>

Me go and see Elves and all! Hooray!
Comment 7 cyrille.lefevre 2004-10-17 03:42:14 UTC
"Pav Lucistnik" <pav@FreeBSD.org> wrote:
V so, 16. 10. 2004 v 03:47, Cyrille Lefevre píse:
[snip]
> What about FreeBSD 4.x users who still have /sbin/nologin?
> Should this change be conditional on ${OSVERSION} perhaps?


ok, ignore this for instance, I'll post a new follow-up later.
however, do you know the OSVERSION to use ? thanks.

Cyrille Lefevre.
-- 
home: mailto:cyrille.lefevre@laposte.net
Comment 8 Cyrille Lefevre 2004-10-17 03:53:41 UTC
On Oct 16, 2004 12:07:06 pm +0200, Pav Lucistnik wrote:

hi, how about this patch ?

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/net/isc-dhcp3-server/Makefile,v
retrieving revision 1.103
diff -u -I$Id.*$ -I$.+BSD.*$ -r1.103 Makefile
--- Makefile	13 Oct 2004 00:17:49 -0000	1.103
+++ Makefile	17 Oct 2004 02:52:23 -0000
@@ -161,6 +161,11 @@
 .endif
 REINPLACE_SUB=	PREFIX=${PREFIX}
 RCSCRIPTS_SUB=	PREFIX=${PREFIX} RC_SUBR=${RC_SUBR}
+.if ${OSVERSION} >= 502100
+RCSCRIPTS_SUB+=	NOLOGIN=/usr/sbin/nologin
+.else
+RCSCRIPTS_SUB+=	NOLOGIN=/sbin/nologin
+.endif
 .if !defined(WITHOUT_DHCP_PARANOIA)
 RCSCRIPTS_SUB+=	PARANOIA=YES
 .else
Index: files/isc-dhcpd.sh.sample
===================================================================
RCS file: /home/ncvs/ports/net/isc-dhcp3-server/files/isc-dhcpd.sh.sample,v
retrieving revision 1.10
diff -u -I$Id.*$ -I$.+BSD.*$ -r1.10 isc-dhcpd.sh.sample
--- files/isc-dhcpd.sh.sample	13 Oct 2004 00:17:49 -0000	1.10
+++ files/isc-dhcpd.sh.sample	17 Oct 2004 02:52:24 -0000
@@ -268,7 +268,7 @@
 	local _user _group _home _shell _gecos
 
 	_user=$1 _group=$2 _gecos=${3:-"& daemon"}
-	_home=${4:-/nonexistent} _shell=${5:-/sbin/nologin}
+	_home=${4:-/nonexistent} _shell=${5:-%%NOLOGIN%%}
 
 	if [ -n "${_group}" ]; then
 		if pw group show ${_group} 2>/dev/null; then

Cyrille Lefevre
-- 
mailto:cyrille.lefevre@laposte.net
Comment 9 Pav Lucistnik freebsd_committer freebsd_triage 2004-10-17 13:53:19 UTC
V ne, 17. 10. 2004 v 04:53, Cyrille Lefevre pí¹e:

> hi, how about this patch ?


This looks fine.

-- 
Pav Lucistnik <pav@oook.cz>
              <pav@FreeBSD.org>

A spoonful of curry, garlic and mustard helps the medicine go down...
and come straight back up again.
  -- JLE on #angband
Comment 10 Pav Lucistnik freebsd_committer freebsd_triage 2004-10-17 13:55:01 UTC
State Changed
From-To: feedback->closed

Committed maintainer's version of patch.