From 6aa22000cd87f9bcb2df1ea0af1c0d60df626c0b Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Fri, 18 Aug 2017 02:03:22 +0200 Subject: [PATCH] [fix] handle post-install --- moulinette/authenticators/ldap.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/moulinette/authenticators/ldap.py b/moulinette/authenticators/ldap.py index 0a15c55b..ea874605 100644 --- a/moulinette/authenticators/ldap.py +++ b/moulinette/authenticators/ldap.py @@ -96,10 +96,14 @@ class Authenticator(BaseAuthenticator): return '{CRYPT}' + crypt.crypt(str(password), salt) hashed_password = self.search("cn=admin,dc=yunohost,dc=org", - attrs=["userPassword"])[0]["userPassword"][0] + attrs=["userPassword"])[0] + + # post-install situation, password is not already set + if "userPassword" not in hashed_password or not hashed_password["userPassword"]: + return # we aren't using sha-512 but something else that is weaker, proceed to upgrade - if not hashed_password.startswith("{CRYPT}$6$"): + if not hashed_password["userPassword"][0].startswith("{CRYPT}$6$"): self.update("cn=admin", { "userPassword": _hash_user_password(password), })