Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 83f318d68bbdab1ca898c94576a838cc97df4700 Mon Sep 17 00:00:00 2001 |
| 2 | From: Ludwig Nussel <ludwig.nussel@suse.de> |
| 3 | Date: Wed, 21 Apr 2010 15:52:10 +0200 |
| 4 | Subject: [PATCH] also create old hash for compatibility |
| 5 | |
| 6 | Upstream-Status: Backport [debian] |
| 7 | |
| 8 | diff --git a/tools/c_rehash.in b/tools/c_rehash.in |
| 9 | index b086ff9..b777d79 100644 |
| 10 | --- a/tools/c_rehash.in |
| 11 | +++ b/tools/c_rehash.in |
| 12 | @@ -8,8 +8,6 @@ my $prefix; |
| 13 | |
| 14 | my $openssl = $ENV{OPENSSL} || "openssl"; |
| 15 | my $pwd; |
| 16 | -my $x509hash = "-subject_hash"; |
| 17 | -my $crlhash = "-hash"; |
| 18 | my $verbose = 0; |
| 19 | my $symlink_exists=eval {symlink("",""); 1}; |
| 20 | my $removelinks = 1; |
| 21 | @@ -18,10 +16,7 @@ my $removelinks = 1; |
| 22 | while ( $ARGV[0] =~ /^-/ ) { |
| 23 | my $flag = shift @ARGV; |
| 24 | last if ( $flag eq '--'); |
| 25 | - if ( $flag eq '-old') { |
| 26 | - $x509hash = "-subject_hash_old"; |
| 27 | - $crlhash = "-hash_old"; |
| 28 | - } elsif ( $flag eq '-h') { |
| 29 | + if ( $flag eq '-h') { |
| 30 | help(); |
| 31 | } elsif ( $flag eq '-n' ) { |
| 32 | $removelinks = 0; |
| 33 | @@ -113,7 +108,9 @@ sub hash_dir { |
| 34 | next; |
| 35 | } |
| 36 | link_hash_cert($fname) if($cert); |
| 37 | + link_hash_cert_old($fname) if($cert); |
| 38 | link_hash_crl($fname) if($crl); |
| 39 | + link_hash_crl_old($fname) if($crl); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | @@ -146,6 +143,7 @@ sub check_file { |
| 44 | |
| 45 | sub link_hash_cert { |
| 46 | my $fname = $_[0]; |
| 47 | + my $x509hash = $_[1] || '-subject_hash'; |
| 48 | $fname =~ s/'/'\\''/g; |
| 49 | my ($hash, $fprint) = `"$openssl" x509 $x509hash -fingerprint -noout -in "$fname"`; |
| 50 | chomp $hash; |
| 51 | @@ -176,11 +174,21 @@ sub link_hash_cert { |
| 52 | $hashlist{$hash} = $fprint; |
| 53 | } |
| 54 | |
| 55 | +sub link_hash_cert_old { |
| 56 | + link_hash_cert($_[0], '-subject_hash_old'); |
| 57 | +} |
| 58 | + |
| 59 | +sub link_hash_crl_old { |
| 60 | + link_hash_crl($_[0], '-hash_old'); |
| 61 | +} |
| 62 | + |
| 63 | + |
| 64 | # Same as above except for a CRL. CRL links are of the form <hash>.r<n> |
| 65 | |
| 66 | sub link_hash_crl { |
| 67 | my $fname = $_[0]; |
| 68 | + my $crlhash = $_[1] || "-hash"; |
| 69 | $fname =~ s/'/'\\''/g; |
| 70 | my ($hash, $fprint) = `"$openssl" crl $crlhash -fingerprint -noout -in '$fname'`; |
| 71 | chomp $hash; |