From 6df6fb8efd5cfd863cef609c879dc4b838124eb6 Mon Sep 17 00:00:00 2001 From: Kload Date: Sun, 7 Jul 2013 08:52:29 +0200 Subject: [PATCH] Modify password with smbldap-passwd --- yunohost_user.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/yunohost_user.py b/yunohost_user.py index f965578e..916b409d 100644 --- a/yunohost_user.py +++ b/yunohost_user.py @@ -194,10 +194,9 @@ def user_update(username, firstname=None, lastname=None, mail=None, change_passw new_attr_dict['cn'] = new_attr_dict['displayName'] = firstname + ' ' + lastname if change_password: - char_set = string.ascii_uppercase + string.digits - salt = ''.join(random.sample(char_set,8)) - salt = '$1$' + salt + '$' - new_attr_dict['userPassword'] = '{CRYPT}' + crypt.crypt(str(change_password), salt) + pwd_changed = os.system('echo "'+ password +'\n'+ password +'" | smbldap-passwd '+ username) + if pwd_changed > 0: + raise YunoHostError(169, _("An error occured during password update")) if mail: yldap.validate_uniqueness({ 'mail': mail })