fix #21397 - force glibc to re-read resolv.conf

This commit is contained in:
Todd Stansell 2015-03-25 19:32:32 -07:00
parent 51c662bcf1
commit f6a81da16f

View File

@ -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
)