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['password'] = 'JDFOQHWQ67mw'
obj['lastname'] = 'Test0021'
obj['mailPrimaryAddress'] = 'test0021@SOMEDOMAIN'
obj['username'] = 'test0021'
obj['primaryGroup'] = 'cn=Domain Users,cn=groups,%s' % baseDN
# Create second user object
obj2 = users.object(config, ldap, position_base_dn)
# 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>
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
Err, oh I see. The default value is replaced to that last used address.
Created attachment 7611 [details]
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'] = 'email@example.com'
Created attachment 7612 [details]
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]
> Even a better patch - it allows base_default to be set from the outside as
> it is done by extended attributes/templates.
* Bug #41092 Copy base_default value for modification
YAML: r 80417