URL: https://github.com/freeipa/freeipa/pull/918
Author: abbra
 Title: #918: [WIP] dcerpc: support Python 3
Action: opened

PR body:
"""
Make 'ipa trust-add' work under Python 3. One needs patches from
https://lists.samba.org/archive/samba-technical/2017-July/121746.html
to Samba too.

Marked as WIP until Samba patches are released as part of 4.7.0-RC2.

Since we haven't switched whole ipa server environment to Python 3 yet,
following packages need to be installed to make trust code working under
Python 3:

 - python3-libsss_nss_idmap
 - python3-sss
 - python3-samba
 - python3-mod_wsgi
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/918/head:pr918
git checkout pr918
From 10787830934437e78763aec27ad94216091eced2 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <aboko...@redhat.com>
Date: Fri, 14 Jul 2017 11:24:37 +0300
Subject: [PATCH] dcerpc: support Python 3

Make 'ipa trust-add' work under Python 3. One needs patches from
https://lists.samba.org/archive/samba-technical/2017-July/121746.html
to Samba too.

Since we haven't switched whole ipa server environment to Python 3 yet,
following packages need to be installed to make trust code working under
Python 3:

 - python3-libsss_nss_idmap
 - python3-sss
 - python3-samba
 - python3-mod_wsgi
---
 ipaserver/dcerpc.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/ipaserver/dcerpc.py b/ipaserver/dcerpc.py
index d684a17cab..93e01e7457 100644
--- a/ipaserver/dcerpc.py
+++ b/ipaserver/dcerpc.py
@@ -186,7 +186,7 @@ def __init__(self):
         self.integerValue = 1
 
     def encodeControlValue(self, value=None):
-        return '0\x03\x02\x01\x01'
+        return b'0\x03\x02\x01\x01'
 
 
 class DomainValidator(object):
@@ -818,6 +818,8 @@ def __retrieve_trusted_domain_gc_list(self, domain):
 
 
 def string_to_array(what):
+    if isinstance(what, bytes):
+        return [v for v in what]
     return [ord(v) for v in what]
 
 
@@ -938,6 +940,15 @@ def retrieve_anonymously(self, remote_host,
         search_result = None
         try:
             _objtype, res = conn.search_s('', _ldap.SCOPE_BASE)[0]
+            for o in res.keys():
+                if isinstance(res[o], (list, tuple)):
+                    t = res[o]
+                    for z in range(len(t)):
+                        if isinstance(t[z], bytes):
+                            t[z] = t[z].decode('utf-8')
+                    res[o] = t
+                elif isinstance(res[o], bytes):
+                    res[o] = res[o].decode('utf-8')
             search_result = res['defaultNamingContext'][0]
             self.info['dns_hostname'] = res['dnsHostName'][0]
         except _ldap.LDAPError as e:
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to