mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
Rewrite the `hostname mismatch' test as per GvR suggestion.
Don't assume gethostbyaddr()'s primary hostname is the same as gethostname(), or even that gethostname() can be found in the list of hosts returned by gethostbyaddr(). We do test for at least one FQDN in gethostbyaddr().
This commit is contained in:
parent
d08735a54b
commit
dbfb8d4626
1 changed files with 8 additions and 2 deletions
|
@ -12,6 +12,7 @@ from test_support import verbose
|
||||||
import socket
|
import socket
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import string
|
||||||
|
|
||||||
def missing_ok(str):
|
def missing_ok(str):
|
||||||
try:
|
try:
|
||||||
|
@ -67,14 +68,19 @@ for optional in ("AF_UNIX",
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
ip = socket.gethostbyname(hostname)
|
ip = socket.gethostbyname(hostname)
|
||||||
hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
|
hname, aliases, ipaddrs = socket.gethostbyaddr(ip)
|
||||||
|
all_host_names = [hname] + aliases
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
print hostname
|
print hostname
|
||||||
print ip
|
print ip
|
||||||
print hname, aliases, ipaddrs
|
print hname, aliases, ipaddrs
|
||||||
|
print all_host_names
|
||||||
|
|
||||||
if hostname <> hname:
|
for name in all_host_names:
|
||||||
print 'hostname mismatch'
|
if string.find(name, '.'):
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print 'FQDN not found'
|
||||||
|
|
||||||
print socket.getservbyname('telnet', 'tcp')
|
print socket.getservbyname('telnet', 'tcp')
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue