Univention Bugzilla – Bug 46844
empty values cannot be added to complex syntaxes via udm cli
Last modified: 2021-05-03 21:39:19 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
(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
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.
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.