aboutsummaryrefslogtreecommitdiffstats
path: root/URPM
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2003-08-20 15:10:25 +0000
committerFrancois Pons <fpons@mandriva.com>2003-08-20 15:10:25 +0000
commit94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd (patch)
tree08acc1938f395ea1333ab196fee3f4216fb285de /URPM
parentd64a23741780b7715e128b1efb5680dba55f5458 (diff)
downloadperl-URPM-94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd.tar
perl-URPM-94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd.tar.gz
perl-URPM-94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd.tar.bz2
perl-URPM-94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd.tar.xz
perl-URPM-94f54d725c6da7a6f91bf4701b4a5af28d0dd2fd.zip
0.93-7mdk (signature comparison workaround)
Diffstat (limited to 'URPM')
-rw-r--r--URPM/Signature.pm33
1 files changed, 26 insertions, 7 deletions
diff --git a/URPM/Signature.pm b/URPM/Signature.pm
index e2089e6..b3ca91b 100644
--- a/URPM/Signature.pm
+++ b/URPM/Signature.pm
@@ -2,6 +2,29 @@ package URPM;
use strict;
+#- compare keys to avoid glitches introduced during the importation where
+#- some characters may be modified on the fly by rpm --import...
+sub compare_pubkeys {
+ my ($a, $b, %options) = @_;
+ my $diff = 0;
+ my @a = unpack "C*", $a->{content};
+ my @b = unpack "C*", $b->{content};
+
+ #- default options to use.
+ $options{start} ||= 0;
+ $options{end} ||= @a < @b ? scalar(@b) : scalar(@a);
+ $options{diff} ||= 1;
+
+ #- check element one by one, count all difference (do not work well if elements
+ #- have been inserted/deleted).
+ foreach ($options{start} .. $options{end}) {
+ $a[$_] != $b[$_] and ++$diff;
+ }
+
+ #- diff options give level to consider the key equal (a character is not always the same).
+ $diff <= $options{diff} ? 0 : $diff;
+}
+
#- pare from rpmlib db.
sub parse_pubkeys {
my ($urpm, %options) = @_;
@@ -49,7 +72,7 @@ sub parse_armored_file {
my $inside_block = /^$/ ... /^-----END PGP PUBLIC KEY BLOCK-----$/;
if ($inside_block > 1) {
if ($inside_block =~ /E/) {
- push @l, $content;
+ push @l, +{ content => $content };
$block = undef;
$content = '';
} else {
@@ -60,22 +83,18 @@ sub parse_armored_file {
}
close F or die "unable to parse armored file $file";
- #- check at least one key has been found.
- @l < 1 and die "no key found while parsing armored file";
-
#- check if key has been found, remove from list.
if ($options{only_unknown_keys}) {
@l = grep {
my $found = 0;
foreach my $k (values %{$urpm->{keys} || {}}) {
- $k->{content} eq $_ and $found = 1, last;
+ compare_pubkeys($k, $_) == 0 and $found = 1, last;
}
!$found;
} @l;
}
- #- now return something (true) which reflect what should be found in keys.
- map { +{ content => $_ } } @l;
+ @l;
}
sub import_armored_file {