Bug 473919 - Hostname validation error
Summary: Hostname validation error
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: system-config-network
Version: 10
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Harald Hoyer
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 473858 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-12-01 13:36 UTC by Cong Ma
Modified: 2009-01-07 09:06 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-01-07 09:06:29 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Patch to /usr/share/system-config-network/netconfpkg/NC_functions.py (468 bytes, patch)
2008-12-01 13:36 UTC, Cong Ma
no flags Details | Diff

Description Cong Ma 2008-12-01 13:36:53 UTC
Created attachment 325231 [details]
Patch to /usr/share/system-config-network/netconfpkg/NC_functions.py 

Description of problem:
Line 250 in the file /usr/share/system-config-network/netconfpkg/NC_functions.py

The Python regular expression does not match host name parts of a single letter.
Thus, hostnames like "a.example.com" will be rejected when parsing /etc/hosts.


Version-Release number of selected component (if applicable):
system-config-network-1.5.93-2.fc10.noarch


How reproducible:
Always


Steps to Reproduce:
1.
2.
3.
  

Actual results:


Expected results:


Additional info:
I did some research on Google and found an IETF RFC about valid hostnames:
"RFC 1123 -- Requirements for Internet Hosts -- Application and Support".
The part related to hostname is here: http://tools.ietf.org/html/rfc1123#page-13

It made a reference to RFC 952, to which a modification is added. In RFC 952, I found
the original BNF for valid hostname is buried in its spec for DoD internet hostname table.
Namely, it's in the BNFs <hname> (http://tools.ietf.org/html/rfc952#page-5). RFC 1123 made
a revision to allow hostnames to begin with a digit.

Therefore I made a patch in accordance with RFC 1123. The regular expression in the patch
is a direct transliteration of the one found in RFC 952 plus the modification made by
RFC 1123.

There's one thing I'm not sure about though. According to the RFCs, hostnames like
"foo--a-bar.example.com" are valid. However I'm yet to see any real example of hostnames
with consecutive hyphens in it. The original Python code rejects this kinds of names, but
the RFC seems to allow them and so does my patch.

This bug was discovered by the user "ssivil" of FedoraForum.org. Another user "arvinddeshpande"
spotted the offending file, and I made the patch. The original discussion can be found at
http://forums.fedoraforum.org/showthread.php?t=205903 (I also posted the patch in that discussion).

BTW, the RFC use the so-called "Augemented BNF" (http://en.wikipedia.org/wiki/ABNF).

Comment 1 Jiri Moskovcak 2008-12-01 15:24:43 UTC
*** Bug 473858 has been marked as a duplicate of this bug. ***

Comment 2 Jiri Moskovcak 2008-12-01 15:35:29 UTC
Hi,
thanks for patch, I'll review the regexp ASAP and make an update with it.

Jirka

Comment 3 Arvind Deshpande 2008-12-01 17:48:10 UTC
$ python
Python 2.5.1 (r251:54863, May 18 2007, 16:56:43)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> #'([a-zA-Z]|[0-9])(([a-zA-Z]|[0-9]|-)*([a-zA-Z]|[0-9]))?$')
...
>>> import re
>>> pat = re.compile('([a-zA-Z]|[0-9])(([a-zA-Z]|[0-9]|-)*([a-zA-Z]|[0-9]))?$')
>>> pat
<_sre.SRE_Pattern object at 0x6d6148>
>>> pat.match('a')
<_sre.SRE_Match object at 0x7ff78cd8>
>>> pat.match('b')
<_sre.SRE_Match object at 0x7ff78d30>
>>> pat.match('9')
<_sre.SRE_Match object at 0x7ff78cd8>
>>> pat.match('a9')
<_sre.SRE_Match object at 0x7ff78d30>
>>> pat.match('a9-')
>>> pat.match('-a9')
>>> pat.match('-a9-')
>>> pat.match('a9')
<_sre.SRE_Match object at 0x7ff78cd8>
>>> pat.match('a9-abc')
<_sre.SRE_Match object at 0x7ff78d30>
>>> pat.match('abc_abcd')
>>> pat.match('9')
<_sre.SRE_Match object at 0x7ff78cd8>
>>> pat.match('-')
>>> pat.match('a-')
>>> pat.match('a-d')
<_sre.SRE_Match object at 0x7ff78d30>
>>> pat.match('a_d')
>>>

Comment 5 Fedora Update System 2008-12-17 12:57:53 UTC
system-config-network-1.5.95-1.fc10 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/system-config-network-1.5.95-1.fc10

Comment 6 Fedora Update System 2008-12-21 08:24:31 UTC
system-config-network-1.5.95-1.fc10 has been pushed to the Fedora 10 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update system-config-network'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F10/FEDORA-2008-11472

Comment 7 Fedora Update System 2009-01-07 09:06:12 UTC
system-config-network-1.5.95-1.fc10 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.


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