Bug 41836 - TypeError: add() got an unexpected keyword argument 'exceptions' in locking.py
TypeError: add() got an unexpected keyword argument 'exceptions' in locking.py
Status: RESOLVED INVALID
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 4.1
Other Linux
: P5 normal (vote)
: ---
Assigned To: UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-07-21 18:46 CEST by Daniel Tröder
Modified: 2018-04-13 13:30 CEST (History)
1 user (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: 2: Improvement: Would be a product improvement
Who will be affected by this bug?: 1: Will affect a very few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2016-07-21 18:46:17 CEST
Under certain circumstances a code path in univention/admin/locking.py is used, that uses wrong arguments to univention.uldap.access.add()


/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in create(self, lo, validate)
    415 		'''
    416                 self.call_hooks('pre', 'create')
--> 417                 success = self.create_without_hooks(lo, validate)
    418                 if success:
    419                         self.call_hooks('post', 'create')

/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in create_without_hooks(self, lo, validate)
    441 
    442                         # here is the real logic
--> 443                         self.do_create(udm_obj, lo)
    444 
    445                         # get it fresh from the database (needed for udm_obj._exists ...)

/usr/lib/pymodules/python2.7/ucsschool/lib/models/user.pyc in do_create(self, udm_obj, lo)
    245                 if script_path is not None:
    246                         udm_obj['scriptpath'] = script_path
--> 247                 success = super(User, self).do_create(udm_obj, lo)
    248                 if password_created:
    249                         # to not show up in host_hooks

/usr/lib/pymodules/python2.7/ucsschool/lib/models/base.pyc in do_create(self, udm_obj, lo)
    458 		'''
    459                 self._alter_udm_obj(udm_obj)
--> 460                 udm_obj.create()
    461 
    462         def modify(self, lo, validate=True, move_if_necessary=None):

/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.pyc in create(self)
    293                         raise univention.admin.uexceptions.insufficientInformation
    294 
--> 295                 return self._create()
    296 
    297         def modify(self, modify_childs=1,ignore_license=0):

/usr/lib/pymodules/python2.7/univention/admin/handlers/__init__.pyc in _create(self)
    677                 self._call_checkLdap_on_all_property_syntaxes()
    678 
--> 679                 al = self._ldap_addlist()
    680                 al.extend(self._ldap_modlist())
    681                 m = univention.admin.modules.get(self.module)

/usr/lib/pymodules/python2.7/univention/admin/handlers/users/user.pyc in _ldap_addlist(self)
   1752                                                 return []
   1753                         try:
-> 1754                                 uid=univention.admin.allocators.request(self.lo, self.position, 'uid', value=self['username'])
   1755                                 if 'posix' in self.options:
   1756                                         if self['unixhome'] == '/home/%s' % self.old_username:

/usr/lib/pymodules/python2.7/univention/admin/allocators.pyc in request(lo, position, type, value)
    190         if type in ('uidNumber', 'gidNumber'):
    191                 return acquireRange(lo, position, type, _type2attr[type], [{'first': 1000, 'last': 55000}, {'first': 65536, 'last': 1000000}], scope=_type2scope[type])
--> 192         return acquireUnique(lo, position, type, value, _type2attr[type], scope=_type2scope[type])
    193 
    194 

/usr/lib/pymodules/python2.7/univention/admin/allocators.pyc in acquireUnique(lo, position, type, value, attr, scope)
    168                         return value
    169         elif type in ['groupName', 'uid'] and configRegistry.is_true('directory/manager/user_group/uniqueness', True):
--> 170                 univention.admin.locking.lock(lo, position, type, value, scope=scope)
    171                 if not lo.searchDn(base=searchBase, filter=filter_format('(|(&(cn=%s)(|(objectClass=univentionGroup)(objectClass=sambaGroupMapping)(objectClass=posixGroup)))(uid=%s))', (value, value))):
    172                         univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'ALLOCATE return %s'% value)

/usr/lib/pymodules/python2.7/univention/admin/locking.pyc in lock(lo, position, type, value, scope, timeout)
     70         if not lo.get(dn, ['lockTime']):
     71                 try:
---> 72                         lo.add(dn, al, exceptions=0)
     73                         return locktime
     74                 except ldap.ALREADY_EXISTS:

TypeError: add() got an unexpected keyword argument 'exceptions'
Comment 1 Daniel Tröder univentionstaff 2016-07-21 18:51:00 CEST
Also lo.modify() in line 93 and 115 and lo.delete() in line 128.
Comment 2 Florian Best univentionstaff 2016-07-21 18:56:26 CEST
Never use a univention.uldap.access instance. Always univention.admin.uldap.access!
Comment 3 Daniel Tröder univentionstaff 2016-07-21 19:02:38 CEST
Good to know.
Maybe more code needs to be adapted:

grep -r 'univention.uldap.getAdminConnection' branches/ucs-4.1/ucs-4.1-2/ | wc -l
→ 12
Comment 4 Florian Best univentionstaff 2016-07-21 19:06:29 CEST
No, all of the following seem fine:

base/univention-heimdal/kerberos_now:lo = univention.uldap.getAdminConnection()
base/univention-python/modules/password.py:                     self.lo = univention.uldap.getAdminConnection()
management/univention-directory-manager-modules/modules/univention/admin/uldap.py:      lo = univention.uldap.getAdminConnection(start_tls, decode_ignorelist=decode_ignorelist)
management/univention-directory-manager-modules/scripts/convert-user-base64-photos:     lo = univention.uldap.getAdminConnection()
management/univention-directory-manager-modules/scripts/univention-remove-old-umc-objects:lo = univention.uldap.getAdminConnection()
management/univention-directory-manager-modules/univention-object-type-migrate: uldap = univention.uldap.getAdminConnection()
management/univention-ldap-overlay-memberof/univention-update-memberof:         lo = univention.uldap.getAdminConnection()
management/univention-ldap/scripts/convert_shadowMax.py:lo = univention.uldap.getAdminConnection()
management/univention-ldap/scripts/convert_univentionMailSharedFolderDeliveryAddress.py:        lo = univention.uldap.getAdminConnection()
services/univention-net-installer/univention-net-installer-daemon:              lo = univention.uldap.getAdminConnection()
services/univention-samba/scripts/kerberize_user:lo = univention.uldap.getAdminConnection(decode_ignorelist = [ 'krb5Key' ])
test/ucs-test/tests/40_mail/45_dovecot_test_camelcase_mailadresses:                             lo = univention.uldap.getAdminConnection()
Comment 5 Florian Best univentionstaff 2016-07-21 19:10:37 CEST
univention-directory-manager-modules/scripts/convert-user-base64-photos uses it wrong in a lookup() call.