summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2019-05-08 13:04:26 +0000
committerespie <espie@openbsd.org>2019-05-08 13:04:26 +0000
commit8b437e75d583ad547ed58b2cd7f2650581e20ea9 (patch)
tree62869a320222cc9fa5a4c2e5de8cdd041bc3ab08
parentRework the TCP md5sig and IKE handling. Move the pfkey socket to the parent (diff)
downloadwireguard-openbsd-8b437e75d583ad547ed58b2cd7f2650581e20ea9.tar.xz
wireguard-openbsd-8b437e75d583ad547ed58b2cd7f2650581e20ea9.zip
better signatures.
- pass state along to be able to do proper errsay instead of raw printing. - compare VERSION markers first, because they're supposed to trump everything else. (todo: evaluate -v diagnostics for version bumps) okay sthen@
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgAdd.pm4
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Signature.pm44
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm4
3 files changed, 33 insertions, 19 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm
index fb468e0b16e..3c009f727dc 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgAdd.pm
@@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgAdd.pm,v 1.110 2019/04/17 07:32:02 stsp Exp $
+# $OpenBSD: PkgAdd.pm,v 1.111 2019/05/08 13:04:26 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
@@ -39,7 +39,7 @@ sub has_different_sig
if (!defined $plist->{different_sig}) {
my $n = OpenBSD::PackingList->from_installation($plist->pkgname)->signature;
my $o = $plist->signature;
- my $r = $n->compare($o, $state->defines("SHORTENED"));
+ my $r = $n->compare($o, $state);
$state->print("Comparing full signature for #1 \"#2\" vs. \"#3\":",
$plist->pkgname, $o->string, $n->string)
if $state->verbose >= 3;
diff --git a/usr.sbin/pkg_add/OpenBSD/Signature.pm b/usr.sbin/pkg_add/OpenBSD/Signature.pm
index 49d4998f914..7cf05b0b0cd 100644
--- a/usr.sbin/pkg_add/OpenBSD/Signature.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Signature.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Signature.pm,v 1.23 2019/05/08 10:19:15 espie Exp $
+# $OpenBSD: Signature.pm,v 1.24 2019/05/08 13:04:27 espie Exp $
#
# Copyright (c) 2010 Marc Espie <espie@openbsd.org>
#
@@ -152,22 +152,34 @@ sub string
sub compare
{
- my ($a, $b, $shortened) = @_;
- return $b->revert_compare($a, $shortened);
+ my ($a, $b, $state) = @_;
+ return $b->revert_compare($a, $state);
}
sub revert_compare
{
- my ($b, $a, $shortened) = @_;
+ my ($b, $a, $state) = @_;
+
if ($a->{name} eq $b->{name}) {
+ # first check if system version changed
+ # then we don't have to go any further
+ my $d = $b->{extra}{VERSION}->name - $a->{extra}{VERSION}->name;
+ if ($d < 0) {
+ return 1;
+ } elsif ($d > 0) {
+ return -1;
+ }
+
+ my $shortened = $state->defines("SHORTENED");
my $awins = 0;
my $bwins = 0;
my $done = {};
my $errors = 0;
while (my ($k, $v) = each %{$a->{extra}}) {
if (!defined $b->{extra}{$k}) {
- print STDERR "Couldn't find $k in second signature\n";
+ $state->errsay(
+ "Couldn't find #1 in second signature", $k);
$errors++;
next;
}
@@ -182,12 +194,13 @@ sub revert_compare
}
for my $k (keys %{$b->{extra}}) {
if (!$done->{$k}) {
- print STDERR "Couldn't find $k in first signature\n";
+ $state->errsay(
+ "Couldn't find #1 in first signature", $k);
$errors++;
}
}
if ($errors) {
- $a->print_error($b);
+ $a->print_error($b, $state);
return undef;
}
if ($awins == 0) {
@@ -204,11 +217,12 @@ sub revert_compare
sub print_error
{
- my ($a, $b) = @_;
+ my ($a, $b, $state) = @_;
- print STDERR "Error: $a->{name} exists in two non-comparable versions\n";
- print STDERR "Someone forgot to bump a REVISION\n";
- print STDERR $a->string, " vs. ", $b->string, "\n";
+ $state->errsay("Error: #1 exists in two non-comparable versions",
+ $a->{name});
+ $state->errsay("Someone forgot to bump a REVISION");
+ $state->errsay("#1 vs. #2", $a->string, $b->string);
}
package OpenBSD::Signature::Full;
@@ -234,8 +248,8 @@ sub string
sub revert_compare
{
- my ($b, $a) = @_;
- my $r = $b->SUPER::revert_compare($a);
+ my ($b, $a, $state) = @_;
+ my $r = $b->SUPER::revert_compare($a, $state);
if (defined $r && $r == 0) {
if ($a->string ne $b->string) {
return undef;
@@ -246,8 +260,8 @@ sub revert_compare
sub compare
{
- my ($a, $b) = @_;
- my $r = $a->SUPER::compare($b);
+ my ($a, $b, $state) = @_;
+ my $r = $a->SUPER::compare($b, $state);
if (defined $r && $r == 0) {
if ($a->string ne $b->string) {
return undef;
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index af64b42e0ac..00ff61dd009 100644
--- a/usr.sbin/pkg_add/OpenBSD/Update.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Update.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Update.pm,v 1.163 2018/10/22 14:14:08 espie Exp $
+# $OpenBSD: Update.pm,v 1.164 2019/05/08 13:04:27 espie Exp $
#
# Copyright (c) 2004-2014 Marc Espie <espie@openbsd.org>
#
@@ -177,7 +177,7 @@ sub process_handle
push(@skipped_locs, $loc);
next
}
- my $r = $plist->signature->compare($p2->signature);
+ my $r = $plist->signature->compare($p2->signature, $state);
if (defined $r && $r > 0 && !$state->defines('downgrade')) {
$oldfound = 1;
$loc->forget;