Merge pull request #22 from chillout2k/devel

LDAP-connection timeout of 60sec is too long
This commit is contained in:
Dominik Chilla 2019-07-09 12:08:07 +02:00 committed by GitHub
commit d667193e1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
import Milter import Milter
from ldap3 import ( from ldap3 import (
Server,ServerPool,Connection,NONE,LDAPOperationResult Server,ServerPool,Connection,NONE,LDAPOperationResult,set_config_parameter
) )
import sys import sys
import traceback import traceback
@ -394,6 +394,8 @@ if __name__ == "__main__":
if 'MILTER_EXPECT_AUTH' in os.environ: if 'MILTER_EXPECT_AUTH' in os.environ:
if re.match(r'^true$', os.environ['MILTER_EXPECT_AUTH'], re.IGNORECASE): if re.match(r'^true$', os.environ['MILTER_EXPECT_AUTH'], re.IGNORECASE):
g_milter_expect_auth = True g_milter_expect_auth = True
set_config_parameter("RESTARTABLE_SLEEPTIME", 2)
set_config_parameter("RESTARTABLE_TRIES", 2)
server = Server(g_ldap_server, get_info=NONE) server = Server(g_ldap_server, get_info=NONE)
g_ldap_conn = Connection(server, g_ldap_conn = Connection(server,
g_ldap_binddn, g_ldap_bindpw, g_ldap_binddn, g_ldap_bindpw,
@ -401,10 +403,6 @@ if __name__ == "__main__":
client_strategy='RESTARTABLE' client_strategy='RESTARTABLE'
) )
logging.info("Connected to LDAP-server: " + g_ldap_server) logging.info("Connected to LDAP-server: " + g_ldap_server)
except LDAPOperationResult as e:
logging.error("LDAP Exception: " + str(e))
sys.exit(1)
try:
timeout = 600 timeout = 600
# Register to have the Milter factory create instances of your class: # Register to have the Milter factory create instances of your class:
Milter.factory = LdapAclMilter Milter.factory = LdapAclMilter
@ -419,3 +417,4 @@ if __name__ == "__main__":
logging.info("Shutdown " + g_milter_name) logging.info("Shutdown " + g_milter_name)
except: except:
logging.error("MAIN-EXCEPTION: " + traceback.format_exc()) logging.error("MAIN-EXCEPTION: " + traceback.format_exc())
sys.exit(1)