Page MenuHomePhorge

Invalid type conversion when setting ldap/timeout
Closed, ResolvedPublic

Description

When starting with a default configuration we get the following message:

2019-11-23 14:43:15,131 pykolab.conf WARNING [29689] Option ldap/timeout does not exist in config file /etc/kolab/kolab.conf, pulling from defaults

After looking the the example configuration at https://git.kolab.org/diffusion/P/browse/master/conf/kolab.conf the example shows:

[ldap]
; The URI to LDAP
ldap_uri = ldap://localhost:389

; A timeout, in seconds, for regular searches such as authentication requests.
timeout = 10

Setting exact this results in the following error:

2019-11-23 14:46:24,078 pykolab.auth ERROR [29941] An error occured using _persistent_search: TypeError('a float is required',)
2019-11-23 14:46:24,080 pykolab.auth ERROR [29941] Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pykolab/auth/ldap/__init__.py", line 3168, in _search
    secondary_domains
  File "<string>", line 10, in <module>
  File "/usr/lib/python2.7/dist-packages/pykolab/auth/ldap/__init__.py", line 2820, in _persistent_search
    serverctrls=psearch_server_controls
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 841, in search_ext
    timeout,sizelimit,
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 313, in _ldap_call
    result = func(*args,**kwargs)
TypeError: a float is required

2019-11-23 14:46:24,080 pykolab.auth ERROR [29941] An error occured using _paged_search: TypeError('encode_page_control() argument 2 must be string or read-only buffer, not None',)
2019-11-23 14:46:24,080 pykolab.auth ERROR [29941] Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pykolab/auth/ldap/__init__.py", line 3168, in _search
    secondary_domains
  File "<string>", line 10, in <module>
  File "/usr/lib/python2.7/dist-packages/pykolab/auth/ldap/__init__.py", line 2907, in _paged_search
    serverctrls=[server_page_control]
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 839, in search_ext
    RequestControlTuples(serverctrls),
  File "/usr/lib/python2.7/dist-packages/ldap/controls/__init__.py", line 119, in RequestControlTuples
    for c in ldapControls
  File "/usr/lib/python2.7/dist-packages/ldap/controls/libldap.py", line 77, in encodeControlValue
    return _ldap.encode_page_control(self.size,self.cookie)
TypeError: encode_page_control() argument 2 must be string or read-only buffer, not None

It looks like `self.config_get('ldap', 'timeout', default=10)? returns a string and not a float.

Solution: we need to make sure the type is converted

Details

Ticket Type
Task