Explorar el Código

dpkg: Defer hardlink renames to avoid breakage on unpack

This fixes two issues related to making the new file contents available
through an alternative but final path before

1) the one "carrying" the content has been fsync()ed, to avoid getting
garbage on system failure.

2) the deferred fsync() on the main path has been performed, avoiding
a possible error when reopening the file for writing if it's currently
under execution.

Deferring the hardlink is safe as they are always after the tar entry
containing the actual file data.

Regression introduced in commit 9cd41fdda1c27169c52d73b3b3ce71991d724994.

Closes: #635683

Reported-by: Niko Tyni <ntyni@debian.org>
Based-on-patch-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Guillem Jover <guillem@debian.org>
Guillem Jover hace 15 años
padre
commit
efcf279a50
Se han modificado 2 ficheros con 7 adiciones y 1 borrados
  1. 5 0
      debian/changelog
  2. 2 1
      src/archives.c

+ 5 - 0
debian/changelog

@@ -183,6 +183,11 @@ dpkg (1.16.1) UNRELEASED; urgency=low
     Closes: #293280
   * Add new --raw-extract option to dpkg-deb combining --control and
     --extract. Closes: #552123
+  * Defer hardlink renames so that there's never a point were the new
+    file contents are accessible from the final path before they have
+    been fsync()ed and cannot be executed causing ETXTBSY when trying
+    to open the to be installed paths for writing.
+    Thanks to Jonathan Nieder <jrnieder@gmail.com>. Closes: #635683
 
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312

+ 2 - 1
src/archives.c

@@ -851,7 +851,8 @@ tarobject(void *ctx, struct tar_entry *ti)
    * in .dpkg-new.
    */
 
-  if (ti->type == tar_filetype_file || ti->type == tar_filetype_symlink) {
+  if (ti->type == tar_filetype_file || ti->type == tar_filetype_hardlink ||
+      ti->type == tar_filetype_symlink) {
     nifd->namenode->flags |= fnnf_deferred_rename;
 
     debug(dbg_eachfiledetail, "tarobject done and installation deferred");