summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive/TLUtils.pm
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2016-04-12 06:09:25 +0000
committerNorbert Preining <preining@logic.at>2016-04-12 06:09:25 +0000
commitd6c6461376192bc9caa5c585ce97152058d1ac78 (patch)
tree5b28c806104ffff1afecf7c89abe60c21f489b9e /Master/tlpkg/TeXLive/TLUtils.pm
parent1dd8017f8a542a0bb6e8d0b02771ffeea32f4f91 (diff)
switch to home-made gpg calling, make tlmgr work
git-svn-id: svn://tug.org/texlive/trunk@40440 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive/TLUtils.pm')
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm56
1 files changed, 34 insertions, 22 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index 689662a93c1..4300bb486ea 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -212,7 +212,6 @@ use Getopt::Long;
use File::Temp;
use TeXLive::TLConfig;
-use TeXLive::GPG;
$::opt_verbosity = 0; # see process_logging_options
@@ -3596,6 +3595,9 @@ sub tlmd5 {
sub tldigest {
return (Digest::SHA::sha512_hex(shift));
}
+sub tl_short_digest {
+ return (Digest::MD5::md5_hex(shift));
+}
sub tlchecksum {
my ($file) = @_;
@@ -3673,7 +3675,7 @@ sub verify_checksum {
=item C<< setup_gpg() >>
-Tries to set up the global TeXLive::GPG instance C<$::gpg> used for
+Tries to set up gpg command line C<$::gpg> used for
verification of downloads.
Returns 1/0 on success/failure.
@@ -3685,16 +3687,20 @@ sub setup_gpg {
# first search for a gpg binary
return 0 if (!setup_unix_one( 'gpg' , '/no/such/path', '--version', 1));
# ok, we found one
- $::gpg = new TeXLive::GPG;
- $::gpg->gpgbin($::progs{'gpg'});
- # now we need to set up GNUPGHOME to make sure that gpg uses the
- # right codes
+ # Set up the gpg invocation:
+ $::gpg = "$::progs{'gpg'} ";
if ($ENV{'TL_GNUPGHOME'}) {
# the user wants us to use this directory, sure, do it
- $ENV{'GNUPGHOME'} = $ENV{'TL_GNUPGHOME'};
+ $::gpg .= "--homedir $ENV{'TL_GNUPGHOME'} ";
+ } else {
+ $::gpg .= "--homedir $master/tlpkg/gpg ";
+ }
+ if ($ENV{'TL_GNUPGARGS'}) {
+ $::gpg .= $ENV{'TL_GNUPGARGS'};
} else {
- $ENV{'GNUPGHOME'} = "$master/tlpkg/gpg";
+ $::gpg .= "--no-secmem-warning --no-permission-warning ";
}
+ debug("gpg command line: $::gpg\n");
return 1;
}
@@ -3730,25 +3736,22 @@ sub verify_download {
$ret = 1; # default for gpg download
if ($::gpg) {
my $urlgpg = "$url.asc";
- my ($gpg_fh, $gpg_file);
+ my ($signature_fh, $signature_file);
if ($urlgpg =~ m,^(http|ftp|file)://,) {
- ($gpg_fh, $gpg_file) = File::Temp::tempfile();
+ ($signature_fh, $signature_file) = File::Temp::tempfile(UNLINK => 1);
# now $gpg_fh filehandle is open, the file created
# TLUtils::download_file will just overwrite what is there
# on windows that doesn't work, so we close the fh immediately
# this creates a short loophole, but much better than before anyway
- close($gpg_fh);
- $ret = download_file($urlgpg, $gpg_file);
+ close($signature_fh);
+ $ret = download_file($urlgpg, $signature_file);
} else {
- $gpg_file = $urlgpg;
+ $signature_file = $urlgpg;
}
- if ($ret && (-r "$gpg_file")) {
- my $signdata = slurp_file($gpg_file);
- # WARNING
- # the documentation of Crypt::GPG is wrong!!! The first argument
- # needs to be the signature, the second the content!!!
- my ($plaintext, $signature) = $::gpg->verify($signdata, $file_data);
- if ($signature->validity ne "GOOD") {
+ if ($ret && (-r "$signature_file")) {
+ if (TeXLive::TLUtils::gpg_verify_signature($file, $signature_file)) {
+ info("cryptographic signature of $url verified\n");
+ } else {
tldie(<<GPGERROR);
Verification of downloaded file
$file
@@ -3756,8 +3759,6 @@ against
$urlgpg
did not succeed. Please report to texlive\@tug.org
GPGERROR
- } else {
- info("cryptographic signature of $file verified\n");
}
} else {
debug("no access to cryptographic signature $urlgpg\n");
@@ -3769,6 +3770,17 @@ GPGERROR
return(1);
}
+sub gpg_verify_signature {
+ my ($file, $sig) = @_;
+ my ($out, $ret) = run_cmd("$::gpg --verify $sig $file 2>&1");
+ if ($ret == 0) {
+ debug("verification succeeded, output:\n$out\n");
+ return 1;
+ } else {
+ tlwarn("verification failed, output:\n$out\n");
+ return 0;
+ }
+}
#
# compare_tlpobjs