Bug 113933

Summary: rhn_register - socket.error: host not found
Product: Red Hat Satellite 5 Reporter: veepee1 <rhn>
Component: RegistrationAssignee: Adrian Likins <alikins>
Status: CLOSED WONTFIX QA Contact: Red Hat Satellite QA List <satqe-list>
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: cperry, michaels, nphilipp
Target Milestone: ---Keywords: EasyFix
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-08-21 22:01:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description veepee1 2004-01-20 11:52:51 UTC
Description of problem:
I have this error when i try to register a new RHLES 2.1 U3

###################################################################
Traceback (innermost last):
  File "/usr/sbin/rhn_register", line 233, in ?
    main()
  File "/usr/sbin/rhn_register", line 214, in main
    tui.main()
  File "/usr/share/rhn/register/tui.py", line 1042, in main
    tui.run()
  File "/usr/share/rhn/register/tui.py", line 986, in run
    win = self.windows[index](self.screen, self)
  File "/usr/share/rhn/register/tui.py", line 567, in __init__
    tui.hardware = hardware.Hardware()
  File "/usr/share/rhn/register/hardware.py", line 374, in Hardware
    ret = read_network()
  File "/usr/share/rhn/register/hardware.py", line 296, in 
read_network
    hostname, ipaddr = findHostByRoute()
  File "/usr/share/rhn/register/hardware.py", line 276, in 
findHostByRoute
    hostname = socket.gethostbyaddr(intf)[0]
socket.error: host not found
###################################################################

When i try whis a new username i haven't this error


Version-Release number of selected component (if applicable):
rhn_register-2.9.2-1.2.1AS

How reproducible:


Steps to Reproduce:
1. $ rhn_register --nox
2. -> NEXT
3. -> NEXT
4. username/pwd/mail
5. -> NEXT
6. socket.error: host not found
  
Actual results:


Expected results:


Additional info:

Comment 1 Michael Sims 2004-02-05 21:22:18 UTC
Not sure if this is frowned upon or not, but I just wanted to confirm
that I have also seen this behavior on three different machines that
I've attempted to register with my existing RHN account (username
"hironimus")

Comment 2 Michael Sims 2004-02-06 16:53:00 UTC
I've done some more digging in the code and I've found that this error
is occuring while the rhn_register program is trying to discover
information about my machine's hardware.  Specifically, it appears to
be trying to discover the machine's hostname and IP address, and this
is where the error is occuring.

It looks like the hardware.py script is opening a socket connection to
the serverURL host, then trying to discover the IP address of my
machine by getting the properties of that connection:

<quote>
def findHostByRoute():
    cfg = config.RHNConfig()
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    serverUrl = cfg.readEntry('serverURL')
    server = string.split(serverUrl, '/')[2]
    s.connect((server, 80))
    (intf, port) = s.getsockname()

    hostname = socket.gethostbyaddr(intf)[0]
    s.close()
    return hostname, intf
</quote>

If I comment out the call to findHostByRoute() and hard code my
hostname and IP address into the hardware.py file, the registration
works.  Here is a diff:

<quote>
[root@gnu2 register]# diff -u hardware.py.orig hardware.py
--- hardware.py.orig    Fri Feb  6 10:26:21 2004
+++ hardware.py Fri Feb  6 10:26:56 2004
@@ -293,9 +293,9 @@

     if netdict['hostname'] == 'localhost.localdomain' or \
        netdict['ipaddr'] == "127.0.0.1":
-        hostname, ipaddr = findHostByRoute()
-        netdict['hostname'] = hostname
-        netdict['ipaddr'] = ipaddr
+        #hostname, ipaddr = findHostByRoute()
+        netdict['hostname'] = "gnu2.crye-leike.com"
+        netdict['ipaddr'] = "10.62.148.241"
     return netdict

 # This one tries to read the DMI information - it needs root access
to do that.
</quote>

I have one machine here that makes it past this discovery step without
incident.  It is on the DMZ of my firewall and has a static internal
IP which is mapped to an external IP address.  Connections from and to
this machine are NAT'ed through this address.  The machine that I
cannot successfully register is on the "trusted" portion of my
firewall and has no mapped IP.  Connections from this machine are
NAT'ed outgoing but the only way to communicate with the machine from
the outside is if the machine initiaties the connection itself.  I'm
not a networking or firewall expert so I may not be describing this
completely but that is my understanding of how it works.

I'm going to place this machine on my DMZ and give it a different
mapped address and see if that rectifies the problem, but I figured
I'd share this information in the meantime in case it rings bells with
anyone.


Comment 3 Michael Sims 2004-02-06 17:52:25 UTC
I figured out what the problem was.  When I changed my machine's
hostname and IP address I updated the /etc/sysconfig/network and
/etc/sysconfig/network-scripts/ifcfg-eth0 files, but I forgot to
update /etc/hosts.  Doh!

I realize I made an amateurish mistake, but I would respectfully
suggest that the rhn_register script be updated to print a somewhat
friendlier error message.  My suggestion is something like this:

"There was a problem attempting to discover your machine's hostname
and IP address.  Please check the contents of your network
configuration files (list files) for any problems and try again."

Thanks...

Comment 4 Nils Philippsen 2004-02-18 14:55:52 UTC
I still see the problem with rhn_register-2.9.2-1.2.1AS from a machine
that:

- is behind a firewall, you can only use a web proxy to get out
- can't resolve external hostnames via nslookup/gethostbyname()
- is configured properly w.r.t. hostname, /etc/hosts

I have tracked back the behaviour to this section of
/usr/share/rhn/register/hardware.py:

[...]
    280 def read_network():
[...]
    284     netdict['hostname'] = socket.gethostname()
    285     try:
    286         netdict['ipaddr'] =
socket.gethostbyname(socket.gethostname())
    287     except:
    288         netdict['ipaddr'] = "127.0.0.1"
    289
    290     netdict['hostname'] = 'localhost.localdomain'
    291     netdict['ipaddr'] = "127.0.0.1"
    292
[...]

Lines 290 and 291 overwrite the real hostname, ipaddr and seem to be
debugging statements (to test out the code path going through
findHostByRoute()?). When I removed them, everything worked.

Comment 6 Clifford Perry 2009-08-21 22:01:21 UTC
RHEL 2.1 is EOL'd. Closing this bug out.