mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 09:21:26 +03:00
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:
parent
043d392878
commit
ace68cd711
@ -56,7 +56,6 @@ int manager_read_resolv_conf(Manager *m) {
|
|||||||
_cleanup_fclose_ FILE *f = NULL;
|
_cleanup_fclose_ FILE *f = NULL;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char line[LINE_MAX];
|
char line[LINE_MAX];
|
||||||
usec_t t;
|
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(m);
|
assert(m);
|
||||||
@ -77,8 +76,7 @@ int manager_read_resolv_conf(Manager *m) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Have we already seen the file? */
|
/* Have we already seen the file? */
|
||||||
t = timespec_load(&st.st_mtim);
|
if (timespec_load(&st.st_mtim) == m->resolv_conf_mtime)
|
||||||
if (t == m->resolv_conf_mtime)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (file_is_our_own(&st))
|
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
|
/* Flush out all servers and search domains that are still
|
||||||
* marked. Those are then ones that didn't appear in the new
|
* marked. Those are then ones that didn't appear in the new
|
||||||
|
Loading…
Reference in New Issue
Block a user