From: Wouter Wijngaards Date: Thu, 22 Oct 2015 07:06:31 +0000 (+0000) Subject: - Fix #712: unbound-anchor appears to not fsync root.key. X-Git-Tag: release-1.5.7rc1~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40c139cd8f753206ff803014378539658093fa92;p=thirdparty%2Funbound.git - Fix #712: unbound-anchor appears to not fsync root.key. git-svn-id: file:///svn/unbound/trunk@3512 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index 8f6cb5d10..99a5d70c2 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,6 @@ +22 October 2015: Wouter + - Fix #712: unbound-anchor appears to not fsync root.key. + 20 October 2015: Wouter - 1.5.6 release. - trunk tracks development of 1.5.7. diff --git a/smallapp/unbound-anchor.c b/smallapp/unbound-anchor.c index 92bfa8428..261c492c1 100644 --- a/smallapp/unbound-anchor.c +++ b/smallapp/unbound-anchor.c @@ -1828,6 +1828,8 @@ write_unsigned_root(const char* root_anchor_file) root_anchor_file); if(verb && errno != 0) printf("%s\n", strerror(errno)); } + fflush(out); + fsync(fileno(out)); fclose(out); } @@ -1854,6 +1856,8 @@ write_root_anchor(const char* root_anchor_file, BIO* ds) root_anchor_file); if(verb && errno != 0) printf("%s\n", strerror(errno)); } + fflush(out); + fsync(fileno(out)); fclose(out); } diff --git a/validator/autotrust.c b/validator/autotrust.c index e63b086e6..9c500e08e 100644 --- a/validator/autotrust.c +++ b/validator/autotrust.c @@ -1195,6 +1195,10 @@ void autr_write_file(struct module_env* env, struct trust_anchor* tp) fatal_exit("could not completely write: %s", fname); return; } + if(fflush(out) != 0) + log_err("could not fflush(%s): %s", fname, strerror(errno)); + if(fsync(fileno(out)) != 0) + log_err("could not fsync(%s): %s", fname, strerror(errno)); if(fclose(out) != 0) { fatal_exit("could not complete write: %s: %s", fname, strerror(errno));