[PATCH] Add code to call res_init in glibc so that we can make use of updated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This will break when glibc soname bumps, and really this should be
fixed in glibc itself or somewhere else, but until then we need to
be able to poke the resolver.  This is for RH bug 480858
---
 network.py |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/network.py b/network.py
index 0d0e2b0..ba3e2b1 100644
--- a/network.py
+++ b/network.py
@@ -1,7 +1,7 @@
 #
 # network.py - network configuration install data
 #
-# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008  Red Hat, Inc.
+# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009  Red Hat, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
 #            Mike Fulbright <msf@xxxxxxxxxx>
 #            Brent Fox <bfox@xxxxxxxxxx>
 #            David Cantrell <dcantrell@xxxxxxxxxx>
+#            Jesse Keating <jkeating@xxxxxxxxxx>
 #
 
 import string
@@ -34,6 +35,7 @@ import time
 import minihal
 import rhpl
 import dbus
+import ctypes
 from flags import flags
 
 from rhpl.simpleconfig import SimpleConfigFile
@@ -50,6 +52,20 @@ class IPError(Exception):
 class IPMissing(Exception):
     pass
 
+# HAAAAAACK because glibc doesn't notice /etc/resolv.conf changes...
+def _reset_resolver():
+    '''Attempt to reset the system resolver.'''
+    # mostly lifted from smolt
+
+    try:
+        # This is sure to break at some point when soname changes.
+        resolv = ctypes.CDLL("libresolv.so.2")
+        r = resolv.__res_init()
+    except (OSError, AttributeError):
+        log.warning("Warning: could not find __res_init in libresolv.so.2")
+        r = -1
+    return r
+
 def sanityCheckHostname(hostname):
     if len(hostname) < 1:
         return None
@@ -440,6 +456,9 @@ class Network:
             log.warning("no network devices were available to look up host name")
             return None
 
+        # reset the resolver in case things have changed.
+        result = _reset_resolver()
+
         try:
             (family, socktype, proto, canonname, sockaddr) = \
                 socket.getaddrinfo(self.hostname, None, socket.AF_INET)[0]
-- 
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux