On Wed, Nov 30, 2011 at 04:22:40PM +0000, Miroslav Suchý wrote:
>  client/rhel/rhn-client-tools/src/up2date_client/hardware.py |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> New commits:
> commit 7c2b37ad9dd2a972e04bb31cbb021047c6572564
> Author: Miroslav Suchý <msu...@redhat.com>
> Date:   Wed Nov 30 17:21:34 2011 +0100
> 
>     743259 - take hostname of client instead of server
> 
> diff --git a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py 
> b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
> index f2e68d8..d85d5d0 100644
> --- a/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
> +++ b/client/rhel/rhn-client-tools/src/up2date_client/hardware.py
> @@ -428,11 +428,12 @@ def findHostByRoute():
>              try:
>                  s.settimeout(5)
>                  s.connect((server, port))
> +                intf_tmp = s.getsockname()[0]
>                  if family == AF_INET:
> -                    intf = s.getsockname()[0]
> +                    intf = intf_tmp
>                  else:
> -                    intf6 = s.getsockname()[0]
> -                hostname = socket.getfqdn(server)
> +                    intf6 = intf_tmp
> +                hostname = socket.getfqdn(intf_tmp)
>              except socket.error:
>                  s.close()
>                  continue

I don't think you want to just blindly set what getfqdn returns. In
most cases, IPv4 addresses will have better DNS records than IPv6 but
you will end up with stuff like

        # python -c 'from socket import *; print                                
        getfqdn("2620:52:0:2223:20c:29ff:fe0e:d05b");' 
2620:52:0:2223:20c:29ff:fe0e:d05b

in the hostname. You should really check (and test) various scenarios,
not overwrite the hostname if it already is set from the IPv4 pass,
and not set it if you get IP address back.

-- 
Jan Pazdziora
Principal Software Engineer, Satellite Engineering, Red Hat

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to