mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Merge pull request #37417 from isbm/isbm-network-id-generator-bugfix
Prevent theoretically possible None from being processed by getaddrinfo
This commit is contained in:
commit
26cbaebdbc
@ -117,13 +117,13 @@ def _generate_minion_id():
|
||||
hosts = DistinctList().append(socket.getfqdn()).append(platform.node()).append(socket.gethostname())
|
||||
if not hosts:
|
||||
try:
|
||||
for a_nfo in socket.getaddrinfo(hosts.first(), None, socket.AF_INET,
|
||||
for a_nfo in socket.getaddrinfo(hosts.first() or 'localhost', None, socket.AF_INET,
|
||||
socket.SOCK_RAW, socket.IPPROTO_IP, socket.AI_CANONNAME):
|
||||
if len(a_nfo) > 3:
|
||||
hosts.append(a_nfo[3])
|
||||
except socket.gaierror:
|
||||
log.warn('Cannot resolve address {addr} info via socket: {message}'.format(
|
||||
addr=hosts.first(), message=socket.gaierror)
|
||||
addr=hosts.first() or 'localhost (N/A)', message=socket.gaierror)
|
||||
)
|
||||
# Universal method for everywhere (Linux, Slowlaris, Windows etc)
|
||||
for f_name in ['/etc/hostname', '/etc/nodename', '/etc/hosts',
|
||||
|
Loading…
Reference in New Issue
Block a user