Bug 41092 - e-mail property contains previous address as default
e-mail property contains previous address as default
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC - Users
UCS 4.2
Other Linux
: P5 normal (vote)
: UCS 4.2-1-errata
Assigned To: Johannes Keiser
Florian Best
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-04-21 14:02 CEST by Jan Christoph Ebersbach
Modified: 2017-06-28 15:33 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
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: 0.034
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number: 2016041821000301
Bug group (optional): External feedback
Max CVSS v3 score:
best: Patch_Available+


Attachments
Test script to reproduce the issue (1.48 KB, text/x-python)
2016-04-21 14:02 CEST, Jan Christoph Ebersbach
Details
patch (1.23 KB, patch)
2016-04-21 15:41 CEST, Florian Best
Details | Diff
patch (4.16 KB, patch)
2016-04-21 15:54 CEST, Florian Best
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Christoph Ebersbach univentionstaff 2016-04-21 14:02:11 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.
Comment 1 Jan Christoph Ebersbach univentionstaff 2016-04-21 14:02:37 CEST
Created attachment 7609 [details]
Test script to reproduce the issue
Comment 2 Florian Best univentionstaff 2016-04-21 14:19:18 CEST
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']
Comment 3 David Vogt 2016-04-21 14:21:24 CEST
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']
Comment 4 Florian Best univentionstaff 2016-04-21 14:22:44 CEST
Ah yes, so you want that the email address is automatically (re)set to a new value.
Comment 5 Florian Best univentionstaff 2016-04-21 14:24:10 CEST
(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.
Comment 6 Florian Best univentionstaff 2016-04-21 15:41:15 CEST
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.
Comment 7 Florian Best univentionstaff 2016-04-21 15:45:35 CEST
>>> 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']
Comment 8 Florian Best univentionstaff 2016-04-21 15:54:02 CEST
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.
Comment 9 Johannes Keiser univentionstaff 2017-06-22 14:56:43 CEST
(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
Comment 10 Florian Best univentionstaff 2017-06-22 16:28:28 CEST
OK: fix
OK: YAML
Comment 11 Janek Walkenhorst univentionstaff 2017-06-28 15:33:24 CEST
<http://errata.software-univention.de/ucs/4.2/74.html>