On Sun, May 08, 2016 at 10:07:00AM -0700, Andrew Fresh wrote: > On Sun, May 08, 2016 at 09:46:47AM +0200, Francesco Toscan wrote: > > On Sat, May 07, 2016 at 08:08:25PM -0700, Andrew Fresh wrote: > > > This minor addition to the patch keeps the existing tests working and > > > adds tests that scalar context returns a filehandle. > > > > I'm unsure about /usr/src/usr.sbin/pkg_add/OpenBSD/PkgSign.pm. > > At line 100 it calls OpenBSD::Temp::permanent_file (which returns > > OpenBSD::MkTemp::mkstemp's value) in scalar context; at line 118 the > > code expects a string, not a filehandle. I have no idea about line 101. > > I've CC'd espie as I am not positive either. I *think* the patch below > works. Removing the scaler context call and seeking on the already > open filehandle seems like a reasonable approach. > > Unfortunately I'm too lazy to sign my own packages usually so not > entirely sure the patch below, or steps I used to sign it is right, but > it seems to work.
Wow, ignore all that, Apparently not enough coffee to properly test things. So, try that again, this time I actually made sure I hit this code path. $ signify -nG -p testkey.pub -s testkey.sec $ doas cp testkey.pub /etc/signify/ $ rm -f p5-Test-Most-0.34.tgz $ PERL5LIB=./ pkg_sign -i -v -s signify -s testkey.sec -D resign file:///usr/ports/packages/amd64/all/p5-Test-Most-0.34.tgz Resigning p5-Test-Most-0.34 Signed file:///usr/ports/packages/amd64/all/p5-Test-Most-0.34.tgz: ok $ doas pkg_add -D SIGNER=testkey,openbsd-59-pkg ./p5-Test-Most-0.34.tgz quirks-2.232 signed on 2016-05-08T10:34:16Z p5-Test-Most-0.34: ok $ doas rm testkey.* /etc/signify/testkey.pub p5-Test-Most-0.34.tgz $ doas pkg_delete p5-Test-Most 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 17:39:55 -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 + seek($fh2, 0, POSIX::SEEK_END) or $state->fatal("Can't append to #1", $tmp); require File::Copy; File::Copy::copy($fh, $fh2) or