summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2016-04-12 06:05:44 +0000
committerNorbert Preining <preining@logic.at>2016-04-12 06:05:44 +0000
commit4340d42cb5033cb3bd60ba643a3491f33f999319 (patch)
tree659e48f90e9236870d5210ed2a75003fc3f51c31
parentdbe3c5aacd7e82e3a0d4a7956c528040982307f8 (diff)
use sha256 for remote tlpdb and location checks
git-svn-id: svn://tug.org/texlive/trunk@40423 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/tlmgr.pl14
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm17
-rwxr-xr-xMaster/tlpkg/bin/tl-update-containers3
3 files changed, 26 insertions, 8 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl
index ef9e56370d8..a0e98f8d616 100755
--- a/Master/texmf-dist/scripts/texlive/tlmgr.pl
+++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl
@@ -2121,7 +2121,7 @@ sub write_w32_updater {
push (@rst_info, "$pkg ^($oldrev^)");
next if ($opts{"dry-run"});
# create backup; make_container expects file name in a format: some-name.r[0-9]+
- my ($size, $md5, $fullname) = $localtlp->make_container("tar", $root, $temp, "__BACKUP_$pkg.r$oldrev");
+ my ($size, $checksum, $fullname) = $localtlp->make_container("tar", $root, $temp, "__BACKUP_$pkg.r$oldrev");
if ($size <= 0) {
tlwarn("$prg: Creation of backup container of $pkg failed.\n");
return 1; # backup failed? abort
@@ -5836,7 +5836,7 @@ sub setup_one_remotetlpdb {
my $local_copy_tlpdb_used = 0;
if ($location =~ m;^(http|ftp)://;) {
# first check that the saved tlpdb is present at all
- my $loc_digest = Digest::MD5::md5_hex($location);
+ my $loc_digest = Digest::SHA::sha256_hex($location);
my $loc_copy_of_remote_tlpdb =
"$Master/$InfraLocation/texlive.tlpdb.$loc_digest";
ddebug("loc_digest = $loc_digest\n");
@@ -5845,11 +5845,11 @@ sub setup_one_remotetlpdb {
ddebug("loc copy found!\n");
# we found the tlpdb matching the current location
# check for the remote hash
- my $path = "$location/$InfraLocation/$DatabaseName.md5";
+ my $path = "$location/$InfraLocation/$DatabaseName.sha256";
ddebug("remote path of digest = $path\n");
my $fh = TeXLive::TLUtils::download_file($path, "|");
my $rem_digest;
- if (read ($fh, $rem_digest, 32) != 32) {
+ if (read ($fh, $rem_digest, 64) != 64) {
info(<<END_NO_INTERNET);
No connection to the internet.
Unable to download the checksum of the remote TeX Live database,
@@ -5868,10 +5868,10 @@ END_NO_INTERNET
$local_copy_tlpdb_used = 1;
} else {
ddebug("found remote digest: $rem_digest\n");
- my $rem_copy_digest = TeXLive::TLUtils::tlmd5($loc_copy_of_remote_tlpdb);
+ my $rem_copy_digest = TeXLive::TLUtils::tlsha256($loc_copy_of_remote_tlpdb);
ddebug("rem_copy_digest = $rem_copy_digest\n");
if ($rem_copy_digest eq $rem_digest) {
- debug("md5 of local copy identical with remote hash\n");
+ debug("sha256 of local copy identical with remote hash\n");
$remotetlpdb = TeXLive::TLPDB->new(root => $location,
tlpdbfile => $loc_copy_of_remote_tlpdb);
$local_copy_tlpdb_used = 1;
@@ -5958,7 +5958,7 @@ FROZEN
# make sure that the writeout of the tlpdb is done in UNIX mode
# since otherwise the sha256 will change.
if (!$local_copy_tlpdb_used && $location =~ m;^(http|ftp)://;) {
- my $loc_digest = Digest::MD5::md5_hex($location);
+ my $loc_digest = Digest::SHA::sha256_hex($location);
my $loc_copy_of_remote_tlpdb =
"$Master/$InfraLocation/texlive.tlpdb.$loc_digest";
my $tlfh;
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index 8df5c3c2cc5..0a9e527c516 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -99,6 +99,7 @@ C<TeXLive::TLUtils> -- utilities used in TeX Live infrastructure
TeXLive::TLUtils::give_ctan_mirror();
TeXLive::TLUtils::give_ctan_mirror_base();
TeXLive::TLUtils::tlmd5($path);
+ TeXLive::TLUtils::tlsha256($path);
TeXLive::TLUtils::compare_tlpobjs($tlpA, $tlpB);
TeXLive::TLUtils::compare_tlpdbs($tlpdbA, $tlpdbB);
TeXLive::TLUtils::report_tlpdb_differences(\%ret);
@@ -173,6 +174,7 @@ BEGIN {
&create_mirror_list
&extract_mirror_entry
&tlmd5
+ &tlsha256
&wsystem
&xsystem
&run_cmd
@@ -199,6 +201,7 @@ BEGIN {
use Cwd;
use Digest::MD5;
+use Digest::SHA;
use Getopt::Long;
use File::Temp;
@@ -3579,6 +3582,20 @@ sub tlmd5 {
}
}
+sub tlsha256 {
+ my ($file) = @_;
+ if (-r $file) {
+ open(FILE, $file) || die "open($file) failed: $!";
+ binmode(FILE);
+ my $sha256hash = Digest::SHA->new(256)->addfile(*FILE)->hexdigest;
+ close(FILE);
+ return $sha256hash;
+ } else {
+ tlwarn("tlsha256, given file not readable: $file\n");
+ return "";
+ }
+}
+
#
# compare_tlpobjs
# returns a hash
diff --git a/Master/tlpkg/bin/tl-update-containers b/Master/tlpkg/bin/tl-update-containers
index 65b73b38bb4..2ea4ecd2552 100755
--- a/Master/tlpkg/bin/tl-update-containers
+++ b/Master/tlpkg/bin/tl-update-containers
@@ -385,9 +385,10 @@ sub main
chomp (my $olddir = `pwd`);
if (chdir("$opt_location/tlpkg/")) {
xsystem("md5sum texlive.tlpdb > texlive.tlpdb.md5");
+ xsystem("sha256sum texlive.tlpdb > texlive.tlpdb.sha256");
xchdir($olddir);
} else {
- tlwarn("Cannot chdir to $opt_location/tlpkg/ for md5 hash creation\n");
+ tlwarn("Cannot chdir to $opt_location/tlpkg/ for md5/sha256 hash creation\n");
}
if (! @ARGV) {