summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-resolv-conf.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-12-08 16:53:36 +0100
committerLennart Poettering <lennart@poettering.net>2017-12-08 17:25:08 +0100
commitace68cd7117869fdeb3b3c352ae5eca730111830 (patch)
treed394760cf009cbf6744280bf1dd15663e17a0237 /src/resolve/resolved-resolv-conf.c
parent043d3928780b474c38c3d7d0f5a5ef785fd7bc10 (diff)
downloadsystemd-ace68cd7117869fdeb3b3c352ae5eca730111830.tar.gz
resolved: store the mtime of the file we read
Let's make sure we use the mtime of the current fstat() data, rather than the mtime of the old stat(), fixing a theoretical race.
Diffstat (limited to 'src/resolve/resolved-resolv-conf.c')
-rw-r--r--src/resolve/resolved-resolv-conf.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/resolve/resolved-resolv-conf.c b/src/resolve/resolved-resolv-conf.c
index a84b0fde1c..48105eef0c 100644
--- a/src/resolve/resolved-resolv-conf.c
+++ b/src/resolve/resolved-resolv-conf.c
@@ -56,7 +56,6 @@ int manager_read_resolv_conf(Manager *m) {
_cleanup_fclose_ FILE *f = NULL;
struct stat st;
char line[LINE_MAX];
- usec_t t;
int r;
assert(m);
@@ -77,8 +76,7 @@ int manager_read_resolv_conf(Manager *m) {
}
/* Have we already seen the file? */
- t = timespec_load(&st.st_mtim);
- if (t == m->resolv_conf_mtime)
+ if (timespec_load(&st.st_mtim) == m->resolv_conf_mtime)
return 0;
if (file_is_our_own(&st))
@@ -131,7 +129,7 @@ int manager_read_resolv_conf(Manager *m) {
}
}
- m->resolv_conf_mtime = t;
+ m->resolv_conf_mtime = timespec_load(&st.st_mtim);
/* Flush out all servers and search domains that are still
* marked. Those are then ones that didn't appear in the new