Merge pull request #41918 from rongzeng54/develop

force glibc to re-read resolv.conf for fix unexpected error dns parsing
This commit is contained in:
Mike Place 2017-06-23 11:39:20 -05:00 committed by GitHub
commit aff5d76081
2 changed files with 14 additions and 3 deletions

View File

@ -763,6 +763,14 @@ def ip_bracket(addr):
return addr
def refresh_dns():
'''
issue #21397: force glibc to re-read resolv.conf
'''
if HAS_RESINIT:
res_init()
@jinja_filter('dns_check')
def dns_check(addr, port, safe=False, ipv6=None):
'''
@ -775,9 +783,7 @@ def dns_check(addr, port, safe=False, ipv6=None):
lookup = addr
seen_ipv6 = False
try:
# issue #21397: force glibc to re-read resolv.conf
if HAS_RESINIT:
res_init()
refresh_dns()
hostnames = socket.getaddrinfo(
addr, None, socket.AF_UNSPEC, socket.SOCK_STREAM
)

View File

@ -15,6 +15,7 @@ import os.path
import pprint
import socket
import yaml
import re
import ssl
try:
@ -157,6 +158,10 @@ def query(url,
if not backend:
backend = opts.get('backend', 'tornado')
match = re.match(r'https?://((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)($|/)', url)
if not match:
salt.utils.refresh_dns()
if backend == 'requests':
if HAS_REQUESTS is False:
ret['error'] = ('http.query has been set to use requests, but the '