Bug 46844 - empty values cannot be added to complex syntaxes via udm cli
empty values cannot be added to complex syntaxes via udm cli
Status: NEW
Product: UCS
Classification: Unclassified
Component: UMC - Computers
UCS 5.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: UMC maintainers
UMC maintainers
:
Depends on: 44389
Blocks:
  Show dependency treegraph
 
Reported: 2018-04-17 18:42 CEST by Johannes Keiser
Modified: 2021-05-03 21:39 CEST (History)
5 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 4: Minor Usability: Impairs usability in secondary scenarios
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.046
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): API change
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Keiser univentionstaff 2018-04-17 18:42:33 CEST
+++ This bug was initially created as a clone of Bug #44389 +++

Version: 4.2-0 errata0 (Lesum)

Remark: Einen PC unter Netzwerk-Einstellungen ein Netzwerk zugeordnet. Netzwerk wurde vorher angelegt.

Die Ausführung des Kommandos udm/put computers/computer ist fehlgeschlagen:
Traceback (most recent call last):
  File "%PY2.7%/notifier/threads.py", line 82, in _run
    tmp = self._function()
  File "%PY2.7%/notifier/__init__.py", line 104, in __call__
    return self._function( *tmp, **self._kwargs )
  File "%PY2.7%/univention/management/console/modules/udm/__init__.py", line 406, in _thread
    module.modify(properties)
  File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 86, in _decorated
    return method(*args, **kwargs)
  File "%PY2.7%/univention/management/console/ldap.py", line 143, in _decorated
    result = func(*args, **kwargs)
  File "%PY2.7%/univention/management/console/modules/udm/udm_ldap.py", line 445, in modify
    obj.modify()
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 318, in modify
    return self._modify(modify_childs, ignore_license=ignore_license)
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 814, in _modify
    self._ldap_post_modify()
  File "%PY2.7%/univention/admin/handlers/computers/windows.py", line 512, in _ldap_post_modify
    univention.admin.handlers.simpleComputer._ldap_post_modify(self)
  File "%PY2.7%/univention/admin/handlers/__init__.py", line 2001, in _ldap_post_modify
    zoneIsV6 = explode_dn(x, 1)[0].endswith('.ip6.arpa')
IndexError: list index out of range
Comment 1 Johannes Keiser univentionstaff 2018-04-17 18:45:34 CEST
(https://forge.univention.org/bugzilla/show_bug.cgi?id=44389#c12)
> A draft for a patch has been implemented in 
> fbest/44389-creating-computer-causes-index-error. The patch fixes the syntax
> validation of some required fields. Additionally it fixes the UDM CLI complex
> syntax validation so that it behaves like UMC does.

The fix for the CLI has not been implemented with Bug #44389
Comment 2 Stefan Gohmann univentionstaff 2018-05-03 10:05:26 CEST
Please check the user pain since the bug has been cloned. If the user pain is below 0.3, please re-assign the bug to umc-maintainers.
Comment 3 Johannes Keiser univentionstaff 2018-05-04 18:08:09 CEST
The patch addresses the issue that empty values in complex syntaxes
are removed from the final result that gets appended.

The intended syntax for appending complex syntax is e.g

--append displayName='de_DE DisplayName'

if a value has spaces or an empty value should be appended double quotes
need to be used.

--append displayName='"de_DE" "DisplayName with spaces"'


The udm cli first splits the value for a property at double quotes

e.g. 'de_DE DisplayName'.split('"') -> ['de_DE DisplayName']

and if the first entry of the result is the initial value
(which means the value did not contain the " char and was therefor not split)
it splits at spaces.

'de_DE DisplayName'.split(' ') -> ['de_DE', 'DisplayName']


The problems occur if double quotes are used.
'"de_DE" "DisplayName with spaces"'.split('"')
becomes
['', 'de_DE', ' ', 'DisplayName with spaces', '']

In the current version empty values are removed from this result
which leaves
['de_DE', 'DisplayName']
which is valid.

But because of this, inserting empty values in complex syntax via cli is not possible.

E.g.: trying to append a homePostalAddress and leaving the Postal Code empty
--append homePostalAddress='"Street name" "" "City"'

will append ['Street name', 'city'] because empty values are removed.
which results in the Postal code being 'city' and the city being empty, which was not intended.

Additionally the error messages from the cli are not alway correct/understandable.
e.g. adding dns forward zone to computer:
--append dnsEntryZoneForward='"" "10.200.28.125"'
will give:  Invalid syntax: dnsEntryZoneForward: Not a valid LDAP DN
for ['10.200.28.125']
instead of: Invalid syntax: dnsEntryZoneForward: An empty value is not allowed
for ['', '10.200.28.125']


The patch for the cli addresses this by using the result from split('"') as the final value,
but that does not work because afais e.g.
'"Street name" "" "City"'.split('"') -> ['', 'Street name', ' ', '', ' ', 'City', '']
and not ['Street name', '', 'City']


Maybe shlex could be used to split the input into a list for complex syntaxes.