Explorar el Código

dpkg-source -x: create temporary directory next to the target place

* scripts/Dpkg/Source/Archive.pm (extract): Do not create the temp
directory in the current directory but in the parent directory of
the target directory. Otherwise the code would fail when called
from a non-writable dir and rename could fail due to filesystem
boundaries beetwen the current dir and the target one.
Raphael Hertzog hace 17 años
padre
commit
23cb6dedb1
Se han modificado 3 ficheros con 17 adiciones y 1 borrados
  1. 8 0
      ChangeLog
  2. 3 0
      debian/changelog
  3. 6 1
      scripts/Dpkg/Source/Archive.pm

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-12-01  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/Dpkg/Source/Archive.pm (extract): Do not create the temp
+	directory in the current directory but in the parent directory of
+	the target directory. Otherwise the code would fail when called
+	from a non-writable dir and rename could fail due to filesystem
+	boundaries beetwen the current dir and the target one.
+
 2008-12-01  Modestas Vainius  <modestas@vainius.eu>
 
 	* scripts/dpkg-shlibdeps.pl: Don't merge all dependency templates

+ 3 - 0
debian/changelog

@@ -7,6 +7,9 @@ dpkg (1.14.24) UNRELEASED; urgency=low
     symbols file. It was merging all dependency templates into the generated
     dependency instead of simply modifying the minimal version. Thanks to
     Modestas Vainius <modestas@vainius.eu>. Closes: #507346
+  * Fix dpkg-source to correctly extract a source package even when called
+    from a non-writable directory when a target directory has been specified
+    on the command line. Closes: #507217, #507219
 
  -- Guillem Jover <guillem@debian.org>  Tue, 18 Nov 2008 12:40:33 +0200
 

+ 6 - 1
scripts/Dpkg/Source/Archive.pm

@@ -28,6 +28,7 @@ use POSIX;
 use File::Temp qw(tempdir);
 use File::Basename qw(basename);
 use File::Spec;
+use Cwd;
 
 use base 'Dpkg::Source::CompressedFile';
 
@@ -103,7 +104,11 @@ sub extract {
         $tmp = $dest; # So that fixperms call works
     } else {
         my $template = basename($self->get_filename()) .  ".tmp-extract.XXXXX";
-        $tmp = tempdir($template, DIR => getcwd(), CLEANUP => 1);
+        unless (-e $dest) {
+            # Kludge so that realpath works
+            mkdir($dest) || syserr(_g("cannot create directory %s"), $dest);
+        }
+        $tmp = tempdir($template, DIR => Cwd::realpath("$dest/.."), CLEANUP => 1);
         $fork_opts{"chdir"} = $tmp;
     }