URL: https://github.com/freeipa/freeipa/pull/898 Author: MartinBasti Title: #898: py3: ipa-dnskeysyncd: fix bytes issues Action: opened
PR body: """ LDAP client returns values as bytes, thus ipa-dnskeysyncd must work with bytes properly. https://pagure.io/freeipa/issue/4985 """ To pull the PR as Git branch: git remote add ghfreeipa https://github.com/freeipa/freeipa git fetch ghfreeipa pull/898/head:pr898 git checkout pr898
From e1205de4ff16b796529b581f38a8a66a82b27504 Mon Sep 17 00:00:00 2001 From: Martin Basti <mba...@redhat.com> Date: Mon, 26 Jun 2017 14:23:44 +0200 Subject: [PATCH] py3: ipa-dnskeysyncd: fix bytes issues LDAP client returns values as bytes, thus ipa-dnskeysyncd must work with bytes properly. https://pagure.io/freeipa/issue/4985 --- ipaserver/dnssec/keysyncer.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ipaserver/dnssec/keysyncer.py b/ipaserver/dnssec/keysyncer.py index a8dc92354e..c3a382ec20 100644 --- a/ipaserver/dnssec/keysyncer.py +++ b/ipaserver/dnssec/keysyncer.py @@ -42,7 +42,7 @@ def _get_objclass(self, attrs): Given set of attributes has to have exactly one supported object class. """ - supported_objclasses = set(['idnszone', 'idnsseckey', 'ipk11publickey']) + supported_objclasses = {b'idnszone', b'idnsseckey', b'ipk11publickey'} present_objclasses = set([o.lower() for o in attrs[OBJCLASS_ATTR]]).intersection(supported_objclasses) assert len(present_objclasses) == 1, attrs[OBJCLASS_ATTR] return present_objclasses.pop() @@ -64,31 +64,31 @@ def __is_replica_pubkey(self, attrs): vals = attrs.get('ipk11label', []) if len(vals) != 1: return False - return vals[0].startswith('dnssec-replica:') + return vals[0].startswith(b'dnssec-replica:') def application_add(self, uuid, dn, newattrs): objclass = self._get_objclass(newattrs) - if objclass == 'idnszone': + if objclass == b'idnszone': self.zone_add(uuid, dn, newattrs) - elif objclass == 'idnsseckey': + elif objclass == b'idnsseckey': self.key_meta_add(uuid, dn, newattrs) - elif objclass == 'ipk11publickey' and \ + elif objclass == b'ipk11publickey' and \ self.__is_replica_pubkey(newattrs): self.hsm_master_sync() def application_del(self, uuid, dn, oldattrs): objclass = self._get_objclass(oldattrs) - if objclass == 'idnszone': + if objclass == b'idnszone': self.zone_del(uuid, dn, oldattrs) - elif objclass == 'idnsseckey': + elif objclass == b'idnsseckey': self.key_meta_del(uuid, dn, oldattrs) - elif objclass == 'ipk11publickey' and \ + elif objclass == b'ipk11publickey' and \ self.__is_replica_pubkey(oldattrs): self.hsm_master_sync() def application_sync(self, uuid, dn, newattrs, oldattrs): objclass = self._get_objclass(oldattrs) - if objclass == 'idnszone': + if objclass == b'idnszone': olddn = ldap.dn.str2dn(oldattrs['dn']) newdn = ldap.dn.str2dn(newattrs['dn']) assert olddn == newdn, 'modrdn operation is not supported' @@ -101,10 +101,10 @@ def application_sync(self, uuid, dn, newattrs, oldattrs): else: self.zone_del(uuid, olddn, oldattrs) - elif objclass == 'idnsseckey': + elif objclass == b'idnsseckey': self.key_metadata_sync(uuid, dn, oldattrs, newattrs) - elif objclass == 'ipk11publickey' and \ + elif objclass == b'ipk11publickey' and \ self.__is_replica_pubkey(newattrs): self.hsm_master_sync()
_______________________________________________ FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org