Bug 1131075

Summary: dnsmasq: directory /etc/resolv.conf for resolv-file is missing, cannot poll
Product: [openSUSE] openSUSE Distribution Reporter: Matwey Kornilov <matwey.kornilov>
Component: NetworkAssignee: Marius Tomaschewski <mt>
Status: RESOLVED DUPLICATE QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P2 - High CC: lnussel, max, rombert
Version: Leap 15.1   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Matwey Kornilov 2019-03-31 16:15:54 UTC
Hello,

I am running dnsmasq-2.78-lp151.4.1.armv7hl on Leap 15.1 and see the following when dnsmasq.service tries to start during boot:


Mar 31 19:11:39 localhost dnsmasq[993]: dnsmasq: syntax check OK.
Mar 31 19:11:39 localhost dnsmasq[998]: directory /etc/resolv.conf for resolv-file is missing, cannot poll
Mar 31 19:11:39 localhost dnsmasq[998]: dnsmasq: directory /etc/resolv.conf for resolv-file is missing, cannot poll
Mar 31 19:11:39 localhost dnsmasq[998]: FAILED to start up


localhost:~ # ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 30 Mar 31 17:31 /etc/resolv.conf -> /var/run/netconfig/resolv.conf
localhost:~ # cat /etc/resolv.conf 
### /etc/resolv.conf is a symlink to /var/run/netconfig/resolv.conf
### autogenerated by netconfig!
#
# Before you change this file manually, consider to define the
# static DNS configuration using the following variables in the
# /etc/sysconfig/network/config file:
#     NETCONFIG_DNS_STATIC_SEARCHLIST
#     NETCONFIG_DNS_STATIC_SERVERS
#     NETCONFIG_DNS_FORWARDER
# or disable DNS configuration updates via netconfig by setting:
#     NETCONFIG_DNS_POLICY=''
#
# See also the netconfig(8) manual page and other documentation.
#
### Call "netconfig update -f" to force adjusting of /etc/resolv.conf.
Comment 1 Ludwig Nussel 2019-04-01 09:07:26 UTC
Fallout from the move of resolv.conf to /run.

Marius, how about creating bot the symlink in /etc as well as the file in run via tmpfiles mechanism? That is done very early by systemd so that way we should be able to create a resolv.conf with only the stub header.
Comment 2 Ludwig Nussel 2019-04-01 09:07:53 UTC
Actually needinfo Marius..
Comment 3 Reinhard Max 2019-04-01 14:20:40 UTC
AFAICS there is nothing wrong with dnsmasq here, reassigning.
Comment 4 Reinhard Max 2019-04-01 14:26:29 UTC
Whoops, did everything except for the actual reassignment.
Comment 5 Reinhard Max 2019-04-01 14:39:29 UTC
Hmm - maybe it could also be fixed via service file dependencies.

I see that dnsmasq.service orders itself after network.target and before nss-lookup.target. Is there anything else it could hook to that makes sure it doesn't get started until /etc/resolve.conf is actually there?
Comment 6 Ludwig Nussel 2019-04-01 15:07:06 UTC
yes, there is network-online.target (mind bug 1130355). If dnsmasq monitors resolv.conf and can update itself when resolv.conf changes there should be no need to use that crutch though. We just need to make sure resolv.conf is there even when empty.
Comment 7 Reinhard Max 2019-04-01 16:00:12 UTC
I checked this again, and dnsmasq only needs the directory containing the resolv file for a successful startup, so that it can put an inotify on it. The resolv file itself does not need to exist and will be picked up by dnsmasq through inotify as soon as it appears.

So, either /etc or /var/run/netconfig must be missing at the point in time when dnsmasq fails to start. Unfortunately these two cases cannot be distinguished from the error message and I cannot imagine for either of the two to not exist at that point in time, given that dnsmasq orders itself After=network.target .
Comment 8 Matwey Kornilov 2019-04-01 16:06:45 UTC
/var/run is symlink to /run which is mounted as tmpfs.

# ls -l /var/run
lrwxrwxrwx 1 root root 4 Mar 31 07:49 /var/run -> /run
Comment 9 Matwey Kornilov 2019-04-01 16:10:45 UTC
Now I use

resolv-file=/var/run/netconfig/resolv.conf

in dnsmasq config to overcome symlink resolution.

dnsmasq still fails at the startup.

Apr 01 19:09:41 localhost dnsmasq[999]: dnsmasq: syntax check OK.
Apr 01 19:09:41 localhost dnsmasq[1005]: dnsmasq: directory /var/run/netconfig/resolv.conf for resolv-file is missing, cannot poll
Apr 01 19:09:41 localhost dnsmasq[1005]: directory /var/run/netconfig/resolv.conf for resolv-file is missing, cannot poll
Apr 01 19:09:41 localhost dnsmasq[1005]: FAILED to start up
Comment 10 Reinhard Max 2019-04-01 16:14:51 UTC
Does it work if you use this?

resolv-file=/run/netconfig/resolv.conf
Comment 11 Ludwig Nussel 2019-04-01 16:16:41 UTC
try

# echo "d /run/netconfig 0755 root root -" > /etc/tmpfiles.d/netconfig.conf
Comment 12 Matwey Kornilov 2019-04-01 16:21:33 UTC
(In reply to Reinhard Max from comment #10)
> Does it work if you use this?
> 
> resolv-file=/run/netconfig/resolv.conf

It still fails:

Apr 01 19:18:39 localhost dnsmasq[975]: dnsmasq: syntax check OK.
Apr 01 19:18:39 localhost dnsmasq[980]: dnsmasq: directory /run/netconfig/resolv.conf for resolv-file is missing, cannot poll
Apr 01 19:18:39 localhost dnsmasq[980]: directory /run/netconfig/resolv.conf for resolv-file is missing, cannot poll
Apr 01 19:18:39 localhost dnsmasq[980]: FAILED to start up
Comment 13 Reinhard Max 2019-04-01 16:29:08 UTC
In this case, Ludwig's suggestion from comment 11 should help and work even without a resolv-file line in the dnsmasq config.
Comment 14 Matwey Kornilov 2019-04-01 16:31:28 UTC
(In reply to Ludwig Nussel from comment #11)
> try
> 
> # echo "d /run/netconfig 0755 root root -" > /etc/tmpfiles.d/netconfig.conf

This makes dnsmasq successfully running both with

resolv-file=/run/netconfig/resolv.conf

and

resolv-file=/etc/resolv.conf
Comment 15 Marius Tomaschewski 2020-09-17 13:14:02 UTC
Duplicate of boo#1123699 where we've added it:

localhost:~ # cat /usr/1123699lib/tmpfiles.d/netconfig.conf
d /run/netconfig 0755 root root -
f /run/netconfig/resolv.conf 0644 root root -
f /run/netconfig/yp.conf 0644 root root -
L /etc/resolv.conf - - - - /run/netconfig/resolv.conf
L /etc/yp.conf - - - - /run/netconfig/yp.conf

*** This bug has been marked as a duplicate of bug 1123699 ***