unbound v1.6.0 python module on debian 9

Christopher Hearn chris at convorelay.com
Thu Oct 25 20:52:22 UTC 2018


This is what I have:

server:
	verbosity: 1
	statistics-cumulative: "yes"
	extended-statistics: "yes"
	num-threads: 2
 	interface: "0.0.0.0"
        interface: "::0"
        interface-automatic: yes
        outgoing-port-permit: "32768-65535"
 	outgoing-port-avoid: "0-32767"
        chroot: ""
	root-hints: "/etc/unbound/root.hints"
        module-config: "validator python iterator"
        directory: "/etc/unbound"
	cache-max-ttl: 300
        log-queries: no
        do-not-query-localhost: no
        include: /etc/unbound/unbound.local.d/*.conf
python:
        python-script: "/etc/unbound/dns-backend.py"
remote-control:
	control-enable: yes
include: "/etc/unbound/unbound.conf.d/*.conf"

Here's what I see when I try to run unbound:

unbound -dv -c unbound.conf
[1540500365] unbound[18398:0] notice: Start of unbound 1.6.0.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named 'unboundmodule'

However, it's there:

ll /usr/lib/python2.7/dist-packages/ | grep unbound
-rw-r--r-- 1 root root 102230 Aug 27  2017 unboundmodule.py
-rw-r--r-- 1 root root  85737 Oct 19 15:05 unboundmodule.pyc
-rw-r--r-- 1 root root  36348 Aug 27  2017 unbound.py
-rw-r--r-- 1 root root  39760 Oct 19 15:05 unbound.pyc
-rw-r--r-- 1 root root  80016 Aug 27  2017 _unbound.x86_64-linux-gnu.so


> On Oct 25, 2018, at 6:00 AM, unbound-users-request at nlnetlabs.nl wrote:
> 
> Date: Wed, 24 Oct 2018 14:38:00 +0200
> From: George Thessalonikefs <george at nlnetlabs.nl <mailto:george at nlnetlabs.nl>>
> To: unbound-users at nlnetlabs.nl <mailto:unbound-users at nlnetlabs.nl>
> Subject: Re: unbound v1.6.0 python module on debian 9
> Message-ID: <b9059648-e1dd-2ecb-3b96-94b1097405f0 at nlnetlabs.nl <mailto:b9059648-e1dd-2ecb-3b96-94b1097405f0 at nlnetlabs.nl>>
> Content-Type: text/plain; charset=utf-8
> 
> Hi Christopher,
> 
> What is the error you are getting from unbound?
> Can you share some bits of your configuration file? I am mainly
> interested in the following options:
>  chroot:
>  directory:
>  module-config:
>  python-script:
> 
> -- George
> 
> On 24/10/2018 14:29, Christopher Hearn via Unbound-users wrote:
>> Thanks for the reply George. ?When I run what you suggested, I see
>> /usr/lib/python2.7/dist-packages, and the unboundmodule.py is indeed in
>> there. ?If I run my python script on it?s own from my shell, it works
>> fine. ?unbound itself still does not see it, nor any of the other
>> dependencies in that directory. ?Any idea why this might be?
>> 
>>> On Oct 24, 2018, at 6:00 AM, unbound-users-request at nlnetlabs.nl <mailto:unbound-users-request at nlnetlabs.nl>
>>> <mailto:unbound-users-request at nlnetlabs.nl <mailto:unbound-users-request at nlnetlabs.nl>> wrote:
>>> 
>>> Date: Tue, 23 Oct 2018 18:13:23 +0200
>>> From: George Thessalonikefs <george at nlnetlabs.nl <mailto:george at nlnetlabs.nl>
>>> <mailto:george at nlnetlabs.nl <mailto:george at nlnetlabs.nl>>>
>>> To:?unbound-users at nlnetlabs.nl <mailto:?unbound-users at nlnetlabs.nl> <mailto:unbound-users at nlnetlabs.nl <mailto:unbound-users at nlnetlabs.nl>>
>>> Subject: Re: unbound v1.6.0 python module on debian 9
>>> Message-ID: <014e436d-11f6-3ce5-e488-011e8d2601a6 at nlnetlabs.nl <mailto:014e436d-11f6-3ce5-e488-011e8d2601a6 at nlnetlabs.nl>
>>> <mailto:014e436d-11f6-3ce5-e488-011e8d2601a6 at nlnetlabs.nl <mailto:014e436d-11f6-3ce5-e488-011e8d2601a6 at nlnetlabs.nl>>>
>>> Content-Type: text/plain; charset=utf-8
>>> 
>>> Hi Christopher,
>>> 
>>> On 23/10/2018 17:24, Christopher Hearn via Unbound-users wrote:
>>>> I?m trying to set up a server running unbound and a python script.
>>>> ?This is working OK on an older server running version 1.4.2. ?On the
>>>> newer one, I can?t seem to get unbound to see the python script
>>>> dependencies. ?I do recall on the old server, this was because chroot
>>>> was enabled. ?Once I disabled it in the config file via chroot: ??,
>>>> it was fine. ?It?s disabled on the new one too, but still doesn?t
>>>> seem to help. ?If I symlink the requested file from
>>>> /usr/lib/python2.7/dist-packages/unboundpython.py to /etc/unbound/,
>>>> that resolves that error, but more come up because of course it can?t
>>>> see the other libraries. ?This leads me to believe that unbound isn?t
>>>> looking out of /etc/unbound/ even though chroot is disabled. ?Is
>>>> there something else I?m missing?
>>>> 
>>> 
>>> I am assuming that you want to use a python script with unbound's python
>>> module.
>>> 
>>> I see that when initializing the python module, unbound appends to the
>>> sys path also the directory reported by Python as the
>>> "platform-dependent include directory" [1].
>>> 
>>> You can find that directory by starting up the Python interpreter (the
>>> same that unbound will also use; in case of Python virtual environments)
>>> and typing:
>>>>> import distutils.sysconfig
>>>>> distutils.sysconfig.get_python_lib(1,0)
>>> '/usr/local/lib/python2.7/site-packages' (in my case)
>>> 
>>> As a side note you can also achieve the same with chroot enabled but
>>> then you would need to link the same python directory structure inside
>>> the chroot in order for unbound to find the libraries.
>>> 
>>> [1]
>>> https://docs.python.org/3.7/distutils/apiref.html?highlight=get_python_lib#distutils.sysconfig.get_python_lib <https://docs.python.org/3.7/distutils/apiref.html?highlight=get_python_lib#distutils.sysconfig.get_python_lib>
>>> 
>>> -- George
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nlnetlabs.nl/pipermail/unbound-users/attachments/20181025/c7c1a2d3/attachment.htm>


More information about the Unbound-users mailing list