Skip to content

Commit 442f311

Browse files
Added support for search_domain into reverse lookup
1 parent 8f3853a commit 442f311

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cmapi/cmapi_server/managers/host_identity.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,13 @@ def check_hostname_rev_lookup(self, hostname: str) -> tuple[HostIdentity, bool]:
217217
logger.exception('Failed to get reverse names for %s', ip)
218218
continue
219219

220-
if normalized in reverse_names:
221-
logger.debug('Roundtrip check passed for %s: %s', hostname, ip)
222-
return identity, True
220+
for rev_name in reverse_names:
221+
# Count reverse names like "mcs1.<domain>" as a match for "mcs"
222+
# It is true because of search_domain/ndots (in /etc/resolv.conf)
223+
# Resolvers respect these options and will add them to the hostname
224+
if rev_name == normalized or rev_name.startswith(normalized + '.'):
225+
logger.debug('Roundtrip check passed for %s: %s', hostname, ip)
226+
return identity, True
223227

224228
logger.warning('Roundtrip check failed for %s', hostname)
225229
return identity, False

0 commit comments

Comments
 (0)