RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 773099 - testHostname() doesn't allow a trailing dot
Summary: testHostname() doesn't allow a trailing dot
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: system-config-network
Version: 6.1
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Jan Synacek
QA Contact: Branislav Blaškovič
URL:
Whiteboard:
Depends On:
Blocks: 1270825
TreeView+ depends on / blocked
 
Reported: 2012-01-10 22:47 UTC by brian
Modified: 2016-05-10 20:32 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-05-10 20:32:35 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:0792 0 normal SHIPPED_LIVE system-config-network bug fix and enhancement update 2016-05-10 22:36:59 UTC

Description brian 2012-01-10 22:47:43 UTC
Description of problem:

In /usr/share/system-config-network/netconfpkg/NC_functions.py:testHostname() the test does not allow for a trailing dot that is legal for DNS names.  In fact the trailing dot makes a DNS name explicit.


Version-Release number of selected component (if applicable):

# rpm -qf /usr/share/system-config-network/netconfpkg/NC_functions.py
system-config-network-tui-1.6.0.el6.2-1.el6.noarch

How reproducible:

100%

Comment 3 Suzanne Logcher 2012-02-14 23:27:45 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.

Comment 5 Jan Synacek 2015-11-27 09:45:37 UTC
What's the real issue here? The hostname can be set to myhost.mydomain without a problem.

Comment 6 Brian J. Murrell 2015-11-27 12:43:44 UTC
(In reply to Jan Synacek from comment #5)
> What's the real issue here? The hostname can be set to myhost.mydomain
> without a problem.

The real problem here is that a domain name with a trailing dot is a legal and valid and _unambiguous_ domain name per RFC 1034 section 3.1:

  Since a complete
  domain name ends with the root label, this leads to a printed form which
  ends in a dot.  We use this property to distinguish between:

     - a character string which represents a complete domain name
       (often called "absolute").  For example, "poneria.ISI.EDU."

     - a character string that represents the starting labels of a
       domain name which is incomplete, and should be completed by
       local software using knowledge of the local domain (often
       called "relative").  For example, "poneria" used in the
       ISI.EDU domain.

To fail when an unambiguous, complete and legal domain name is specified such as is happening in the case of this ticket, is a bug.

What is the real-world problem with this?  I wish you'd have asked me that almost 4 years ago when I originally opened this ticket.

But given that this is a bug and somebody has hit it in the real world and that the fix is absolutely trivial, what is the resistance to fixing it?  Here's the patch:

--- /mnt/centos6.5/usr/share/system-config-network/netconfpkg/NC_functions.py	2010-11-11 15:19:49.000000000 -0500
+++ /tmp/foo	2015-11-27 07:38:52.997684620 -0500
@@ -245,8 +245,8 @@
 
 # we want to compile the regexp just once (not as fast as I expect)
 ip_pattern = re.compile('^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$')
-hostname_pattern = re.compile('^([a-zA-Z]|[0-9]|_)(([a-zA-Z]|[0-9]|-|_)*([a-zA-Z]|[0-9]|_))?(\.([a-zA-Z]|[0-9]|_)(([a-zA-Z]|[0-9]|-|_)*([a-zA-Z]|[0-9]))?)*$')
-length_pattern = re.compile('^[a-zA-Z0-9-_]{1,64}(\.([a-zA-Z0-9-_]{1,64}))*$')
+hostname_pattern = re.compile('^([a-zA-Z]|[0-9]|_)(([a-zA-Z]|[0-9]|-|_)*([a-zA-Z]|[0-9]|_))?(\.([a-zA-Z]|[0-9]|_)(([a-zA-Z]|[0-9]|-|_)*([a-zA-Z]|[0-9]))?)*\.?$')
+length_pattern = re.compile('^[a-zA-Z0-9-_]{1,64}(\.([a-zA-Z0-9-_]{1,64}))*\.?$')
 def testHostname(hostname):
     # hostname: names separated by '.' every name must be max 63 
     # chars in length and the hostname max length is 255 chars

And the proofs:

$ python
Python 2.7.10 (default, Sep 24 2015, 17:50:09) 
[GCC 5.1.1 20150618 (Red Hat 5.1.1-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> hostname_pattern = re.compile('^([a-zA-Z]|[0-9]|_)(([a-zA-Z]|[0-9]|-|_)*([a-zA-Z]|[0-9]|_))?(\.([a-zA-Z]|[0-9]|_)(([a-zA-Z]|[0-9]|-|_)*([a-zA-Z]|[0-9]))?)*\.?$')
>>> length_pattern = re.compile('^[a-zA-Z0-9-_]{1,64}(\.([a-zA-Z0-9-_]{1,64}))*\.?$')
>>> length_pattern.match("www.redhat.com")
<_sre.SRE_Match object at 0x7f66f0197938>
>>> length_pattern.match("www.redhat.com.")
<_sre.SRE_Match object at 0x7f66f01979c0>
>>> hostname_pattern.match("www.redhat.com")
<_sre.SRE_Match object at 0x7f66f8dcdeb8>
>>> hostname_pattern.match("www.redhat.com.")
<_sre.SRE_Match object at 0x7f66f8caf410>

Given that it is actually a bug and that I have provided the patch to fix it, I am going to unset the NOTABUG label and reopen this.

Comment 7 Jan Synacek 2015-11-27 12:58:28 UTC
I misread the bug description, hence the confusion.

Comment 8 Jan Synacek 2015-11-27 13:20:05 UTC
In the current release (system-config-network-1.6.0.el6.3), hostname_pattern already contains the trailing dot, but length_pattern doesn't.

Comment 14 Branislav Blaškovič 2016-02-16 11:27:51 UTC
Ok, regexp is ok now, but we are not using this function anywhere in tui so it is just dead code.

Filled another bug (BZ#1308891 so we actually use this function in tui).

Marking this as verified.

Comment 16 errata-xmlrpc 2016-05-10 20:32:35 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-0792.html


Note You need to log in before you can comment on or make changes to this bug.