From c36a274c633c08115b6006622112f5609031001e Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 19 Feb 2020 03:02:04 +0000 Subject: CTAN sync 202002190302 --- systems/texlive/tlnet/tlpkg/TeXLive/TLCrypto.pm | 65 +++++++++++++++++++++++-- systems/texlive/tlnet/tlpkg/TeXLive/TLPDB.pm | 59 ++++------------------ 2 files changed, 71 insertions(+), 53 deletions(-) (limited to 'systems/texlive/tlnet/tlpkg/TeXLive') diff --git a/systems/texlive/tlnet/tlpkg/TeXLive/TLCrypto.pm b/systems/texlive/tlnet/tlpkg/TeXLive/TLCrypto.pm index 3e4dfb1331..87cff357ed 100644 --- a/systems/texlive/tlnet/tlpkg/TeXLive/TLCrypto.pm +++ b/systems/texlive/tlnet/tlpkg/TeXLive/TLCrypto.pm @@ -1,6 +1,6 @@ -# $Id: TLCrypto.pm 52158 2019-09-23 18:04:33Z karl $ +# $Id: TLCrypto.pm 53820 2020-02-17 03:23:13Z preining $ # TeXLive::TLCrypto.pm - handle checksums and signatures. -# Copyright 2016-2019 Norbert Preining +# Copyright 2016-2020 Norbert Preining # This file is licensed under the GNU General Public License version 2 # or any later version. @@ -12,7 +12,7 @@ use TeXLive::TLConfig; use TeXLive::TLUtils qw(debug ddebug win32 which platform conv_to_w32_path tlwarn tldie); -my $svnrev = '$Revision: 52158 $'; +my $svnrev = '$Revision: 53820 $'; my $_modulerevision = ($svnrev =~ m/: ([0-9]+) /) ? $1 : "unknown"; sub module_revision { return $_modulerevision; } @@ -34,6 +34,7 @@ C -- checksums and cryptographic signatures TeXLive::TLCrypto::tlchecksum($path); TeXLive::TLCrypto::verify_checksum($file, $url); + TeXLive::TLCrypto::verify_checksum_and_check_return($file, $url); =head2 Signatures @@ -52,6 +53,7 @@ BEGIN { &tlchecksum &tl_short_digest &verify_checksum + &verify_checksum_and_check_return &setup_gpg &verify_signature %VerificationStatusDescription @@ -223,6 +225,63 @@ Return short digest (MD5) of C<$str>. sub tl_short_digest { return (Digest::MD5::md5_hex(shift)); } +# emacs-page +=pod + +=item C<< verify_checksum_and_check_return($file, $tlpdburl [, $is_main, $localcopymode ]) >> + +Calls C<> and checks the various return values +for critical errors, and dies if necessary. + +If C<$is_main> is given and true, an unsigned tlpdb is considered +fatal. If C<$localcopymode> is given and true, do not die for +checksum and connection errors, thus allowing for re-downloading +of a copy. + +=cut + +sub verify_checksum_and_check_return { + my ($file, $path, $is_main, $localcopymode) = @_; + my ($r, $m) = verify_checksum($file, "$path.$ChecksumExtension"); + if ($r == $VS_CHECKSUM_ERROR) { + if (!$localcopymode) { + tldie("$0: checksum error when downloading $file from $path: $m\n"); + } + } elsif ($r == $VS_SIGNATURE_ERROR) { + tldie("$0: signature verification error of $file from $path: $m\n"); + } elsif ($r == $VS_CONNECTION_ERROR) { + if ($localcopymode) { + return(0, $r); + } else { + tldie("$0: cannot download: $m\n"); + } + } elsif ($r == $VS_UNSIGNED) { + if ($is_main) { + tldie("$0: main database at $path is not signed: $m\n"); + } + debug("$0: remote database checksum is not signed, continuing anyway: $m\n"); + return(0, $r); + } elsif ($r == $VS_EXPKEYSIG) { + debug("$0: good signature bug gpg key expired, continuing anyway!\n"); + return(0, $r); + } elsif ($r == $VS_REVKEYSIG) { + debug("$0: good signature but from revoked gpg key, continuing anyway!\n"); + return(0, $r); + } elsif ($r == $VS_GPG_UNAVAILABLE) { + debug("$0: TLPDB: no gpg available, continuing anyway!\n"); + return(0, $r); + } elsif ($r == $VS_PUBKEY_MISSING) { + debug("$0: TLPDB: pubkey missing, continuing anyway!\n"); + return(0, $r); + } elsif ($r == $VS_VERIFIED) { + return(1, $r); + } else { + tldie("$0: unexpected return value from verify_checksum: $r\n"); + } +} + + + # emacs-page =pod diff --git a/systems/texlive/tlnet/tlpkg/TeXLive/TLPDB.pm b/systems/texlive/tlnet/tlpkg/TeXLive/TLPDB.pm index 4dd848a1d2..ce00df5bf7 100644 --- a/systems/texlive/tlnet/tlpkg/TeXLive/TLPDB.pm +++ b/systems/texlive/tlnet/tlpkg/TeXLive/TLPDB.pm @@ -1,12 +1,12 @@ -# $Id: TLPDB.pm 53706 2020-02-07 01:48:10Z preining $ +# $Id: TLPDB.pm 53820 2020-02-17 03:23:13Z preining $ # TeXLive::TLPDB.pm - tlpdb plain text database files. -# Copyright 2007-2019 Norbert Preining +# Copyright 2007-2020 Norbert Preining # This file is licensed under the GNU General Public License version 2 # or any later version. package TeXLive::TLPDB; -my $svnrev = '$Revision: 53706 $'; +my $svnrev = '$Revision: 53820 $'; my $_modulerevision = ($svnrev =~ m/: ([0-9]+) /) ? $1 : "unknown"; sub module_revision { return $_modulerevision; } @@ -370,57 +370,16 @@ sub from_file { # # before we open and proceed, verify the downloaded file if ($params{'verify'} && $media ne 'local_uncompressed') { - my ($r, $m) = TeXLive::TLCrypto::verify_checksum($tlpdbfile, "$path.$ChecksumExtension"); - if ($r == $VS_CHECKSUM_ERROR) { - tldie("$0: checksum error when downloading $tlpdbfile from $path: $m\n"); - } elsif ($r == $VS_SIGNATURE_ERROR) { - tldie("$0: signature verification error of $tlpdbfile from $path: $m\n"); - } elsif ($r == $VS_CONNECTION_ERROR) { - tldie("$0: cannot download: $m\n"); - } elsif ($r == $VS_UNSIGNED) { - debug("$0: remote database checksum is not signed, continuing anyway: $m\n"); - $self->verification_status($r); - } elsif ($r == $VS_GPG_UNAVAILABLE) { - debug("$0: TLPDB: no gpg available, continuing anyway!\n"); - $self->verification_status($r); - } elsif ($r == $VS_PUBKEY_MISSING) { - debug("$0: TLPDB: pubkey missing, continuing anyway!\n"); - $self->verification_status($r); - } elsif ($r == $VS_VERIFIED) { - $is_verified = 1; - $self->verification_status($r); - } else { - tldie("$0: unexpected return value from verify_checksum: $r\n"); - } + my ($verified, $status) = TeXLive::TLCrypto::verify_checksum_and_check_return($tlpdbfile, $path); + $is_verified = $verified; + $self->verification_status($status); } open($retfh, "<$tlpdbfile") || die "$0: open($tlpdbfile) failed: $!"; } else { if ($params{'verify'} && $media ne 'local_uncompressed') { - my ($r, $m) = TeXLive::TLCrypto::verify_checksum($path, "$path.$ChecksumExtension"); - if ($r == $VS_CHECKSUM_ERROR) { - tldie("$0: checksum error when downloading $path from $path: $m\n"); - } elsif ($r == $VS_SIGNATURE_ERROR) { - tldie("$0: signature verification error of $path from $path: $m\n"); - } elsif ($r == $VS_CONNECTION_ERROR) { - tldie("$0: cannot download: $m\n"); - } elsif ($r == $VS_UNSIGNED) { - debug("$0: remote database checksum is not signed, continuing anyway!\n"); - $self->verification_status($r); - } elsif ($r == $VS_GPG_UNAVAILABLE) { - debug("$0: TLPDB: no gpg available, continuing anyway!\n"); - $self->verification_status($r); - } elsif ($r == $VS_PUBKEY_MISSING) { - debug("$0: TLPDB: pubkey missing, continuing anyway!\n"); - $self->verification_status($r); - } elsif ($r == $VS_EXPKEYSIG) { - debug("$0: TLPDB: signature verified, but key expired, continuing anyway!\n"); - $self->verification_status($r); - } elsif ($r == $VS_VERIFIED) { - $is_verified = 1; - $self->verification_status($r); - } else { - tldie("$0: unexpected return value from verify_checksum: $r\n"); - } + my ($verified, $status) = TeXLive::TLCrypto::verify_checksum_and_check_return($path, $path); + $is_verified = $verified; + $self->verification_status($status); } open(TMP, "<$path") || die "$0: open($path) failed: $!"; $retfh = \*TMP; -- cgit v1.2.3