NetBSD Problem Report #49380

From kamada@nanohz.org  Tue Nov 11 11:30:49 2014
Return-Path: <kamada@nanohz.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id DC2ECA668F
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 11 Nov 2014 11:30:49 +0000 (UTC)
Message-Id: <20141111203046CJ%kamada@nanohz.org>
Date: Tue, 11 Nov 2014 20:30:46 +0900
From: KAMADA Ken'ichi <kamada@nanohz.org>
To: gnats-bugs@NetBSD.org
Cc: kamada@nanohz.org
Subject: ntpd_chrootdir does not work on NetBSD 7.0_BETA

>Number:         49380
>Category:       bin
>Synopsis:       ntpd_chrootdir does not work on NetBSD 7.0_BETA
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 11 11:35:00 +0000 2014
>Closed-Date:    Thu May 26 04:48:50 +0000 2022
>Last-Modified:  Thu May 26 04:48:50 +0000 2022
>Originator:     KAMADA Ken'ichi
>Release:        NetBSD 7.0_BETA
>Organization:
>Environment:
System: NetBSD host.example.org 7.0_BETA NetBSD 7.0_BETA (GENERIC) #21: Mon Oct 27 20:43:39 JST 2014 user@host.example.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
If ntpd_chrootdir is set in /etc/rc.conf, ntpd fails to resolve
host names and does not establish associations.  The new ntpd
imported in December 2013 seems to defer name resolution, and
it moves on to chroot() without waiting the completion.

>How-To-Repeat:
With the default /etc/ntp.conf, do the following.

# grep ntpd /etc/rc.conf
ntpd=YES
ntpd_chrootdir="/var/chroot/ntpd"

# ps ax | grep ntpd
 4606 ?     Ss   0:00.03 /usr/sbin/ntpd -u ntpd:ntpd -i /var/chroot/ntpd -p /va
27866 ?     S    0:00.00 /usr/sbin/ntpd -u ntpd:ntpd -i /var/chroot/ntpd -p /va

# ntpq -p
No association ID's returned

>Fix:
Index: distrib/sets/lists/base/mi
===================================================================
RCS file: /cvsroot/src/distrib/sets/lists/base/mi,v
retrieving revision 1.1087
diff -u -r1.1087 mi
--- distrib/sets/lists/base/mi	10 Aug 2014 17:32:54 -0000	1.1087
+++ distrib/sets/lists/base/mi	10 Nov 2014 15:42:36 -0000
@@ -5670,6 +5670,7 @@
 ./var/chroot/named/var/tmp			base-bind-root
 ./var/chroot/ntpd				base-ntp-root
 ./var/chroot/ntpd/dev				base-ntp-root
+./var/chroot/ntpd/etc				base-ntp-root
 ./var/chroot/ntpd/var				base-ntp-root
 ./var/chroot/ntpd/var/db			base-ntp-root
 ./var/chroot/ntpd/var/run			base-ntp-root
Index: etc/mtree/NetBSD.dist.base
===================================================================
RCS file: /cvsroot/src/etc/mtree/NetBSD.dist.base,v
retrieving revision 1.139
diff -u -r1.139 NetBSD.dist.base
--- etc/mtree/NetBSD.dist.base	10 Aug 2014 17:32:54 -0000	1.139
+++ etc/mtree/NetBSD.dist.base	10 Nov 2014 15:42:36 -0000
@@ -1257,6 +1257,7 @@
 ./var/chroot/named/var/tmp	mode=01775 gname=named
 ./var/chroot/ntpd
 ./var/chroot/ntpd/dev
+./var/chroot/ntpd/etc
 ./var/chroot/ntpd/var
 ./var/chroot/ntpd/var/db	mode=0775 gname=ntpd
 ./var/chroot/ntpd/var/run	mode=0775 gname=ntpd
Index: etc/mtree/special
===================================================================
RCS file: /cvsroot/src/etc/mtree/special,v
retrieving revision 1.148
diff -u -r1.148 special
--- etc/mtree/special	5 Aug 2014 07:34:52 -0000	1.148
+++ etc/mtree/special	10 Nov 2014 15:42:36 -0000
@@ -391,6 +391,7 @@
 ./var/chroot/named/var/tmp	type=dir  mode=01775 gname=named
 ./var/chroot/ntpd		type=dir  mode=0755
 ./var/chroot/ntpd/dev		type=dir  mode=0755
+./var/chroot/ntpd/etc		type=dir  mode=0755
 ./var/chroot/ntpd/var		type=dir  mode=0755
 ./var/chroot/ntpd/var/db	type=dir  mode=0775 gname=ntpd
 ./var/chroot/ntpd/var/run	type=dir  mode=0775 gname=ntpd
Index: etc/rc.d/ntpd
===================================================================
RCS file: /cvsroot/src/etc/rc.d/ntpd,v
retrieving revision 1.14
diff -u -r1.14 ntpd
--- etc/rc.d/ntpd	4 Dec 2012 16:38:40 -0000	1.14
+++ etc/rc.d/ntpd	10 Nov 2014 15:42:36 -0000
@@ -49,6 +49,11 @@
 		( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" )
 	fi
 	ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift
+	for f in resolv.conf services; do
+		if ! cmp -s /etc/$f "${ntpd_chrootdir}/etc/$f"; then
+			cp -p /etc/$f "${ntpd_chrootdir}/etc/$f"
+		fi
+	done

 	#	Change run_rc_commands()'s internal copy of $ntpd_flags
 	#

>Release-Note:

>Audit-Trail:
From: Matthew Mondor <mm_lists@pulsar-zone.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/49380: ntpd_chrootdir does not work on NetBSD 7.0_BETA
Date: Wed, 14 Oct 2015 19:30:03 -0400

 The netbsd-6 branch also seems to recently be affected.  Copying the
 resolv.conf file into the chroot (which was the default configuration
 if I remember) finally permits it to access peers.  It was quite
 puzzling to see ntpd suddenly fail to work.  In the rare cases where
 this occurred before, it was because of a too large time discrepency,
 which could be fixed using an explicit ntpdate command before
 restarting ntpd.  This obviously didn't work this time.

 If two different comments make it on the PR, I apologize, I forgot to
 prefix the subject with Re: when posting the previous, less complete,
 one.

 Thanks,

 -- 
 Matt

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49380 CVS commit: src
Date: Mon, 23 Nov 2015 14:56:48 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Mon Nov 23 19:56:47 UTC 2015

 Modified Files:
 	src/distrib/sets/lists/base: mi
 	src/etc/mtree: NetBSD.dist.base special
 	src/etc/rc.d: ntpd

 Log Message:
 PR/49380: KAMADA Ken'ichi: ntpd_chrootdir does not work on NetBSD 7.0_BETA
 Provide /etc/resolv.conf so that it can resolve names. This is needed because
 of deferred name resolution.
 XXX: pullup -7


 To generate a diff of this commit:
 cvs rdiff -u -r1.1117 -r1.1118 src/distrib/sets/lists/base/mi
 cvs rdiff -u -r1.149 -r1.150 src/etc/mtree/NetBSD.dist.base
 cvs rdiff -u -r1.152 -r1.153 src/etc/mtree/special
 cvs rdiff -u -r1.15 -r1.16 src/etc/rc.d/ntpd

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: pgoyette@NetBSD.org
State-Changed-When: Wed, 01 Jun 2016 02:51:06 +0000
State-Changed-Why:
Committed by christos@ on Nov 23 19:56:47 UTC 2015


State-Changed-From-To: closed->open
State-Changed-By: snj@NetBSD.org
State-Changed-When: Wed, 01 Jun 2016 17:34:46 +0000
State-Changed-Why:
Fixed on HEAD, but never made it into 7.0.


State-Changed-From-To: open->needs-pullups
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 16 Jun 2018 23:45:40 +0000
State-Changed-Why:
was supposed to get into -7


State-Changed-From-To: needs-pullups->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Thu, 26 May 2022 04:48:50 +0000
State-Changed-Why:
never made it into -7, oh well


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.