mirror of
https://github.com/univention/univention-domain-join.git
synced 2025-10-26 11:27:12 +00:00
fix[utils]: Fix name_is_resolvable()
- `gethostbyaddr()` works with IPv4 and IPv6, but requires a valid DNS-PTR-RR. - `gethostbyname()` only works with IPv4 Use `getaddrinfo()` instead which works with both IPv4 and IPv6 and also resolved the name in the right direction only requiting a DNS-A- or AAAA-RR. This should resolve several MRs proposing the wrong fix: - https://github.com/univention/univention-domain-join/pull/4 - https://github.com/univention/univention-domain-join/pull/2 - https://forge.univention.org/bugzilla/show_bug.cgi?id=52726 Bug #52726
This commit is contained in:
parent
acac9bdd01
commit
229cb6fd95
@ -47,7 +47,6 @@ def execute_as_root(func):
|
||||
|
||||
def name_is_resolvable(name):
|
||||
try:
|
||||
socket.gethostbyaddr(name)
|
||||
return True
|
||||
return bool(socket.getaddrinfo(name, 22, socket.AF_UNSPEC, socket.SOCK_STREAM, socket.IPPROTO_TCP))
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
Loading…
Reference in New Issue
Block a user