c8cd03
From 3acf8e092f95233bc3d854e161569487dce83ba2 Mon Sep 17 00:00:00 2001
c8cd03
From: Mark Andrews <marka@isc.org>
c8cd03
Date: Fri, 3 Feb 2017 14:22:03 +1100
c8cd03
Subject: [PATCH] 4567. [port] Call getprotobyname and getservbyname prior to
c8cd03
 calling chroot so that shared libraries get loaded. [RT #44537]
c8cd03
c8cd03
---
c8cd03
 lib/isc/unix/dir.c | 10 ++++++++++
c8cd03
 1 file changed, 10 insertions(+)
c8cd03
c8cd03
diff --git a/lib/isc/unix/dir.c b/lib/isc/unix/dir.c
c8cd03
index 0d64778..ee80f41 100644
c8cd03
--- a/lib/isc/unix/dir.c
c8cd03
+++ b/lib/isc/unix/dir.c
c8cd03
@@ -31,6 +31,7 @@
c8cd03
 
c8cd03
 #include <isc/dir.h>
c8cd03
 #include <isc/magic.h>
c8cd03
+#include <isc/netdb.h>
c8cd03
 #include <isc/string.h>
c8cd03
 #include <isc/util.h>
c8cd03
 
c8cd03
@@ -172,6 +173,15 @@ isc_dir_chroot(const char *dirname) {
c8cd03
 	REQUIRE(dirname != NULL);
c8cd03
 
c8cd03
 #ifdef HAVE_CHROOT
c8cd03
+	/*
c8cd03
+	 * Try to use getservbyname and getprotobyname before chroot.
c8cd03
+	 * If WKS records are used in a zone under chroot, Name Service Switch
c8cd03
+	 * may fail to load library in chroot.
c8cd03
+	 * Do not report errors if it fails, we do not need any result now.
c8cd03
+	 */
c8cd03
+	if (getprotobyname("udp"))
c8cd03
+		(void)getservbyname("domain", "udp");
c8cd03
+
c8cd03
 	if (chroot(dirname) < 0 || chdir("/") < 0)
c8cd03
 		return (isc__errno2result(errno));
c8cd03
 
c8cd03
-- 
c8cd03
2.9.3
c8cd03