This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.27.9000-90-g999a6da


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  999a6dab3ee1c8e77bb348ba2389e7aeb5c062b2 (commit)
      from  52a01100ad011293197637e42b5be1a479a2f4ae (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=999a6dab3ee1c8e77bb348ba2389e7aeb5c062b2

commit 999a6dab3ee1c8e77bb348ba2389e7aeb5c062b2
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Feb 21 10:42:48 2018 +0100

    ldconfig: Sync temporary files to disk before renaming them [BZ #20890]
    
    If the system crashes before the file data has been written to disk, the
    file system recovery upon the next mount may restore a partially
    rewritten temporary file under the non-temporary (final) name (after the
    rename operation).

diff --git a/ChangeLog b/ChangeLog
index a56f1fa..25b8e12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2018-02-21  Florian Weimer  <fweimer@redhat.com>
 
+	[BZ #20890]
+	* elf/cache.c (save_cache): Call fsync on temporary file before
+	renaming it.
+	(save_aux_cache): Call fdatasync on temporary file before renaming
+	it.
+
+2018-02-21  Florian Weimer  <fweimer@redhat.com>
+
 	[BZ #22787]
 	* include/caller.h: Remove file.
 	* elf/dl-caller.c: Likewise.
diff --git a/elf/cache.c b/elf/cache.c
index c2c010f..e63979d 100644
--- a/elf/cache.c
+++ b/elf/cache.c
@@ -454,8 +454,7 @@ save_cache (const char *cache_name)
 	error (EXIT_FAILURE, errno, _("Writing of cache data failed"));
     }
 
-  if (write (fd, strings, total_strlen) != (ssize_t) total_strlen
-      || close (fd))
+  if (write (fd, strings, total_strlen) != (ssize_t) total_strlen)
     error (EXIT_FAILURE, errno, _("Writing of cache data failed"));
 
   /* Make sure user can always read cache file */
@@ -464,6 +463,10 @@ save_cache (const char *cache_name)
 	   _("Changing access rights of %s to %#o failed"), temp_name,
 	   S_IROTH|S_IRGRP|S_IRUSR|S_IWUSR);
 
+  /* Make sure that data is written to disk.  */
+  if (fsync (fd) != 0 || close (fd) != 0)
+    error (EXIT_FAILURE, errno, _("Writing of cache data failed"));
+
   /* Move temporary to its final location.  */
   if (rename (temp_name, cache_name))
     error (EXIT_FAILURE, errno, _("Renaming of %s to %s failed"), temp_name,
@@ -818,7 +821,8 @@ save_aux_cache (const char *aux_cache_name)
 
   if (write (fd, file_entries, file_entries_size + total_strlen)
       != (ssize_t) (file_entries_size + total_strlen)
-      || close (fd))
+      || fdatasync (fd) != 0
+      || close (fd) != 0)
     {
       unlink (temp_name);
       goto out_fail;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog   |    8 ++++++++
 elf/cache.c |   10 +++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]