summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-27 00:15:28 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-27 00:46:51 +0100
commitbf7fabd6000fd95495904ed55db62caf361b3d8f (patch)
tree7027bb6693e042cd6c6d63da85db69b0ab7a2894
parent8a7a7e971e97830fd722fb73ef87f7180180cc27 (diff)
resolved: don't clear the server list too eagerly
If /etc/resolv.conf is missing, this should not result in the server list to be cleared, after all the native data from resolved.conf shouldn't be flushed out then. Hence flush out the data only if /etc/resolv.conf exists, but we cannot read it for some reason.
-rw-r--r--src/resolve/resolved-resolv-conf.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/resolve/resolved-resolv-conf.c b/src/resolve/resolved-resolv-conf.c
index 744969b745..63bde1c2f4 100644
--- a/src/resolve/resolved-resolv-conf.c
+++ b/src/resolve/resolved-resolv-conf.c
@@ -50,9 +50,9 @@ int manager_read_resolv_conf(Manager *m) {
r = stat("/etc/resolv.conf", &st);
if (r < 0) {
if (errno == ENOENT)
- r = 0;
- else
- r = log_warning_errno(errno, "Failed to stat /etc/resolv.conf: %m");
+ return 0;
+
+ r = log_warning_errno(errno, "Failed to stat /etc/resolv.conf: %m");
goto clear;
}
@@ -61,22 +61,18 @@ int manager_read_resolv_conf(Manager *m) {
if (t == m->resolv_conf_mtime)
return 0;
- m->resolv_conf_mtime = t;
-
/* Is it symlinked to our own file? */
if (stat("/run/systemd/resolve/resolv.conf", &own) >= 0 &&
st.st_dev == own.st_dev &&
- st.st_ino == own.st_ino) {
- r = 0;
- goto clear;
- }
+ st.st_ino == own.st_ino)
+ return 0;
f = fopen("/etc/resolv.conf", "re");
if (!f) {
if (errno == ENOENT)
- r = 0;
- else
- r = log_warning_errno(errno, "Failed to open /etc/resolv.conf: %m");
+ return 0;
+
+ r = log_warning_errno(errno, "Failed to open /etc/resolv.conf: %m");
goto clear;
}
@@ -115,6 +111,8 @@ int manager_read_resolv_conf(Manager *m) {
}
}
+ m->resolv_conf_mtime = t;
+
/* Flush out all servers and search domains that are still
* marked. Those are then ones that didn't appear in the new
* /etc/resolv.conf */