From f6a81da16f3c6e586314f369ff9b1301d17a07fa Mon Sep 17 00:00:00 2001 From: Todd Stansell Date: Wed, 25 Mar 2015 19:32:32 -0700 Subject: [PATCH] fix #21397 - force glibc to re-read resolv.conf --- salt/utils/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/salt/utils/__init__.py b/salt/utils/__init__.py index 3b89774b88..7088a513ba 100644 --- a/salt/utils/__init__.py +++ b/salt/utils/__init__.py @@ -96,6 +96,15 @@ try: except ImportError: HAS_SETPROCTITLE = False +try: + import ctypes + import ctypes.util + libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("c")) + res_init = libc.__res_init + HAS_RESINIT = True +except: + HAS_RESINIT = False + # Import salt libs import salt._compat import salt.exitcodes @@ -518,6 +527,9 @@ def dns_check(addr, safe=False, ipv6=False): ''' error = False try: + # issue #21397: force glibc to re-read resolv.conf + if HAS_RESINIT: + res_init() hostnames = socket.getaddrinfo( addr, None, socket.AF_UNSPEC, socket.SOCK_STREAM )