Univention Bugzilla – Bug 53642
Changing computer name: TypeError: replace() argument 1 must be str, not bytes
Last modified: 2021-08-20 14:07:21 CEST
I cannot reproduce this, but a fix is easy. I tested all standard computer roles, maybe it's some extension role. Version: 5.0-0 errata65 Remark: Change Computer Name Error: Internal server error during "udm/put (computers/computer)". Request: udm/put (computers/computer) File "%PY3%/notifier/threads.py", line 80, in _run result = self._function() File "%PY3%/notifier/__init__.py", line 105, in __call__ return self._function(*tmp, **self._kwargs) File "%PY3%/univention/management/console/modules/udm/__init__.py", line 442, in _thread module.modify(properties) File "%PY3%/univention/management/console/modules/udm/udm_ldap.py", line 649, in modify obj.modify() File "%PY3%/univention/admin/handlers/__init__.py", line 636, in modify dn = self._modify(modify_childs, ignore_license=ignore_license, response=response) File "%PY3%/univention/admin/handlers/__init__.py", line 1360, in _modify self._ldap_post_modify() File "%PY3%/univention/admin/handlers/computers/__base.py", line 206, in _ldap_post_modify univention.admin.handlers.simpleComputer._ldap_post_modify(self) File "%PY3%/univention/admin/handlers/__init__.py", line 2776, in _ldap_post_modify self.__rename_dhcp_object(old_name=self.__changes['name'][0], new_name=self.__changes['name'][1]) File "%PY3%/univention/admin/handlers/__init__.py", line 2220, in __rename_dhcp_object object['host'] = object['host'].replace(old_name, new_name) TypeError: replace() argument 1 must be str, not bytes
diff --git management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py index f61ac8a576..a3a9cf3164 100644 --- management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py +++ management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py @@ -2848,7 +2848,7 @@ class simpleComputer(simpleLdap): if self.hasChanged('name'): ml.append(('sn', self.oldattr.get('sn', [None])[0], self['name'].encode('UTF-8'))) - self.__changes['name'] = (self.oldattr.get('sn', [None])[0], self['name']) + self.__changes['name'] = (self.oldattr.get('sn', [None])[0].decode("UTF-8"), self['name']) if self.hasChanged('ip') or self.hasChanged('mac'): dhcp = [self.__split_dhcp_line(entry) for entry in self.info.get('dhcpEntryZone', [])]
#!/usr/share/ucs-test/runner pytest-3 -s -l -v ## desc: Rename object for all computer roles ## tags: [udm-computers] ## roles: [domaincontroller_master] ## exposure: careful ## packages: ## - univention-config ## - univention-directory-manager-tools import univention.testing.udm as udm_test import univention.testing.strings as uts import univention.testing.utils as utils import pytest @pytest.mark.parametrize('role', udm_test.UCSTestUDM.COMPUTER_MODULES) def test_all_roles_rename(role, udm): computer = udm.create_object(role, name=uts.random_string()) udm.modify_object(role, dn=computer, name=uts.random_string()) # TODO: verify ldap object
univention-directory-manager-modules.yaml 97f762317912 | Bug #53642: fix changing computer name univention-directory-manager-modules (15.0.11-14) 97f762317912 | Bug #53642: fix changing computer name
This does not work: Interner Server-Fehler in "udm/add (computers/computer)". Request: udm/add (computers/computer) File "/usr/lib/python3/dist-packages/notifier/threads.py", line 80, in _run result = self._function() File "/usr/lib/python3/dist-packages/notifier/__init__.py", line 105, in __call__ return self._function(*tmp, **self._kwargs) File "/usr/lib/python3/dist-packages/univention/management/console/modules/udm/__init__.py", line 404, in _thread dn = module.create(properties, container=options.get('container'), superordinate=options.get('superordinate')) File "/usr/lib/python3/dist-packages/univention/management/console/modules/udm/udm_ldap.py", line 570, in create obj.create() File "/usr/lib/python3/dist-packages/univention/admin/handlers/__init__.py", line 543, in create dn = self._create(response=response, serverctrls=serverctrls) File "/usr/lib/python3/dist-packages/univention/admin/handlers/__init__.py", line 1255, in _create al.extend(self._ldap_modlist()) File "/usr/lib/python3/dist-packages/univention/admin/handlers/computers/__base.py", line 223, in _ldap_modlist ml = univention.admin.handlers.simpleComputer._ldap_modlist(self) File "/usr/lib/python3/dist-packages/univention/admin/handlers/__init__.py", line 2851, in _ldap_modlist self.__changes['name'] = (self.oldattr.get('sn', [None])[0].decode("UTF-8"), self['name']) AttributeError: 'NoneType' object has no attribute 'decode'
Oups, sorry. Fixed in: univention-directory-manager-modules (15.0.11-14) cb269dd4db40 | fixup! Bug #53642: fix changing computer name
Manual renaming a computer with and without DHCP service: OK Codechange: OK YAML: OK
<https://errata.software-univention.de/#/?erratum=5.0x67>