Bug 38856

Summary: Traceback creating existing UDM object with policies
Product: UCS Reporter: Philipp Hahn <hahn>
Component: UDM - CLIAssignee: Johannes Keiser <keiser>
Status: CLOSED FIXED QA Contact: Florian Best <best>
Severity: normal    
Priority: P5 CC: best, gohmann
Version: UCS 4.2Flags: hahn: Patch_Available+
Target Milestone: UCS 4.2-1-errata   
Hardware: Other   
OS: Linux   
See Also: https://forge.univention.org/bugzilla/show_bug.cgi?id=38584
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?: ISV affected?:
Waiting Support: Flags outvoted (downgraded) after PO Review:
Ticket number: Bug group (optional):
Max CVSS v3 score:
Attachments: Patch tracebacks
Rebased patch

Description Philipp Hahn univentionstaff 2015-07-08 10:10:42 CEST
Created attachment 7009 [details]
Patch tracebacks

1. dn is re-assigned the exception instance
2. For existing objects the policies are applied, even when already referenced.

ucr set directory/manager/cmd/debug/level=4
eval "$(ucr shell ldap/base domainname)"
python /usr/share/pyshared/univention/admincli/admin.py dhcp/subnet create --logfile /dev/stderr --ignore_exists --superordinate cn=$domainname,cn=dhcp,$ldap_base --set subnet=192.168.122.0 --policy-reference cn=default-settings,cn=boot,cn=dhcp,cn=policies,$ldap_base --set subnetmask=255.255.255.0
...
... add dn=cn=192.168.122.0,cn=phahn.dev,cn=dhcp,dc=phahn,dc=dev err={'desc': 'Already exists'}
... mod dn=cn=192.168.122.0,cn=phahn.dev,cn=dhcp,dc=phahn,dc=dev ml=[('objectClass', '', 'univentionPolicyReference')]
...
Traceback (most recent call last):
  File "/usr/share/univention-directory-manager-tools/univention-cli-server", line 222, in doit
    output = univention.admincli.admin.doit(arglist)
  File "/usr/lib/pymodules/python2.7/univention/admincli/admin.py", line 393, in doit
    out=_doit(arglist)
  File "/usr/lib/pymodules/python2.7/univention/admincli/admin.py", line 889, in _doit
    lo.modify(dn,[('objectClass','','univentionPolicyReference')])
  File "/usr/lib/pymodules/python2.7/univention/admin/uldap.py", line 414, in modify
    return self.lo.modify(dn, changes)
  File "/usr/lib/pymodules/python2.7/univention/uldap.py", line 460, in modify
    if dn.startswith(key+'='):
AttributeError: 'objectExists' object has no attribute 'startswith'
...
08.07.15 09:57:35.666  ADMIN       ( WARN    ) : Traceback (most recent call last):
  File "/usr/share/pyshared/univention/admincli/admin.py", line 393, in doit
    out=_doit(arglist)
  File "/usr/share/pyshared/univention/admincli/admin.py", line 890, in _doit
    lo.modify(dn,[('objectClass','','univentionPolicyReference')])
  File "/usr/lib/pymodules/python2.7/univention/admin/uldap.py", line 423, in modify
    raise univention.admin.uexceptions.ldapError(_err2str(msg), original_exception=msg)
ldapError: Type or value exists: modify/add: objectClass: value #0 already exists
Comment 1 Johannes Keiser univentionstaff 2017-06-29 12:55:58 CEST
Created attachment 8985 [details]
Rebased patch

Applied rebased patch:

r 80609
univention-directory-manager-modules (12.0.17-24) 
* Bug #38856: Applied patch - Fix traceback when creating existing UDM
object with policies

YAML: r 80610
Comment 2 Florian Best univentionstaff 2017-06-29 14:41:40 CEST
OK: policy reference is not evaluated if object exists
OK: AttributeError: DN
OK: YAML (adjusted in r80618)

Added a test case:
r80617 | Bug #38856: add 59_udm/12_create_existing_object_does_not_policy_reference
Comment 3 Janek Walkenhorst univentionstaff 2017-07-05 13:06:20 CEST
<http://errata.software-univention.de/ucs/4.2/79.html>