chiark / gitweb /
dgit import: Avoid making broken symlinks in ..
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 Jul 2017 22:27:29 +0000 (23:27 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 16 Jul 2017 11:14:46 +0000 (12:14 +0100)
In most cases we could carry on and fail later.  But creating a broken
symlink is undesirable, particularly because it might prevent dgit
from trying to make a non-broken symlink pointing elsewhere in future
(or prevent dget from downloading the file).

Even worse, if the dsc is in .. but an absolute path was provided, we
would make a circular symlink!

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
dgit

index eeaeb1ff9d3c98d440d7edcdf4f2da3cef099214..ad43d412027e4ed8e6e87cf182e07feb4d30a78c 100644 (file)
@@ -7,6 +7,7 @@ dgit (3.12~) unstable; urgency=medium
     patch filenames.
   * dgit import: Defend against broken symlinks in ..
   * dgit import: Right error message for missing files in ..
+  * dgit import: Avoid making broken symlinks in ..
 
  --
 
diff --git a/dgit b/dgit
index 944de8592418be52f5fae781bdf2447a4439f418..dd3b31c717a60ab0562420f3fce5f3a439a8d929 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -6365,6 +6365,8 @@ END
        $there =~ s#/+[^/]+$## or
            fail "import $dscfn requires ../$f, but it does not exist";
        $there .= "/$f";
+       my $test = $there =~ m{^/} ? $there : "../$there";
+       stat $test or fail "import $dscfn requires $test, but: $!";
        symlink $there, $here or fail "symlink $there to $here: $!";
        progress "made symlink $here -> $there";
 #      print STDERR Dumper($fi);