URL: https://github.com/freeipa/freeipa/pull/845 Author: stlaz Title: #845: ipadiscovery: Return realm as a string Action: synchronized
To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/845/head:pr845 git checkout pr845
From 302600aafdf467ea37f387720829cd59e42618d5 Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka <slazn...@redhat.com> Date: Fri, 2 Jun 2017 08:05:02 +0200 Subject: [PATCH 1/2] ipadiscovery: Return realm as a string We don't have a use for realm as a bytes instance, return it as a string, otherwise there's a use of str() on bytes in py3. https://pagure.io/freeipa/issue/4985 --- ipaclient/install/ipadiscovery.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ipaclient/install/ipadiscovery.py b/ipaclient/install/ipadiscovery.py index c929a35a80..bff79b007e 100644 --- a/ipaclient/install/ipadiscovery.py +++ b/ipaclient/install/ipadiscovery.py @@ -531,7 +531,13 @@ def ipadnssearchkrbrealm(self, domain=None): for answer in answers: root_logger.debug("DNS record found: %s", answer) if answer.strings: - realm = answer.strings[0] + try: + realm = answer.strings[0].decode('utf-8') + except UnicodeDecodeError as e: + root_logger.debug( + 'A TXT record cannot be decoded as UTF-8: {err}' + .format(err=e)) + continue if realm: break return realm From d162858820777f784cdfad1e1abbee5e6d213216 Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka <slazn...@redhat.com> Date: Fri, 2 Jun 2017 10:47:17 +0200 Subject: [PATCH 2/2] Docstring+refactor of IPADiscovery.ipadnssearchkrbrealm() Added a docstring and made a tiny miny refactor to IPADiscovery.ipadnssearchkrbrealm() --- ipaclient/install/ipadiscovery.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ipaclient/install/ipadiscovery.py b/ipaclient/install/ipadiscovery.py index bff79b007e..d9ef191085 100644 --- a/ipaclient/install/ipadiscovery.py +++ b/ipaclient/install/ipadiscovery.py @@ -514,7 +514,11 @@ def ipadns_search_srv(self, domain, srv_record_name, default_port, return servers def ipadnssearchkrbrealm(self, domain=None): - realm = None + """ + :param domain: Domain to be searched in + :returns: string of a realm found in a TXT record + None if no realm was found + """ if not domain: domain = self.domain # now, check for a Kerberos realm the local host or domain is in @@ -528,6 +532,7 @@ def ipadnssearchkrbrealm(self, domain=None): root_logger.debug("DNS record not found: %s", e.__class__.__name__) answers = [] + realm = None for answer in answers: root_logger.debug("DNS record found: %s", answer) if answer.strings: @@ -539,8 +544,7 @@ def ipadnssearchkrbrealm(self, domain=None): .format(err=e)) continue if realm: - break - return realm + return realm def ipadnssearchkrbkdc(self, domain=None): kdc = None
_______________________________________________ FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org