Control: tags -1 + pending

Hi,

Quoting Sebastian Ramacher (2015-09-13 18:20:29)
> I'm using the sbuild profile and my /etc/schroot/sbuild/fstab has the
> following diff compared to the one from schroot 1.6.10-1:
> 
> [...]

aha, okay I *finally* see the problem you are seeing, albeit I only get one
extra temporary file. The reason seems to be that the function your patch
touches has been rewritten since the last time and now only creates one
temporary file. This also doesn't make your patch apply anymore. So instead I
went through lib/Sbuild/ResolverBase.pm and tried to make sure that all
instances where File::Temp::tempfile() is being called are followed by
appropriate close() and unlink() calls. You can find the patch I just pushed to
sbuild master attached.

Thanks for finding this issue!

cheers, josch
From aba0ffb5e7da37070c4e0e626fe557b538fb0a97 Mon Sep 17 00:00:00 2001
From: Johannes 'josch' Schauer <[email protected]>
Date: Sun, 13 Sep 2015 18:53:18 +0200
Subject: [PATCH] lib/Sbuild/ResolverBase.pm: close and unlink temporary files
 created by File::Temp::tempfile() (Closes: #775091)

---
 lib/Sbuild/ResolverBase.pm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/Sbuild/ResolverBase.pm b/lib/Sbuild/ResolverBase.pm
index c5a4f79..5912a1c 100644
--- a/lib/Sbuild/ResolverBase.pm
+++ b/lib/Sbuild/ResolverBase.pm
@@ -162,6 +162,8 @@ sub get_foreign_architectures {
     {
         $self->set('Multiarch Support', 0);
         $self->log_error("Failed to get dpkg foreign-architecture config\n");
+        close $tmpfh;
+        unlink $tmpfilename;
         return {};
     } # else dpkg has multiarch support
     seek $tmpfh, 0, SEEK_SET;
@@ -173,6 +175,7 @@ sub get_foreign_architectures {
         push @existing_foreign_arches, $_;
     }
     close $tmpfh;
+    unlink $tmpfilename;
     my %set;
     foreach (@existing_foreign_arches) { $set{$_} = 1; }
     return \%set;
@@ -1037,12 +1040,15 @@ EOF
             if (!-f $repokey) {
                 $self->log("Failed to add archive key '${repokey}' - it doesn't exist!\n");
                 $self->cleanup_apt_archive();
+                close($tmpfh);
+                unlink $tmpfilename;
                 return 0;
             }
             copy($repokey, $tmpfh);
             print $tmpfh "\n";
         }
         close($tmpfh);
+        unlink $tmpfilename;
 
         # Now that we've concat'd all the keys into the chroot, we're going
         # to use GPG to import the keys into a single keyring. We've stubbed
@@ -1080,6 +1086,7 @@ EOF
         }
 
         close($tmpfh);
+        unlink $tmpfilename;
         # List file needs to be moved with root.
         $session->run_command(
             { COMMAND => ['chmod', '0644', $session->strip_chroot_path($tmpfilename)],
@@ -1205,6 +1212,7 @@ APT::FTPArchive::Release::Codename "invalid";
 APT::FTPArchive::Release::Description "Sbuild Build Dependency Temporary Archive";
 EOF
     close $tmpfh;
+    unlink $tmpfilename;
 
     # Remove APT_CONFIG environment variable here, restore it later.
     my $env = $self->get('Session')->get('Defaults')->{'ENV'};
-- 
2.1.4

Attachment: signature.asc
Description: signature

Reply via email to