From 1418796f85ce27401673442e19977957d94079fe Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Mon, 11 Apr 2016 18:12:35 +0000 Subject: dh_compress: Resolve tmpdir to handle symlinks Signed-off-by: Niels Thykier --- debian/changelog | 4 ++++ dh_compress | 8 +++++--- 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 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; } -- cgit v1.2.3