[nsd-users] nsd looses timezone after chroot

Camiel Dobbelaar cd at sentia.nl
Thu Sep 20 22:25:05 CEST 2012


After chrooting the timezone is wrong in the logging:

See (unpatched daemon ran first):
Sep 20 19:53:11 xmts nsd[32253]: nsd started (NSD 3.2.13), pid 32253
Sep 20 19:54:16 xmts nsd[32253]: signal received, shutting down...
Sep 20 21:54:18 xmts nsd[13502]: nsd started (NSD 3.2.13), pid 13502

chdir() after chroot() is good practice.

Note that unbound has the tzet() but not the chdir().  But I guess the 
unbound devs read this list too?  :-)

Regards,
Cam


(diff is against the OpenBSD tree)

Index: nsd.c
===================================================================
RCS file: /cvs/src/usr.sbin/nsd/nsd.c,v
retrieving revision 1.12
diff -u -p -r1.12 nsd.c
--- nsd.c	9 Jul 2012 21:56:41 -0000	1.12
+++ nsd.c	20 Sep 2012 20:01:24 -0000
@@ -1083,7 +1083,8 @@ main(int argc, char *argv[])
 		nsd.options->xfrdfile += l;
 		nsd.options->difffile += l;
 
-		if (chroot(nsd.chrootdir)) {
+		tzset();
+		if (chroot(nsd.chrootdir) != 0 || chdir("/") != 0) {
 			log_msg(LOG_ERR, "unable to chroot: %s", strerror(errno));
 			exit(1);
 		}



More information about the nsd-users mailing list