[PATCH] Handle missing nsswitch.conf, fallback files,dns

Phil Pennock gnupg-devel at spodhuis.org
Thu Jan 19 07:21:42 CET 2017


From: Phil Pennock <phil at pennock-tech.com>

Signed-off-by: Phil Pennock <phil at pennock-tech.com>
---
 dirmngr/dns-stuff.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/dirmngr/dns-stuff.c b/dirmngr/dns-stuff.c
index 28ecb18..eae888b 100644
--- a/dirmngr/dns-stuff.c
+++ b/dirmngr/dns-stuff.c
@@ -478,7 +478,16 @@ libdns_init (void)
       if (err)
         {
           log_error ("failed to load '%s': %s\n", fname, gpg_strerror (err));
-          goto leave;
+          /* not fatal, nsswitch.conf is not used on all systems; assume
+           * classic behavior instead.  Our dns library states "bf" which tries
+           * DNS then Files, which is not classic; FreeBSD
+           * /usr/src/lib/libc/net/gethostnamadr.c defines default_src[] which
+           * is Files then DNS, which is. */
+          log_debug ("dns: fallback resolution order, files then DNS");
+          ld.resolv_conf->lookup[0] = 'f';
+          ld.resolv_conf->lookup[1] = 'b';
+          ld.resolv_conf->lookup[2] = '\0';
+          err = GPG_ERR_NO_ERROR;
         }
 
 #endif /* Unix */
-- 
1.9.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: </pipermail/attachments/20170119/c5027c0e/attachment.sig>


More information about the Gnupg-devel mailing list