From 84e1f3e96f1c3dd8d99afc6fcb020c7d77b7ca2f Mon Sep 17 00:00:00 2001 From: Flavio Stanchina Date: Thu, 27 Dec 2007 08:26:44 +0200 Subject: [PATCH] dpkg-divert: Fail when diverting to a non existent directory Closes: #245562 --- ChangeLog | 5 +++++ debian/changelog | 2 ++ scripts/dpkg-divert.pl | 23 ++++++++++++++--------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bc9e517..25c7f686 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-12-27 Flavio Stanchina + + * scripts/dpkg-divert.pl (checkrename): Do not ignore ENOENT for + destination. + 2007-12-27 Daniel Leidert Guillem Jover diff --git a/debian/changelog b/debian/changelog index f84c8ca9..5a20f20f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -45,6 +45,8 @@ dpkg (1.14.13) UNRELEASED; urgency=low Closes: #76295, #246906, #433567, #451872, #220044, #392440, #441021 Closes: #443241 Based on a patch by Daniel Leidert . + * Fail when diverting to a non existent directory. Closes: #245562 + Thanks to Flavio Stanchina . [ Updated dpkg translations ] * Swedish (Peter Karlsson) diff --git a/scripts/dpkg-divert.pl b/scripts/dpkg-divert.pl index 88c3f7d5..6eeb8188 100755 --- a/scripts/dpkg-divert.pl +++ b/scripts/dpkg-divert.pl @@ -237,15 +237,20 @@ sub checkrename { # same name as the diversions but with an extension that # (hopefully) wont overwrite anything. If it succeeds, we # assume a writable filesystem. - foreach my $file ($rsrc, $rdest) { - if (open (TMP, ">> ${file}.dpkg-devert.tmp")) { - close TMP; - unlink ("${file}.dpkg-devert.tmp"); - } elsif ($! == ENOENT) { - $dorename = !$dorename; - } else { - &quit(sprintf(_g("error checking \`%s': %s"), $file, $!)); - } + if (open (TMP, ">>", "${rsrc}.dpkg-devert.tmp")) { + close TMP; + unlink ("${rsrc}.dpkg-devert.tmp"); + } elsif ($! == ENOENT) { + $dorename = !$dorename; + } else { + quit(sprintf(_g("error checking \`%s': %s"), $rsrc, $!)); + } + + if (open (TMP, ">>", "${rdest}.dpkg-devert.tmp")) { + close TMP; + unlink ("${rdest}.dpkg-devert.tmp"); + } else { + quit(sprintf(_g("error checking \`%s': %s"), $rdest, $!)); } if (@ssrc && @sdest && !($ssrc[0] == $sdest[0] && $ssrc[1] == $sdest[1])) { -- 2.39.5