Package: dpkg
Version: 1.10.28
Tags: patch

I've been bitten by bug #245562 recently and I came up with the following
patch to dpkg-divert.pl: basically, function checkrename() shouldn't
silently accept ENOENT as a non-error if it can't create the temporary file
for the target.

Note: I consider this a real bug that needs fixing because it can actually
cause files to disappear without notice. Not creating the directory I want
to divert to is my own error, but still dpkg-divert wouldn't do what it was
asked to do.

The patch is crude, but works for me. Maybe it should check for a writable
target only if the source actually exists.

-- 
Ciao, Flavio

--- dpkg-divert.pl-orig	2004-11-11 04:16:35.000000000 +0100
+++ dpkg-divert.pl	2005-06-13 00:26:01.000000000 +0200
@@ -219,16 +219,22 @@
     # 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) {
-	if (open (TMP, ">> ${file}.dpkg-devert.tmp")) {
-		close TMP;
-		unlink ("${file}.dpkg-devert.tmp");
-	} elsif ($! == ENOENT) {
-		$dorename = !$dorename;
-	} else {
-		&quit("error checking \`$file': $!");
-	}
+    if (open (TMP, ">> ${rsrc}.dpkg-devert.tmp")) {
+        close TMP;
+        unlink ("${rsrc}.dpkg-devert.tmp");
+    } elsif ($! == ENOENT) {
+        $dorename = !$dorename;
+    } else {
+        &quit("error checking \`$rsrc': $!");
     }
+
+    if (open (TMP, ">> ${rdest}.dpkg-devert.tmp")) {
+        close TMP;
+        unlink ("${rdest}.dpkg-devert.tmp");
+    } else {
+        &quit("error checking \`$rdest': $!");
+    }
+
     if (@ssrc && @sdest &&
         !($ssrc[0] == $sdest[0] && $ssrc[1] == $sdest[1])) {
         &quit("rename involves overwriting \`$rdest' with\n".

Reply via email to