From 82c4357421de8a422fc3ba7df5eaa639f2ee5990 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Mon, 4 May 2020 14:00:22 +0200 Subject: [PATCH] [fix] handle new auto restart of ldap in moulinette --- src/yunohost/utils/ldap.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/yunohost/utils/ldap.py b/src/yunohost/utils/ldap.py index fd984ce56..b1f49e287 100644 --- a/src/yunohost/utils/ldap.py +++ b/src/yunohost/utils/ldap.py @@ -21,6 +21,7 @@ import os import atexit +from moulinette.core import MoulinetteLdapIsDownError from moulinette.authenticators import ldap from yunohost.utils.error import YunohostError @@ -34,8 +35,6 @@ def _get_ldap_interface(): if _ldap_interface is None: - assert_slapd_is_running() - conf = { "vendor": "ldap", "name": "as-root", "parameters": { 'uri': 'ldapi://%2Fvar%2Frun%2Fslapd%2Fldapi', @@ -44,7 +43,12 @@ def _get_ldap_interface(): "extra": {} } - _ldap_interface = ldap.Authenticator(**conf) + try: + _ldap_interface = ldap.Authenticator(**conf) + except MoulinetteLdapIsDownError: + raise YunohostError("Service slapd is not running but is required to perform this action ... You can try to investigate what's happening with 'systemctl status slapd'") + + assert_slapd_is_running() return _ldap_interface