From 3f5e57d45a831b2192df53df46e094526db6cdde Mon Sep 17 00:00:00 2001 From: espie Date: Tue, 7 Jan 2014 11:51:15 +0000 Subject: [PATCH] integrate signer logic and fix resign with -DSIGNER --- usr.sbin/pkg_add/OpenBSD/PkgCreate.pm | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm index 91b2198e39b..36dc23ac3d0 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgCreate.pm,v 1.85 2014/01/07 10:38:12 espie Exp $ +# $OpenBSD: PkgCreate.pm,v 1.86 2014/01/07 11:51:15 espie Exp $ # # Copyright (c) 2003-2010 Marc Espie # @@ -1150,13 +1150,19 @@ sub add_signature { my ($self, $plist, $state) = @_; - if ($plist->has('digital-signature')) { + if ($plist->has('digital-signature') || $plist->has('signer')) { if ($state->defines('resign')) { $state->errsay("Resigning #1", $plist->pkgname); delete $plist->{'digital-signature'}; + delete $plist->{signer}; } } + my $signer = $state->{subst}->value('SIGNER'); + if (defined $signer) { + OpenBSD::PackingElement::Signer->add($plist, $signer); + } + my $sig = $state->{signer}->new_sig; $sig->add_object($plist); $sig->{b64sig} = $state->{signer}->compute_signature($state, $plist); @@ -1169,15 +1175,6 @@ sub create_archive return OpenBSD::Ustar->new($fh, $state, $dir); } -sub setup_signer -{ - my ($self, $plist, $state) = @_; - my $signer = $state->{subst}->value('SIGNER'); - if (!defined $signer) { - return; - } - OpenBSD::PackingElement::Signer->add($plist, $signer); -} sub sign_existing_package { @@ -1187,7 +1184,6 @@ sub sign_existing_package my $plist = OpenBSD::PackingList->fromfile($dir.CONTENTS); $plist->set_infodir($dir); $self->add_signature($plist, $state); - $self->setup_signer($plist, $state); $plist->save; my $tmp = OpenBSD::Temp::permanent_file($output, "pkg"); my $wrarc = $self->create_archive($state, $tmp, "."); @@ -1273,7 +1269,6 @@ sub add_extra_info my ($self, $plist, $state) = @_; my $subst = $state->{subst}; - $self->setup_signer($plist, $state); my $fullpkgpath = $subst->value('FULLPKGPATH'); my $cdrom = $subst->value('PERMIT_PACKAGE_CDROM') || $subst->value('CDROM');; -- 2.20.1