Univention Bugzilla – Bug 36034
Minus in hostname should be valid
Last modified: 2016-01-20 13:33:28 CET
Found at #2014092921000445: ucs-school-lib/python/models/attributes.py overrides the valid syntax for hostnames: regex = re.compile('^[a-zA-Z0-9](([a-zA-Z0-9_]*)([a-zA-Z0-9]$))?$') This is wrong! "-" in hostnames is also valid. This leads to unseen erros if a new school dc contains a "-" and the install wizard is used. It just fails without any menaingful error message.
(In reply to Tim Petersen from comment #0) > regex = re.compile('^[a-zA-Z0-9](([a-zA-Z0-9_]*)([a-zA-Z0-9]$))?$') > > This is wrong! "-" in hostnames is also valid. The underscore should also be removed as it produces problems in DNS names.
I think instead the "normal" udm syntax for hostnames should be used, as new systems are installed with this validation.
Fixed in svn r57584. I replaced "_" by "-" in the 2 regexps in ucs-school-lib/python/models/attributes.py (class SchoolName and class DCName). In ucs-school-import the function is_valid_hostname() has been adapted to allow also 0-9 as first character as all other regexps do this, too. Btw: here are the regexp's used in UCS: join module: ^[a-z]([a-z0-9-]*[a-z0-9])*(\.([a-z0-9]([a-z0-9-]*[a-z0-9])*[.])*[a-z0-9]([a-z0-9-]*[a-z0-9])*)?$ system-setup: ^[a-z]([a-z0-9-]*[a-z0-9])*$ UDM syntax.py: hostName class: (^[a-zA-Z0-9])(([a-zA-Z0-9-_]*)([a-zA-Z0-9]$))?$
merged to UCS@school 3.2
For completeness other checks for hostnames (correct ones): ucs-school-umc-wizards/umc/python/schoolwizards/__init__.py: schooldc=StringSanitizer(required=True, regex_pattern=re.compile(r'^[a-zA-Z](([a-zA-Z0-9-_]*)([a-zA-Z0-9]$))?$')), ucs-school-import/ucs-school-import: return bool(re.match('^[a-zA-Z0-9](([a-zA-Z0-9-_]*)([a-zA-Z0-9]$))?$', name)) ucs-school-import/ucs-school-import: if not re.match('^[a-zA-Z0-9](([a-zA-Z0-9-_]*)([a-zA-Z0-9]$))?$', ShareFileServer): ucs-school-umc-installer/umc/python/schoolinstaller/__init__.py:RE_HOSTNAME_OR_EMPTY = re.compile('^([a-z]([a-z0-9-]*[a-z0-9])*(\.([a-z0-9]([a-z0-9-]*[a-z0-9])*[.])*[a-z0-9]([a-z0-9-]*[a-z0-9])*)?)?$') OK: code change OK: debian changelog entry OK: XML changelog entry TODO: practical check
> OK: code change > OK: debian changelog entry > OK: XML changelog entry OK: practical check
UCS@school 4.0 v2 has been released: http://docs.univention.de/release-notes-ucsschool-4.0v2-de.html If this error occurs again, please use "Clone This Bug".