Bug 36034 - Minus in hostname should be valid
Minus in hostname should be valid
Status: CLOSED FIXED
Product: UCS@school
Classification: Unclassified
Component: Ucsschool-lib
UCS@school 3.2 R2
Other Linux
: P5 normal (vote)
: UCS@school 4.0 Errata
Assigned To: Florian Best
Sönke Schwardt-Krummrich
:
Depends on:
Blocks: 40472 37770 37802 37945
  Show dependency treegraph
 
Reported: 2014-10-01 11:21 CEST by Tim Petersen
Modified: 2016-01-20 13:33 CET (History)
1 user (show)

See Also:
What kind of report is it?: ---
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:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Petersen univentionstaff 2014-10-01 11:21:22 CEST
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.
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2014-10-07 10:06:45 CEST
(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.
Comment 2 Tim Petersen univentionstaff 2014-10-07 11:11:21 CEST
I think instead the "normal" udm syntax for hostnames should be used, as new systems are installed with this validation.
Comment 3 Florian Best univentionstaff 2015-01-27 11:52:47 CET
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]$))?$
Comment 4 Florian Best univentionstaff 2015-01-27 12:24:32 CET
merged to UCS@school 3.2
Comment 5 Sönke Schwardt-Krummrich univentionstaff 2015-02-19 16:34:57 CET
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
Comment 6 Sönke Schwardt-Krummrich univentionstaff 2015-02-20 17:33:01 CET
> OK: code change
> OK: debian changelog entry
> OK: XML changelog entry
 
OK: practical check
Comment 7 Sönke Schwardt-Krummrich univentionstaff 2015-02-27 15:19:38 CET
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".