From: Bob Halley Date: Sat, 5 Jan 2019 14:46:29 +0000 (-0800) Subject: If reading /etc/resolv.conf fails, or finds no servers, raise NoResolverConfiguration X-Git-Tag: v2.0.0rc1~386 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03176dea4c56ede85c34cf6bec127c96c85a8bf4;p=thirdparty%2Fdnspython.git If reading /etc/resolv.conf fails, or finds no servers, raise NoResolverConfiguration [Issue #332] --- diff --git a/dns/resolver.py b/dns/resolver.py index 74828bd1..dc40efa7 100644 --- a/dns/resolver.py +++ b/dns/resolver.py @@ -180,6 +180,8 @@ class NoRootSOA(dns.exception.DNSException): class NoMetaqueries(dns.exception.DNSException): """DNS metaqueries are not allowed.""" +class NoResolverConfiguration(dns.exception.DNSException): + """Resolver configuration could not be read or specified no nameservers.""" class Answer(object): """DNS stub resolver answer. @@ -576,9 +578,7 @@ class Resolver(object): f = open(f, 'r') except IOError: # /etc/resolv.conf doesn't exist, can't be read, etc. - # We'll just use the default resolver configuration. - self.nameservers = ['127.0.0.1'] - return + raise NoResolverConfiguration want_close = True else: want_close = False @@ -606,7 +606,7 @@ class Resolver(object): if want_close: f.close() if len(self.nameservers) == 0: - self.nameservers.append('127.0.0.1') + raise NoResolverConfiguration def _determine_split_char(self, entry): #