On Sun, May 08, 2016 at 07:22:07PM +0200, Marc Espie wrote:
> > Index: OpenBSD/PkgSign.pm
> > ===================================================================
> > RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgSign.pm,v
> > retrieving revision 1.7
> > diff -u -p -r1.7 PkgSign.pm
> > --- OpenBSD/PkgSign.pm 11 Oct 2014 08:41:06 -0000 1.7
> > +++ OpenBSD/PkgSign.pm 8 May 2016 16:50:33 -0000
> > @@ -79,6 +79,7 @@ package OpenBSD::PkgSign;
> > use OpenBSD::Temp;
> > use OpenBSD::PackingList;
> > use OpenBSD::PackageInfo;
> > +use POSIX ();
> >
> > sub sign_existing_package
> > {
> > @@ -97,7 +98,7 @@ sub sign_existing_package
> > $plist->set_infodir($dir);
> > $state->add_signature($plist);
> > $plist->save;
> > - my $tmp = OpenBSD::Temp::permanent_file($output, "pkg");
> > + my ($fh2, $tmp) = OpenBSD::Temp::permanent_file($output, "pkg");
> > my $wrarc = $state->create_archive($tmp, ".");
> >
> > my $fh;
> > @@ -115,7 +116,7 @@ sub sign_existing_package
> > close($wrarc->{fh});
> > delete $wrarc->{fh};
> >
> > - open(my $fh2, ">>", $tmp) or
> > + $fh2->seek(POSIX::SEEK_END, 0) or
> > $state->fatal("Can't append to #1", $tmp);
> > require File::Copy;
> > File::Copy::copy($fh, $fh2) or
So with that code, you're going to have two handles writing into the same
file... bleah.
I'd prefer just
my (undef, $tmp) = OpenBSD::Temp::permanent_file($output, "pkg");
not quite sure I'm not using a similar idiom in other ports tools.
Even though I said "okay" to guenther a while back, it was *after* testing
the code... which did not conform to the published interface. Not surprisingly
it worked.