summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2018-05-16 16:51:34 +0100
committerNoel Power <npower@samba.org>2018-05-17 11:31:29 +0200
commite7144f2e115f7d446de880a5680c2f2f02dd9467 (patch)
tree5f31a0ebd675a94bd341f25d068a78589d1b1a33 /python
parent75e1019f6162814eae3edb050d41784179cfa8ab (diff)
downloadsamba-e7144f2e115f7d446de880a5680c2f2f02dd9467.tar.gz
samba-e7144f2e115f7d446de880a5680c2f2f02dd9467.tar.bz2
samba-e7144f2e115f7d446de880a5680c2f2f02dd9467.zip
python/samba/netcmd: net.change_password should be passed string
password param which in python2 (is str) is incorrectly encoded before passing to net.change_password. python2 - password is either unicode or str, if str we should decode to get unicode (and then pass to net.change_password). python3 - password is either str or bytes, if bytes then decode (and pass as 'str' to net.change_password). Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r--python/samba/netcmd/user.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py
index 4009d6304bf..f211b5158ce 100644
--- a/python/samba/netcmd/user.py
+++ b/python/samba/netcmd/user.py
@@ -54,7 +54,7 @@ from samba.netcmd import (
SuperCommand,
Option,
)
-
+from samba.compat import text_type
try:
import io
@@ -713,7 +713,9 @@ class cmd_user_password(Command):
self.outf.write("Sorry, passwords do not match.\n")
try:
- net.change_password(password.encode('utf-8'))
+ if not isinstance(password, text_type):
+ password = password.decode('utf8')
+ net.change_password(password)
except Exception as msg:
# FIXME: catch more specific exception
raise CommandError("Failed to change password : %s" % msg)