Source: python-eventlet
Version: 0.35.1-1
Severity: normal
X-Debbugs-Cc: d...@debian.org, wb-t...@buildd.debian.org
Control: affects -1 buildd.debian.org

Hi,

python-eventlet fails to build with no nameserver specified in
/etc/resolv.conf:

=================================== FAILURES ===================================
_________________________ TestProxyResolver.test_clear _________________________

self = <tests.greendns_test.TestProxyResolver testMethod=test_clear>

    def test_clear(self):
        rp = greendns.ResolverProxy()
        assert rp._cached_resolver is None
>       resolver = rp._resolver

tests/greendns_test.py:304:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
eventlet/support/greendns.py:347: in _resolver
    self.clear()
eventlet/support/greendns.py:355: in clear
    self._resolver = dns.resolver.Resolver(filename=self._filename)
/usr/lib/python3/dist-packages/dns/resolver.py:944: in __init__
    self.read_resolv_conf(filename)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <dns.resolver.Resolver object at 0x7f9116b8ac90>
f = <_io.TextIOWrapper name='/etc/resolv.conf' mode='r' encoding='UTF-8'>

    def read_resolv_conf(self, f: Any) -> None:
        """Process *f* as a file in the /etc/resolv.conf format.  If f is
        a ``str``, it is used as the name of the file to open; otherwise it
        is treated as the file itself.

        Interprets the following items:

        - nameserver - name server IP address

        - domain - local domain name

        - search - search list for host-name lookup

        - options - supported options are rotate, timeout, edns0, and ndots

        """

        nameservers = []
        if isinstance(f, str):
            try:
                cm: contextlib.AbstractContextManager = open(f)
            except OSError:
                # /etc/resolv.conf doesn't exist, can't be read, etc.
                raise NoResolverConfiguration(f"cannot open {f}")
        else:
            cm = contextlib.nullcontext(f)
        with cm as f:
            for l in f:
                if len(l) == 0 or l[0] == "#" or l[0] == ";":
                    continue
                tokens = l.split()

                # Any line containing less than 2 tokens is malformed
                if len(tokens) < 2:
                    continue

                if tokens[0] == "nameserver":
                    nameservers.append(tokens[1])
                elif tokens[0] == "domain":
                    self.domain = dns.name.from_text(tokens[1])
                    # domain and search are exclusive
                    self.search = []
                elif tokens[0] == "search":
                    # the last search wins
                    self.search = []
                    for suffix in tokens[1:]:
                        self.search.append(dns.name.from_text(suffix))
                    # We don't set domain as it is not used if
                    # len(self.search) > 0
               elif tokens[0] == "options":
                    for opt in tokens[1:]:
                        if opt == "rotate":
                            self.rotate = True
                        elif opt == "edns0":
                            self.use_edns()
                        elif "timeout" in opt:
                            try:
                                self.timeout = int(opt.split(":")[1])
                            except (ValueError, IndexError):
                                pass
                        elif "ndots" in opt:
                            try:
                                self.ndots = int(opt.split(":")[1])
                            except (ValueError, IndexError):
                                pass
        if len(nameservers) == 0:
>           raise NoResolverConfiguration("no nameservers")
E           dns.resolver.NoResolverConfiguration: no nameservers

/usr/lib/python3/dist-packages/dns/resolver.py:1038: NoResolverConfiguration


This fails in sbuild with the unshare backend.

Cheers Jochen

Reply via email to