question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

luci-mod-system/startup: dnsmasq restart failed to load names from /tmp/hosts/dhcp.main_dns: Permission denied

See original GitHub issue

Dnsmasq no longer able to read dns files in /tmp/hosts/ after restart via the UI. All files are rw by owner (root) only.

root@u1:/etc/config# ls -l /tmp/hosts/dhcp.main_dns 
-rw-------    1 root     root           151 Oct 30 23:53 /tmp/hosts/dhcp.main_dns
root@u1:/etc/config# logread -e dnsmasq.*dhcp.main_dns
Sat Oct 30 23:53:16 2021 daemon.err dnsmasq[11280]: failed to load names from /tmp/hosts/dhcp.main_dns: Permission denied

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
dangowrtcommented, Oct 31, 2021

Please check if the patch below resolves both issues (wrong umask inherited from LuCI, missing HOSTFILE_DIR in ujail).

diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
index 3250b2179b..28cc8b961b 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -829,12 +829,14 @@ dnsmasq_start()
        CONFIGFILE_TMP="${CONFIGFILE}.$$"
        HOSTFILE="${BASEHOSTFILE}.${cfg}"
        HOSTFILE_TMP="${HOSTFILE}.$$"
+       HOSTFILE_DIR="$(dirname $HOSTFILE)"
        BASEDHCPSTAMPFILE_CFG="${BASEDHCPSTAMPFILE}.${cfg}"
 
        # before we can call xappend
+       umask u=rwx,g=rx,o=rx
        mkdir -p /var/run/dnsmasq/
        mkdir -p $(dirname $CONFIGFILE)
-       mkdir -p $(dirname $HOSTFILE)
+       mkdir -p "$HOSTFILE_DIR"
        mkdir -p /var/lib/misc
        chown dnsmasq:dnsmasq /var/run/dnsmasq
 
@@ -1154,6 +1156,7 @@ dnsmasq_start()
        procd_add_jail_mount $EXTRA_MOUNT $RFC6761FILE $TRUSTANCHORSFILE
        procd_add_jail_mount $dnsmasqconffile $dnsmasqconfdir $resolvdir $user_dhcpscript
        procd_add_jail_mount /etc/passwd /etc/group /etc/TZ /etc/hosts /etc/ethers
+       [ "$HOSTFILE_DIR" != "/tmp" ] && procd_add_jail_mount "$HOSTFILE_DIR"
        procd_add_jail_mount_rw /var/run/dnsmasq/ $leasefile
 
        procd_close_instance
Read more comments on GitHub >

github_iconTop Results From Across the Web

daemon.err dnsmasq[6363]: failed to load names from /tmp ...
In system.log I found this logs each time I (re)start dnsmasq ... failed to load names from /tmp/hosts/dhcp.cfg01411c: Permission #7844.
Read more >
dnsmasq and permission denied reading /etc/hosts
Therefore, when dnsmasq attempts to read the file it throws an error (dnsmasq.log) ... dnsmasq[1740]: failed to load names from /etc/hosts: Permission denied....
Read more >
How do I start dnsmasq?
I have installed dnsmasq but I can't start it: $ dnsmasq dnsmasq: failed to create listening socket for 10.0.1.57: Permission denied $ sudo ......
Read more >
Dnsmasq unable to access log file
I know this answer comes late, but I found the solution. Just remove the log file and restart dnsmasq rm /tmp/dnsmasq.log systemctl restart ......
Read more >
ubuntu 15.10 - dnsmasq failed to restart
Restarting dnsmasq (via systemctl): dnsmasq.serviceJob for dnsmasq.service failed because the control process exited with error code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found