Bug 54558 - make /etc/hosts.d/20-static UCR template idempotent
make /etc/hosts.d/20-static UCR template idempotent
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: univention-base-files
UCS 5.0
Other Linux
: P5 normal (vote)
: UCS 5.0-1-errata
Assigned To: Juan Carlos
Peter Stoll
https://git.knut.univention.de/univen...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2022-03-16 09:54 CET by Florian Best
Modified: 2022-05-25 18:33 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): bitesize
Max CVSS v3 score:
best: Patch_Available+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2022-03-16 09:54:11 CET
03_ucr/37check-ucr-templates-py3-migration-status.test_configfile_python_compatibility[/etc/univention/templates/files/etc/hosts.d/20-static] revealed that the UCR template is not idempotent.

Patch:
diff --git base/univention-base-files/conffiles/etc/hosts.d/20-static base/univention-base-files/conffiles/etc/hosts.d/20-static
index 57979353e2..19c9c05878 100644
--- base/univention-base-files/conffiles/etc/hosts.d/20-static
+++ base/univention-base-files/conffiles/etc/hosts.d/20-static
@@ -1,7 +1,7 @@
 @!@
 # Add static addresses "hosts/static/$ip=$names"
 PREFIX = 'hosts/static/'
-for key, value in configRegistry.items():
+for key, value in sorted(configRegistry.items()):
        if key.startswith(PREFIX) and key != PREFIX:
                print("%s\t%s" % (key.split('/')[-1], value))
 @!@
Comment 1 Juan Carlos univentionstaff 2022-05-12 16:59:35 CEST
37check-ucr-templates-py3-migration-status.py::test_configfile_python_compatibility[/etc/univention/templates/files/etc/hosts.d/20-static] Py2:|✅|100%	Py3:|✅|100%
PASSED
Comment 2 Juan Carlos univentionstaff 2022-05-17 08:21:37 CEST
Suggested patch applied. Now the content of /etc/hosts is idempotent. With this fix the entries are ordered before they are written to the file.
Fixed on version 9.0.3-8.
See commit 6f96d73c