Univention Bugzilla – Bug 41092
e-mail property contains previous address as default
Last modified: 2017-06-28 15:33:24 CEST
At Ticket #2016041821000301 an issue was discovered regarding the "e-mail" property of UDM user objects. Apparently, the e-mail address (property "mailPrimaryAddress") set for a new UDM user object is set as default (attribute "base_default") for the "e-mail" property. This default isn't cleared/reinitialized properly when a second new UDM user object is created. Following, the new UDM user object reports as default for the "e-mail" property the value of "mailPrimaryAddress" of the first object. The attached script will reproduce the issue. Here are the main steps to reproduce the issue: # Create first user object obj = users.object(config, ldap, position_base_dn) obj.open() obj['password'] = 'JDFOQHWQ67mw' obj['lastname'] = 'Test0021' obj['mailPrimaryAddress'] = 'test0021@SOMEDOMAIN' obj['username'] = 'test0021' obj['primaryGroup'] = 'cn=Domain Users,cn=groups,%s' % baseDN obj.create() # Create second user object obj2 = users.object(config, ldap, position_base_dn) obj2.open() # Demonstrate problem assert obj2['e-mail'] == obj['e-mail'] # this should fail! This line sets the default /usr/share/pyshared/univention/admin/handlers/users/user.py:343 default = [ '<mailPrimaryAddress>' ] The list() appears to be the problem its values are not reinitialized.
Created attachment 7609 [details] Test script to reproduce the issue
It doesn't fail on my machine (UCS 4.1-1). # python test.py <univention.admin.uldap.position instance at 0x1752cf8> <univention.admin.uldap.access instance at 0x1752ea8> 1 2 ['test0022@school.local']
The test is written backwards.. the assert on the last line accepts it's input if the problem exists :) So, to let the test crash when the problem exists, change it to the following instead: assert obj2['e-mail'] != obj['e-mail']
Ah yes, so you want that the email address is automatically (re)set to a new value.
(In reply to Florian Best from comment #4) > Ah yes, so you want that the email address is automatically (re)set to a new > value. Err, oh I see. The default value is replaced to that last used address.
Created attachment 7611 [details] patch Attached is a patch which fixes the issue. The problem is that the default() function of the property returns the original list which is modified instead of a copy.
>>> import univention.admin.handlers.users.user >>> email = univention.admin.handlers.users.user.property_descriptions['e-mail'] >>> lo, po = univention.admin.uldap.getMachineConnection() >>> obj = univention.admin.handlers.users.user.object(None, lo, po) >>> obj['mailPrimaryAddress'] = 'foo@bar.baz' >>> email.default(obj) ['foo@bar.baz'] >>> email.base_default ['foo@bar.baz']
Created attachment 7612 [details] patch Even a better patch - it allows base_default to be set from the outside as it is done by extended attributes/templates.
(In reply to Florian Best from comment #8) > Created attachment 7612 [details] > patch > > Even a better patch - it allows base_default to be set from the outside as > it is done by extended attributes/templates. Applied patch: r 80415 univention-directory-manager-modules (12.0.17-20) * Bug #41092 Copy base_default value for modification YAML: r 80417
OK: fix OK: YAML
<http://errata.software-univention.de/ucs/4.2/74.html>