Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#4085 - dnsmasq: cannot open or create lease file /tmp/dhcp.leases: Read-only file system #9064

Open
openwrt-bot opened this issue Oct 14, 2021 · 12 comments
Labels

Comments

@openwrt-bot
Copy link

openwrt-bot commented Oct 14, 2021

bittorf:

with a selfcompiled r17753 with mipsel ramips/mt7621 on 'TP-LINK Archer C6U'
It was working without these issues with r17560

Thu Oct 14 18:32:38 2021 user.err : jail: creat(/tmp/ujail-lhNbFK/tmp/dhcp.leases) failed: Read-only file system
Thu Oct 14 18:32:38 2021 daemon.crit dnsmasq[1]: cannot open or create lease file /tmp/dhcp.leases: Read-only file system
Thu Oct 14 18:32:38 2021 daemon.crit dnsmasq[1]: FAILED to start up
Thu Oct 14 18:32:43 2021 user.err : jail: creat(/tmp/ujail-FlhCEP/tmp/dhcp.leases) failed: Read-only file system
Thu Oct 14 18:32:43 2021 daemon.crit dnsmasq[1]: cannot open or create lease file /tmp/dhcp.leases: Read-only file system
Thu Oct 14 18:32:43 2021 daemon.crit dnsmasq[1]: FAILED to start up
Thu Oct 14 18:32:49 2021 user.err : jail: creat(/tmp/ujail-fHEJCC/tmp/dhcp.leases) failed: Read-only file system
Thu Oct 14 18:32:49 2021 daemon.crit dnsmasq[1]: cannot open or create lease file /tmp/dhcp.leases: Read-only file system
Thu Oct 14 18:32:49 2021 daemon.crit dnsmasq[1]: FAILED to start up
Thu Oct 14 18:32:50 2021 daemon.alert kalua: /usr/sbin/cron.monitorin: curl_it() [ERR] returning 4 after fetching 'http://intercity-vpn.de/networ...'
Thu Oct 14 18:32:54 2021 user.err : jail: creat(/tmp/ujail-jGfjpp/tmp/dhcp.leases) failed: Read-only file system
Thu Oct 14 18:32:54 2021 daemon.crit dnsmasq[1]: cannot open or create lease file /tmp/dhcp.leases: Read-only file system
Thu Oct 14 18:32:54 2021 daemon.crit dnsmasq[1]: FAILED to start up
Thu Oct 14 18:32:59 2021 user.err : jail: creat(/tmp/ujail-knefoG/tmp/dhcp.leases) failed: Read-only file system
Thu Oct 14 18:32:59 2021 daemon.crit dnsmasq[1]: cannot open or create lease file /tmp/dhcp.leases: Read-only file system
Thu Oct 14 18:32:59 2021 daemon.crit dnsmasq[1]: FAILED to start up
Thu Oct 14 18:33:02 2021 daemon.alert kalua: /usr/sbin/cron.monitorin: curl_it() [ERR] returning 4 after fetching 'http://intercity-vpn.de/networ...'
Thu Oct 14 18:33:04 2021 user.err : jail: creat(/tmp/ujail-jneGLN/tmp/dhcp.leases) failed: Read-only file system
Thu Oct 14 18:33:04 2021 daemon.crit dnsmasq[1]: cannot open or create lease file /tmp/dhcp.leases: Read-only file system
Thu Oct 14 18:33:04 2021 daemon.crit dnsmasq[1]: FAILED to start up
Thu Oct 14 18:33:04 2021 daemon.info procd: Instance dnsmasq::cfg01411c s in a crash loop 6 crashes, 0 seconds since last crash

The filesystem looks normal:

root@box:~ :) df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 5.5M      5.5M         0 100% /rom
tmpfs                    59.4M      1.3M     58.1M   2% /tmp
/dev/mtdblock4            7.4M    476.0K      7.0M   6% /overlay
overlayfs:/overlay        7.4M    476.0K      7.0M   6% /
tmpfs                   512.0K         0    512.0K   0% /dev

root@liszt28-hybrid--37:~ :) echo foo >/tmp/dhcp.leases.txt 

root@liszt28-hybrid--37:~ :) ls -l /tmp/dhcp.leases.txt
-rw-r--r--    1 root     root             4 Oct 14 18:37 /tmp/dhcp.leases.txt

root@liszt28-hybrid--37:~ :) ps | grep jail
 3898 root      2616 S    {hostapd} /sbin/ujail -n hostapd -U network -G network -C /etc/capabilities/wpad.json -c -- /usr/sbin/hostapd -s -g /var/run/hostapd/global
 3899 root      2616 S    {wpa_supplicant} /sbin/ujail -n wpa_supplicant -U network -G network -C /etc/capabilities/wpad.json -c -- /usr/sbin/wpa_supplicant -n -s -g /var/run/wpa_supplican
 4489 root      1280 S    grep jail

root@liszt28-hybrid--37:~ :) pidof dnsmasq || echo BAD
BAD

root@liszt28-hybrid--37:~ :) uci show dhcp
dhcp.@dnsmasq[0]=dnsmasq
dhcp.@dnsmasq[0].logqueries='0'
dhcp.@dnsmasq[0].domainneeded='0'
dhcp.@dnsmasq[0].boguspriv='1'
dhcp.@dnsmasq[0].filterwin2k='0'
dhcp.@dnsmasq[0].localise_queries='1'
dhcp.@dnsmasq[0].rebind_protection='0'
dhcp.@dnsmasq[0].rebind_localhost='0'
dhcp.@dnsmasq[0].expandhosts='1'
dhcp.@dnsmasq[0].nonegcache='0'
dhcp.@dnsmasq[0].authoritative='1'
dhcp.@dnsmasq[0].readethers='1'
dhcp.@dnsmasq[0].leasefile='/tmp/dhcp.leases'
dhcp.@dnsmasq[0].resolvfile='/tmp/resolv.conf.auto'
dhcp.@dnsmasq[0].addnhosts='/var/run/hosts_olsr' '/etc/local.hosts'
dhcp.@dnsmasq[0].server='8.8.8.8'
dhcp.@dnsmasq[0].notinterface='wan' 'wlan' 'wlanRADIO1'
dhcp.@dnsmasq[0].dhcpscript='/etc/dhcp-script.d/10dhcpscript'
dhcp.@dnsmasq[0].cachesize='1000'
dhcp.@dnsmasq[0].local='/internet/'
dhcp.@dnsmasq[0].domain='internet'
dhcp.lan=dhcp
dhcp.lan.interface='lan'
dhcp.lan.start='34'
dhcp.lan.limit='13'
dhcp.lan.force='1'
dhcp.lan.ignore='0'
dhcp.lan.leasetime='48h'
dhcp.wlan=dhcp
dhcp.wlan.force='1'
dhcp.wlan.ignore='0'
dhcp.wlan.interface='mastergate'
dhcp.wlan.dhcp_option='3,100.64.0.1' '6,100.64.0.1'
dhcp.wlan.leasetime='12h'
dhcp.wlan.start='100.65.35.2'
dhcp.wlan.limit='253'
dhcp.wan=dhcp
dhcp.wan.interface='wan'
dhcp.wan.ignore='1'
dhcp.@host[0]=host
dhcp.@host[0].ip='127.0.0.2'
dhcp.@host[0].mac='00:00:00:00:00:00'
dhcp.@host[0].name='lo-alias'
dhcp.@dhcp[3]=dhcp
dhcp.@dhcp[3].interface='loopback'
dhcp.@dhcp[3].start='2'
dhcp.@dhcp[3].limit='2'
dhcp.@dhcp[3].leasetime='1h'
dhcp.@dhcp[3].force='1'
dhcp.@dhcp[3].ignore='0'
@openwrt-bot
Copy link
Author

bittorf:

reverting this commit fixes it for me:

commit 44f694ba1bca1417d24e851c637c284f9f78c06d Author: Daniel Golle Date: Wed Oct 21 15:04:17 2020 +0100
build: select procd-ujail if !SMALL_FLASH

Add procd-ujail to DEFAULT_PACKAGES if not building for
space-constraint (FEATURES:=small_flash) targets.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>

@RussianNeuroMancer
Copy link

Same issue on 22.03.0rc1 build for armvirt64 target after restoring old configuration tar.

@discordianfish
Copy link

Same with rc4, also worked fine until restoring config

@discordianfish
Copy link

opkg remove procd-ujail seems to have fixed it

@VasoVV
Copy link

VasoVV commented Sep 2, 2022

opkg remove procd-ujail seems to have fixed it

nice
it sounds like: "I can't connect to my PC via RDP. Okay, I've found a problem -- it's a firewall. Disabling it solved a problem" 😄

I guess we can set another location for dhcp.leases in /etc/config/dhcp, until this issue will be fixed. E.g.:

uci set dhcp.@dnsmasq[0].leasefile='/var/run/dnsmasq/dhcp.leases'

@johnfzc
Copy link
Contributor

johnfzc commented Sep 8, 2022

This issue in 22.03 is caused by the resolvfile setting, if you import an old configuration that looks like this the service will fail as described above:

     option resolvfile '/tmp/resolv.conf.auto'

If you update it to match the default 22.03 configuration as follows then the service will start correctly:

option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'

I do not understand why, or what the relationship is with the error reported for /tmp/dhcp.leases.

@VasoVV
Copy link

VasoVV commented Sep 9, 2022

The root of the problem is that the 22.xx brings the procd-ujail package (in spite of the flash size, BTW), which makes files in /tmp/ read-only for dnsmasq. More info here
Thus those pure soles who have their configuration migrated from ancient releases (where the default location for resolv.conf.auto and dhcp.leases was in /tmp/) got the issue.
As a workaround, they can remove procd-ujail package (as @discordianfish says), or change the location of the files according to the latest configuration.

I see two parallel solutions for the issue:

  1. 22.xx should not install a procd-ujail where it wasn't installed before (especially where the flash size is insufficient)
  2. Autofix or ask a user before upgrading to change the location of the resolv.conf.auto or/and dhcp.leases wherever from /tmp.

@hamelg
Copy link

hamelg commented Dec 13, 2022

I updated to 22.03 and had this problem. After changing the resolvfile option as instructed by johnfzc, the dnsmasq starts. But a few seconds after dnsmasq successfully started, openwrt restarts. I can't understand why ? I see several ubus messages with ubus monitor just before reboot but no explication in logs. procd-ujail completely breaks my openwrt. The only solution is to simply uninstall the procd-ujail package.

@hamelg
Copy link

hamelg commented Dec 15, 2022

I found out why my openwrt reboots when dnsmasq is started with ujail.
A script is scheduled in my crontab to scrape dnsmasq metrics by sending a signal :

kill -USR1 $(cat /var/run/dnsmasq/dnsmasq.cfg01411c.pid)

As ujail starts dnsmaq in a container with another pid namespace, the pid of dnsmaq is 1.
Kill -USR1 1 triggers a reboot.

So, when the device is configured fine, proc-ujail works as expected.

@xiaozhuai
Copy link

Had the same problem recently on 22.03.0. Simply remove procd-ujail solved my problem.
I hate procd-ujail, it waste my two hours to solve the problem, and mess up my configurations.

@Brightchu
Copy link

This issue in 22.03 is caused by the resolvfile setting, if you import an old configuration that looks like this the service will fail as described above:

     option resolvfile '/tmp/resolv.conf.auto'

If you update it to match the default 22.03 configuration as follows then the service will start correctly:

option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'

I do not understand why, or what the relationship is with the error reported for /tmp/dhcp.leases.

yep, thanks a lot. it solves my problem

@johnfzc
Copy link
Contributor

johnfzc commented Mar 25, 2024

@hauke I think this issue can be closed , correcting the option resolvfile setting in /etc/config/dhcp to:

option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'

will resolve the problem. You can also remove procd-ujail if you prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants