]> git.ipfire.org Git - ipfire.org.git/commitdiff
accounts: Limit LDAP operations to 10 seconds
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 4 Dec 2019 16:51:33 +0000 (16:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 4 Dec 2019 16:51:33 +0000 (16:51 +0000)
Some operations seem to lock up indefinitely.

This change will abort any operation after 10 seconds
and prevent the webapp from locking up.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/accounts.py

index 74b4eafbd7e591720147f4f7e8dbc7ee2c1e8b13..a32c15f521ebc920fe7679aae69aec05c0cee8b0 100644 (file)
@@ -194,9 +194,15 @@ class Accounts(Object):
                logging.debug("Connecting to LDAP server: %s" % ldap_uri)
 
                # Connect to the LDAP server
-               return ldap.ldapobject.ReconnectLDAPObject(ldap_uri,
+               connection = ldap.ldapobject.ReconnectLDAPObject(ldap_uri,
+                       trace_level=2 if self.backend.debug else 0,
                        retry_max=10, retry_delay=3)
 
+               # Set maximum timeout for operations
+               connection.set_option(ldap.OPT_TIMEOUT, 10)
+
+               return connection
+
        def _authenticate(self):
                # Authenticate against LDAP server using Kerberos
                self.ldap.sasl_gssapi_bind_s()