summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Thykier <niels@thykier.net>2016-04-11 18:12:35 +0000
committerNiels Thykier <niels@thykier.net>2016-04-11 18:12:35 +0000
commit1418796f85ce27401673442e19977957d94079fe (patch)
tree2acc13a7380699d462e89ce0278bf1fef83d0656
parentb41377e08c4c5ccabb00e608031fcf14e0a15e8d (diff)
downloaddebhelper-1418796f85ce27401673442e19977957d94079fe.tar.gz
dh_compress: Resolve tmpdir to handle symlinks
Signed-off-by: Niels Thykier <niels@thykier.net>
-rw-r--r--debian/changelog4
-rwxr-xr-xdh_compress8
2 files changed, 9 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog
index 3c5d7dc9..ba689d17 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,10 @@ debhelper (9.20160403+unreleased) UNRELEASED; urgency=medium
* dh: Fix bug where "--help" or "--list" would not work
unless "debian/compat" existed and had a supported
compat level. (Closes: #820508)
+ * dh_compress: Gracefully handle debian (or any other
+ path segment in the package "tmpdir") being a symlink
+ pointing outside the same directory. Thanks to
+ Bernhard Miklautz for the report. (Closes: #820711)
-- Niels Thykier <niels@thykier.net> Sat, 09 Apr 2016 09:20:32 +0000
diff --git a/dh_compress b/dh_compress
index fe3d6cbe..55f73863 100755
--- a/dh_compress
+++ b/dh_compress
@@ -179,7 +179,9 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
if ($norm_from_dir !~ m{^/}) {
$norm_from_dir = "${olddir}/${tmp}";
}
- my @normalized = normalize_paths($norm_from_dir, $tmp, @f);
+ my $resolved = abs_path($norm_from_dir)
+ or error("Cannot resolve $norm_from_dir: $!");
+ my @normalized = normalize_paths($norm_from_dir, $resolved, $tmp, @f);
my %uniq_f; @uniq_f{@normalized} = ();
@f = sort keys %uniq_f;
@@ -225,7 +227,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
}
sub normalize_paths {
- my ($cwd, $tmp, @paths) = @_;
+ my ($cwd, $cwd_resolved, $tmp, @paths) = @_;
my @normalized;
my $prefix = qr{\Q${tmp}/};
@@ -242,7 +244,7 @@ sub normalize_paths {
warning(qq{Interpreted "$path" as "$alt"});
}
error("${abs} does not exist") if not -e $abs;
- push(@normalized, abs2rel($abs, $cwd));
+ push(@normalized, abs2rel($abs, $cwd_resolved));
}
return @normalized;
}