nsd 3.0.1 + chroot() = fail to write xfrdfile

Koh-ichi Ito kohi at bbtower.co.jp
Tue Sep 26 07:59:56 UTC 2006


Hello,

I found that nsd 3.0.1 invoked with -t option fails to write
xfrdfile at least exit time.

I guess that the reason is that the pathname of chroot()
jail is NOT striped from pathname of xfrdfile which is done
for dbfile and pidfile in server.c::server_init().

The following quick hack seems to fixes the problem.

*** nsd-3.0.1/server.c-dist     Wed Aug 23 15:09:57 2006
--- nsd-3.0.1/server.c  Tue Sep 26 16:50:08 2006
***************
*** 443,448 ****
--- 443,451 ----
  
                nsd->dbfile += l;
                nsd->pidfile += l;
+               if (nsd->options->xfrdfile) {
+                       nsd->options->xfrdfile += l;
+               }
  
                if (chroot(nsd->chrootdir)) {
                        log_msg(LOG_ERR, "unable to chroot: %s", strerror(errno));



Environment:
 configure:
kohi at alphonse[74]% cat nsd-3.0.1/do-configure.sh 
#!/bin/sh

exec `dirname $0`/configure \
        --prefix=/u1/nsd-3.0.1 \
        --with-configdir=/u1/nsd3/etc/nsd \
        --with-nsd_conf_file=/u1/nsd3/etc/nsd/nsd.conf \
        --with-pidfile=/u1/nsd3/var/run/nsd.pid \
        --with-dbfile=/u1/nsd3/var/db/nsd.db \
        --with-zonesdir=/u1/nsd3/etc/nsd/namedb \
        --with-facility=LOG_LOCAL3

 nsd.conf:

type95# cat /u1/nsd3/etc/nsd/nsd.conf
#
#       $id$
#
server:
        ip-address: 10.2.0.3
        chroot: "/u1/nsd3"
        xfrdfile: "/u1/nsd3/var/db/xfrd.state"

zone:
        name: "hoge"
        zonefile: "master/hoge"
        provide-xfr: 127.0.0.1 NOKEY

 log:
	# PID 33265/33266 is without this patch.
Sep 26 16:55:10 type95 nsd[33265]: nsd started (NSD 3.0.1), pid 33265
Sep 26 16:55:13 type95 nsd[33265]: signal received, shutting down...
Sep 26 16:55:13 type95 nsd[33266]: xfrd: Could not open file /u1/nsd3/var/db/xfrd.state for writing: No such file or directory

	# PID 33279 is with this patch.
Sep 26 16:55:26 type95 nsd[33279]: nsd started (NSD 3.0.1), pid 33279
Sep 26 16:55:28 type95 nsd[33279]: signal received, shutting down...
	# no 'Could not open file..." message is left.

Thanks.

						Koh-ichi Ito
						BroadBand Tower



More information about the nsd-users mailing list