From: Ben Collins Date: Fri, 29 Oct 1999 14:36:43 +0000 (+0000) Subject: * dpkg-divert: Fix check for writable filesystem, closes: #48646 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad8957a34d5113c002dacf8468827463b840a052;p=dpkg * dpkg-divert: Fix check for writable filesystem, closes: #48646 --- diff --git a/ChangeLog b/ChangeLog index 7ba5d0bd..9825017d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Oct 29 10:37:16 EDT 1999 Ben Collins + + * dpkg-divert: Fix check for writable filesystem, closes: #48646 + Thu Oct 28 22:14:49 CEST 1999 Wichert Akkerman * Add Polish translation from Piotr Roszatycki UNRELEASED diff --git a/scripts/dpkg-divert.pl b/scripts/dpkg-divert.pl index f8252373..bc5de590 100755 --- a/scripts/dpkg-divert.pl +++ b/scripts/dpkg-divert.pl @@ -176,23 +176,21 @@ sub infol { sub checkrename { return unless $dorename; ($rsrc,$rdest) = @_; - my %exist; (@ssrc= lstat($rsrc)) || $! == &ENOENT || &quit("cannot stat old name \`$rsrc': $!"); - $exist{$rsrc} = 1 unless $! != &ENOENT; (@sdest= lstat($rdest)) || $! == &ENOENT || &quit("cannot stat new name \`$rdest': $!"); - $exist{$rdest} = 1 unless $! != &ENOENT; # Unfortunately we have to check for write access in both # places, just having +w is not enough, since people do # mount things RO, and we need to fail before we start - # mucking around with things + # mucking around with things. So we open a file with the + # same name as the diversions but with an extension that + # (hopefully) wont overwrite anything. If it succeeds, we + # assume a writable filesystem. foreach $file ($rsrc,$rdest) { - open (TMP, ">> $file") || &quit("error checking \`$file': $!"); + open (TMP, ">> ${file}.dpkg-devert.tmp") || &quit("error checking \`$file': $!"); close TMP; - if ($exist{$file} == 1) { - unlink ("$file"); - } + unlink ("${file}.dpkg-devert.tmp"); } if (@ssrc && @sdest && !($ssrc[0] == $sdest[0] && $ssrc[1] == $sdest[1])) {