]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: store the mtime of the file we read
authorLennart Poettering <lennart@poettering.net>
Fri, 8 Dec 2017 15:53:36 +0000 (16:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 8 Dec 2017 16:25:08 +0000 (17:25 +0100)
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

index a84b0fde1c79c44853aa1470d859d06901831c55..48105eef0c0a7cc8e93acd3b022d69d59d93a8cd 100644 (file)
@@ -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