Kaynağa Gözat

dpkg-dev: fail when closing an output handle fails

This patch makes dpkg-gencontrol and dpkg-shlibdeps fail if their
call to close (on output handles) suggests an issue.  This prevents
them from silently producing incomplete files and may provide a
better error than the following rename failing.

Signed-off-by: Raphaël Hertzog <hertzog@debian.org>
Niels Thykier 15 yıl önce
ebeveyn
işleme
006e0f93a2

+ 1 - 0
debian/changelog

@@ -73,6 +73,7 @@ dpkg (1.16.1) UNRELEASED; urgency=low
     Closes: #603435
     Closes: #603435
   * dpkg-mergechangelogs now checks the return value of the close() call.
   * dpkg-mergechangelogs now checks the return value of the close() call.
     Thanks to Niels Thykier <niels@thykier.net> for the patch. Closes: #633539
     Thanks to Niels Thykier <niels@thykier.net> for the patch. Closes: #633539
+  * Similar changes to dpkg-shlibdeps and dpkg-gencontrol, also by Niels.
 
 
   [ Guillem Jover ]
   [ Guillem Jover ]
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520

+ 1 - 1
scripts/dpkg-gencontrol.pl

@@ -375,7 +375,7 @@ $fields->apply_substvars($substvars);
 $fields->output($fh_output);
 $fields->output($fh_output);
 
 
 if (!$stdout) {
 if (!$stdout) {
-    close($fh_output);
+    close($fh_output) || syserr(_g("cannot close %s"), "$cf.new");
     rename("$cf.new", "$cf") ||
     rename("$cf.new", "$cf") ||
         syserr(_g("cannot install output control file \`%s'"), $cf);
         syserr(_g("cannot install output control file \`%s'"), $cf);
 }
 }

+ 1 - 1
scripts/dpkg-shlibdeps.pl

@@ -520,7 +520,7 @@ foreach my $field (reverse @depfields) {
 
 
 # Replace old file by new one
 # Replace old file by new one
 if (!$stdout) {
 if (!$stdout) {
-    close($fh);
+    close($fh) || syserr(_g("cannot close %s"), "$varlistfile.new");
     rename("$varlistfile.new",$varlistfile) ||
     rename("$varlistfile.new",$varlistfile) ||
 	syserr(_g("install new varlist file \`%s'"), $varlistfile);
 	syserr(_g("install new varlist file \`%s'"), $varlistfile);
 }
 }