Script `/etc/resolver/dhcp_host_domain_ng.py` seems to be run as shell by dnsmasq
This was reported by user of Turris Mox. The output from logs is as follows:
Feb 24 15:09:57 turris dnsmasq-dhcp[20356]: read /etc/ethers - 0 addresses
Feb 24 15:09:57 turris dnsmasq-script[20356]: /usr/lib/dnsmasq/dhcp-script.sh: /etc/resolver/dhcp_host_domain_ng.py: line 3: import: not found
Feb 24 15:09:57 turris dnsmasq-script[20356]: /usr/lib/dnsmasq/dhcp-script.sh: /etc/resolver/dhcp_host_domain_ng.py: line 4: import: not found
Feb 24 15:09:57 turris dnsmasq-script[20356]: /usr/lib/dnsmasq/dhcp-script.sh: /etc/resolver/dhcp_host_domain_ng.py: line 5: import: not found
Feb 24 15:09:57 turris dnsmasq-script[20356]: /usr/lib/dnsmasq/dhcp-script.sh: /etc/resolver/dhcp_host_domain_ng.py: line 6: from: not found
Feb 24 15:09:57 turris dnsmasq-script[20356]: /usr/lib/dnsmasq/dhcp-script.sh: /etc/resolver/dhcp_host_domain_ng.py: line 7: import: not found
Feb 24 15:09:57 turris dnsmasq-script[20356]: /usr/lib/dnsmasq/dhcp-script.sh: /etc/resolver/dhcp_host_domain_ng.py: line 8: import: not found
Feb 24 15:09:57 turris dnsmasq-script[20356]: /usr/lib/dnsmasq/dhcp-script.sh: /etc/resolver/dhcp_host_domain_ng.py: line 9: import: not found
Feb 24 15:09:57 turris dnsmasq-script[20356]: /usr/lib/dnsmasq/dhcp-script.sh: /etc/resolver/dhcp_host_domain_ng.py: line 10: from: not found
Feb 24 15:09:57 turris dnsmasq-script[20356]: /usr/lib/dnsmasq/dhcp-script.sh: /etc/resolver/dhcp_host_domain_ng.py: line 13: syntax error: unexpected “(”
Feb 24 15:09:57 turris dnsmasq[20356]: script process exited with status 2
This is clearly a shell interpretation of python script. I am not sure why this is happening but I suspect that some patch or even upstream dnsmasq introduced change of in from that they source scripts instead of starting them.
Problematic script seems to have correct hashbang at the beginning (or might we migrate it to python3?):
head /etc/resolver/dhcp_host_domain_ng.py
#!/usr/bin/python
import subprocess
import sys
import syslog
from syslog import LOG_ERR, LOG_INFO, LOG_DEBUG, LOG_WARNING
import re
import socket
import os
from os import listdir
Forum reference: https://forum.turris.cz/t/hostname-resolution-without-domain-doesnt-work/9606