NetBSD Problem Report #42306

From prlw1@inf.phy.cam.ac.uk  Wed Nov 11 14:54:16 2009
Return-Path: <prlw1@inf.phy.cam.ac.uk>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 4968563B8CD
	for <gnats-bugs@gnats.netbsd.org>; Wed, 11 Nov 2009 14:54:16 +0000 (UTC)
Message-Id: <E1N8EaK-0004Xv-Di@quartz.inf.phy.cam.ac.uk>
Date: Wed, 11 Nov 2009 14:54:12 +0000
From: prlw1@cam.ac.uk
Sender: Patrick Welche <prlw1@inf.phy.cam.ac.uk>
Reply-To: prlw1@inf.phy.cam.ac.uk
To: gnats-bugs@gnats.NetBSD.org
Subject: permissions on /var/chroot/named/etc/namedb
X-Send-Pr-Version: 3.95

>Number:         42306
>Category:       misc
>Synopsis:       chrooted named can't write to namedb
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    misc-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 11 14:55:01 +0000 2009
>Closed-Date:    Mon May 30 23:28:26 +0000 2016
>Last-Modified:  Mon May 30 23:28:26 +0000 2016
>Originator:     Patrick Welche
>Release:        NetBSD 5.99.22
>Organization:

>Environment:
NetBSD-current
>Description:
Our default etc/named.conf has:

        directory "/etc/namedb";

rather than /etc/namedb/cache, and I would leave that as I think /etc/namedb is the
more usual choice.

Our etc/mtree/special file however has:

y/var/chroot/named/etc/namedb   type=dir  mode=0755
./var/chroot/named/etc/namedb/cache     type=dir mode=0775 uname=named gname=named

If you run named in a chroot, named won't be able to write to etc/namedb.
>How-To-Repeat:
The actual surprise was setting up the chroot, with a
chown named:named /var/chroot/named/etc/namedb
and then being surprised after a build at the logs filling up with
 named[164]: general: error: dumping master file: tmp-B6BVu5A1mN: open: permission denied
because I let /etc/mtree/special change the ownership as a result of the build.
>Fix:

Index: special
===================================================================
RCS file: /cvsroot/src/etc/mtree/special,v
retrieving revision 1.131
diff -u -r1.131 special
--- special	29 Sep 2009 23:56:27 -0000	1.131
+++ special	11 Nov 2009 14:53:02 -0000
@@ -378,8 +378,7 @@
 ./var/chroot/named		type=dir  mode=0755
 ./var/chroot/named/dev		type=dir  mode=0755
 ./var/chroot/named/etc		type=dir  mode=0755
-./var/chroot/named/etc/namedb	type=dir  mode=0755
-./var/chroot/named/etc/namedb/cache	type=dir mode=0775 uname=named gname=named
+./var/chroot/named/etc/namedb	type=dir  mode=0775 uname=named gname=named
 ./var/chroot/named/usr		type=dir  mode=0755
 ./var/chroot/named/usr/libexec	type=dir  mode=0755
 ./var/chroot/named/var		type=dir  mode=0755

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: reed@NetBSD.org
State-Changed-When: Mon, 30 May 2016 23:28:26 +0000
State-Changed-Why:
The ISC way is to use the "file" statement within the "zone" statement
to set the relative directory in the chroot, like:
    file "sl/example.net";
This example is from the BIND FAQ.
We could add comments about it to the etc/named.conf (NetBSD example)
if is still concern.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.