Bug 32765 - Maybe broken extended attributes handling for modules without layout
Maybe broken extended attributes handling for modules without layout
Status: NEW
Product: UCS
Classification: Unclassified
Component: UDM - Extended Attributes
UCS 5.0
All Linux
: P5 minor (vote)
: ---
Assigned To: UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-30 20:07 CEST by Philipp Hahn
Modified: 2020-06-22 16:53 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Cleanup, Error handling
Max CVSS v3 score:
best: Patch_Available+


Attachments
This look more right, but please re-check; UNTESTED (11.91 KB, patch)
2013-09-30 20:07 CEST, Philipp Hahn
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Hahn univentionstaff 2013-09-30 20:07:30 CEST
Created attachment 5477 [details]
This look more right, but please re-check; UNTESTED

r27969 changed the indention of univention/admin/modules.py to put some EA code unter a conditional:
  if hasattr( module, 'layout' ):

This also included the call to 
  module.extended_udm_attributes.extend([univention.admin.extended_attribute(
    pname,
    attrs.get('univentionUDMPropertyObjectClass', [])[0],
    attrs['univentionUDMPropertyLdapMapping'][0],
    deleteObjectClass,
    propertySyntaxString,
    propertyHook
  )])

Since this call is AFAIK not related to the layout, but is required for proper working of EAs including hooks, it looks wrong and should be checked (search for "extended_udm_attributes"in "univention/admin/handlers/__init__.py").

Currently there a 4 modules which don't declare a layout:
  $ grep -L ^layout */[^_]*.py 
  computers/computer.py
  nagios/nagios.py
  settings/settings.py
  shares/print.py

The simplest fix would be to move the above mentioned call one indention level to the left.

The attached patch does more:
1. move the call before the layout attribute processing.
2. Use "continue" to skip the layout processing.
3. Factor out the "layoutDisabled" checking to also skip the rest of the loop
4. Introduce a ldap_true() function to factor out the checking for "1"|"TRUE"
5. Introduce a ldap_int() function to factor out the integer parsing
6. Fix several white space issues and break some very long lines for easier reading.