From cc130d7114425cc6f8c315e6cbc68be2cb4d3c38 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 30 Jan 2014 14:08:08 +0000 Subject: multicompress with externals sets wrong file modes Copy from the bug description: After we upgraded the Ubuntu master archive from lucid to precise, we noticed that Translation-en.bz2 was being written with mode 0600 rather than 0644, which broke our mirroring. This is no longer reproducible as such in unstable because apt now links against libbz2, but it's still reproducible with xz; it happens because multicompress fchmods one end of the compression pipe in this case rather than the target file. [Original testcase slightly modified to comply with house-style] Closes: 737130 --- ftparchive/multicompress.cc | 2 +- .../test-bug-737130-multicompress-file-modes | 30 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100755 test/integration/test-bug-737130-multicompress-file-modes diff --git a/ftparchive/multicompress.cc b/ftparchive/multicompress.cc index 265fb1a80..c1bd6037a 100644 --- a/ftparchive/multicompress.cc +++ b/ftparchive/multicompress.cc @@ -365,7 +365,7 @@ bool MultiCompress::Child(int const &FD) for (Files *I = Outputs; I != 0; I = I->Next) { // Set the correct file modes - fchmod(I->TmpFile.Fd(),Permissions); + chmod(I->TmpFile.Name().c_str(),Permissions); if (rename(I->TmpFile.Name().c_str(),I->Output.c_str()) != 0) _error->Errno("rename",_("Failed to rename %s to %s"), diff --git a/test/integration/test-bug-737130-multicompress-file-modes b/test/integration/test-bug-737130-multicompress-file-modes new file mode 100755 index 000000000..7df6339a2 --- /dev/null +++ b/test/integration/test-bug-737130-multicompress-file-modes @@ -0,0 +1,30 @@ +#!/bin/sh +set -e + +TESTDIR=$(readlink -f $(dirname $0)) +. $TESTDIR/framework +setupenvironment +configarchitecture 'i386' + +cat >aptarchive/ftparchive.conf <