From fb2cef28da51a612d7a508cb4ef05dade6fa4b37 Mon Sep 17 00:00:00 2001 From: XiaoliChan <2209553467@qq.com> Date: Sun, 27 Aug 2023 23:53:44 +0800 Subject: [PATCH] [connection.py] bug fix in funciton 'gethost_addrinfo' Signed-off-by: XiaoliChan <2209553467@qq.com> --- cme/connection.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cme/connection.py b/cme/connection.py index 91e0d5ac..10e1ce1c 100755 --- a/cme/connection.py +++ b/cme/connection.py @@ -29,9 +29,9 @@ def gethost_addrinfo(hostname): except socket.gaierror: for res in getaddrinfo( hostname, None, AF_INET, SOCK_DGRAM, IPPROTO_IP, AI_CANONNAME): af, socktype, proto, canonname, sa = res - if canonname == "": - return sa[0] - return canonname + if not sa[0]: + return canonname + return sa[0] def requires_admin(func): def _decorator(self, *args, **kwargs): @@ -89,6 +89,7 @@ class connection(object): self.host = gethost_addrinfo(self.hostname) if self.args.kerberos: self.host = self.hostname + self.logger.info(f"Socket info: host={self.host}, hostname={self.hostname}, kerberos={ 'True' if self.args.kerberos else 'False' }") except Exception as e: self.logger.info(f"Error resolving hostname {self.hostname}: {e}") return