From: Mark Andrews Date: Fri, 3 Feb 2017 03:22:03 +0000 (+1100) Subject: 4567. [port] Call getprotobyname and getservbyname prior to calling X-Git-Tag: v9.12.0a1~478 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=c550e75ade4ceb4ece96f660292799519a5c3183;p=thirdparty%2Fbind9.git 4567. [port] Call getprotobyname and getservbyname prior to calling chroot so that shared libraries get loaded. [RT #44537] --- diff --git a/CHANGES b/CHANGES index be4d0fc4168..6660f7edb22 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +4567. [port] Call getprotobyname and getservbyname prior to calling + chroot so that shared libraries get loaded. [RT #44537] + 4566. [func] Query logging now includes the ECS option if one was included in the query. [RT #44476] diff --git a/lib/isc/unix/dir.c b/lib/isc/unix/dir.c index 3fbfcaf4c2b..29a587ac2c0 100644 --- a/lib/isc/unix/dir.c +++ b/lib/isc/unix/dir.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -163,6 +164,14 @@ isc_dir_chroot(const char *dirname) { REQUIRE(dirname != NULL); #ifdef HAVE_CHROOT + /* + * Try to use getservbyname and getprotobyname before chroot. + * If WKS records are used in a zone under chroot, Name Service Switch + * may fail to load library in chroot. + * Do not report errors if it fails, we do not need any result now. + */ + getprotobyname("udp") && getservbyname("domain", "udp"); + if (chroot(dirname) < 0 || chdir("/") < 0) return (isc__errno2result(errno));