mirror of git://git.gnupg.org/gnupg.git
dirmngr: This towel should better detect a changed resolv.conf.
* dirmngr/dns-stuff.c (resolv_conf_changed_p): Fix initialization time
issue.
--
Fixes-commit: b5f356e9fb
Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
b5f356e9fb
commit
de3a0988ef
|
@ -407,21 +407,23 @@ resolv_conf_changed_p (void)
|
||||||
static time_t last_mtime;
|
static time_t last_mtime;
|
||||||
const char *fname = RESOLV_CONF_NAME;
|
const char *fname = RESOLV_CONF_NAME;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
int changed;
|
int changed = 0;
|
||||||
|
|
||||||
if (stat (fname, &statbuf))
|
if (stat (fname, &statbuf))
|
||||||
{
|
{
|
||||||
log_error ("stat'ing '%s' failed: %s\n",
|
log_error ("stat'ing '%s' failed: %s\n",
|
||||||
fname, gpg_strerror (gpg_error_from_syserror ()));
|
fname, gpg_strerror (gpg_error_from_syserror ()));
|
||||||
changed = 0;
|
|
||||||
last_mtime = 1; /* Force a "changed" result the next time stat
|
last_mtime = 1; /* Force a "changed" result the next time stat
|
||||||
* works. */
|
* works. */
|
||||||
}
|
}
|
||||||
else
|
else if (!last_mtime)
|
||||||
|
last_mtime = statbuf.st_mtime;
|
||||||
|
else if (last_mtime != statbuf.st_mtime)
|
||||||
{
|
{
|
||||||
changed = last_mtime && (last_mtime != statbuf.st_mtime);
|
changed = 1;
|
||||||
last_mtime = statbuf.st_mtime;
|
last_mtime = statbuf.st_mtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue