Bug#759497: don't break hardlinks

2014-08-27 Thread djcj

Package: patchelf
Version: 0.8-2

Patchelf breaks hardlinks. The attached patch will fix that.
See also: https://github.com/NixOS/patchelf/issues/32

--- a/src/patchelf.cc
+++ b/src/patchelf.cc
@@ -360,19 +360,10 @@
 
 static void writeFile(string fileName, mode_t fileMode)
 {
-string fileName2 = fileName + _patchelf_tmp;
-
-int fd = open(fileName2.c_str(),
-O_CREAT | O_TRUNC | O_WRONLY, 0700);
+int fd = open(fileName.c_str(), O_TRUNC | O_WRONLY);
 if (fd == -1) error(open);
-
 if (write(fd, contents, fileSize) != fileSize) error(write);
-
 if (close(fd) != 0) error(close);
-
-if (chmod(fileName2.c_str(), fileMode) != 0) error(chmod);
-
-if (rename(fileName2.c_str(), fileName.c_str()) != 0) error(rename);
 }
 
 
@@ -1122,7 +1113,7 @@
 
 if (elfFile.isChanged()){
 elfFile.rewriteSections();
-writeFile(fileName, fileMode);
+writeFile(fileName);
 }
 }
 


Bug#759497: don't break hardlinks

2014-08-27 Thread Felipe Sateler
Hi,

On Wed, Aug 27, 2014 at 1:51 PM, djcj d...@gmx.de wrote:
 Package: patchelf
 Version: 0.8-2

 Patchelf breaks hardlinks. The attached patch will fix that.
 See also: https://github.com/NixOS/patchelf/issues/32

This patch also makes patchelf vulnerable to data loss: if patchelf is
interrupted/the disk fails/power is turned off/aliens attack, then the
operated file could be rendered unusable.

This could have a bad impact if running this tool against a system binary.

-- 

Saludos,
Felipe Sateler


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org