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.
This commit is contained in:
Lennart Poettering 2017-12-08 16:53:36 +01:00
parent 043d392878
commit ace68cd711

View 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