From ace68cd7117869fdeb3b3c352ae5eca730111830 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 8 Dec 2017 16:53:36 +0100 Subject: [PATCH] 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. --- src/resolve/resolved-resolv-conf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/resolve/resolved-resolv-conf.c b/src/resolve/resolved-resolv-conf.c index a84b0fd..48105ee 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 -- 2.7.4