summaryrefslogtreecommitdiff
path: root/python/samba/provision
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2018-04-27 15:11:54 +0100
committerAndrew Bartlett <abartlet@samba.org>2018-09-03 03:22:23 +0200
commit252950ac08554d7c86a5cfc2c7fbc626c4c5f863 (patch)
treef1872e44699289ba5714144b6cc3668a80615a1c /python/samba/provision
parent7a2df705f6a834194e2e50210bf36a0d425a8fa1 (diff)
downloadsamba-252950ac08554d7c86a5cfc2c7fbc626c4c5f863.tar.gz
python/samba/netcmd: Fix password usage for py2/py3 compatability
getpass returns str (e.g. bytes) in python2 and str (unicode) in py3. Adapt code to so we don't do illegal things (like try and decode) a string in python3 Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python/samba/provision')
-rw-r--r--python/samba/provision/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/python/samba/provision/__init__.py b/python/samba/provision/__init__.py
index 44434a215ff..9ecb2018060 100644
--- a/python/samba/provision/__init__.py
+++ b/python/samba/provision/__init__.py
@@ -28,6 +28,7 @@ __docformat__ = "restructuredText"
from samba.compat import urllib_quote
from samba.compat import string_types
+from samba.compat import binary_type
from base64 import b64encode
import errno
import os
@@ -2313,7 +2314,8 @@ def provision(logger, session_info, smbconf=None,
adminpass = samba.generate_random_password(12, 32)
adminpass_generated = True
else:
- adminpass = unicode(adminpass, 'utf-8')
+ if isinstance(adminpass, binary_type):
+ adminpass = adminpass.decode('utf-8')
adminpass_generated = False
if samdb_fill == FILL_FULL: