Hello,

DNS: Reinitialize DNS resolver after changing resolv.conf

Previously the installer did not reinitialize resolver so queries for
records created using --ip-address option might not be answered. This led
to incorrect results during 'Updating DNS system records' phase at the
end of installation.

This is kind of hack but right now we do not have enough time to extend
python-dns's interface with resolver_reinit() method.

https://fedorahosted.org/freeipa/ticket/5962

-- 
Petr^2 Spacek
From 4a55df8ad821140fddfefe2835b0dd01f41cb466 Mon Sep 17 00:00:00 2001
From: Petr Spacek <pspa...@redhat.com>
Date: Wed, 29 Jun 2016 19:35:35 +0200
Subject: [PATCH] DNS: Reinitialize DNS resolver after changing resolv.conf

Previously the installer did not reinitialize resolver so queries for
records created using --ip-address option might not be answered. This led
to incorrect results during 'Updating DNS system records' phase at the
end of installation.

This is kind of hack but right now we do not have enough time to extend
python-dns's interface with resolver_reinit() method.

https://fedorahosted.org/freeipa/ticket/5962
---
 ipaserver/install/bindinstance.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py
index ebb4212ab161456dc3898456567d7b97a6a9939e..f4ed63141cf25dfcfdc72d37d6ff4563e4acccf1 100644
--- a/ipaserver/install/bindinstance.py
+++ b/ipaserver/install/bindinstance.py
@@ -17,6 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+from __future__ import absolute_import
 from __future__ import print_function
 
 import tempfile
@@ -27,6 +28,7 @@ import re
 import sys
 import time
 
+import dns.resolver
 import ldap
 import six
 
@@ -982,6 +984,10 @@ class BindInstance(service.Service):
             resolv_fd.close()
         except IOError as e:
             root_logger.error('Could not write to resolv.conf: %s', e)
+        else:
+            # python DNS might have global resolver cached in this variable
+            # we have to re-initialize it because resolv.conf has changed
+            dns.resolver.default_resolver = None
 
     def __generate_rndc_key(self):
         installutils.check_entropy()
-- 
2.7.4

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to