/usr/sbin/globus-update-certificate-dir is in globus-gsi-cert-utils-progs 9.16-2build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | #! /usr/bin/perl
my $prefix;
my $datarootdir;
my $datadir;
my $openssl="/usr/bin/openssl";
BEGIN {
if (exists $ENV{GLOBUS_LOCATION}) {
$prefix = $ENV{GLOBUS_LOCATION};
} else {
$prefix = '/usr';
}
$datarootdir="${prefix}/share";
$datadir="${datarootdir}";
}
use strict;
use Getopt::Long;
my $ca_dir = undef;
my $help = 0;
my @ca_dir_options = (
"$ENV{HOME}/.globus/certificates",
"/etc/grid-security/certificates",
"$datadir/certificates");
if (exists($ENV{X509_CERT_DIR}))
{
$ca_dir = $ENV{X509_CERT_DIR};
}
my $result = GetOptions("d=s" => \$ca_dir, "help" => \$help);
if (!$result)
{
exit(1);
}
if ($help)
{
print "Usage: $0 [-d TRUSTED-CA-DIR] [-help]\n";
exit(0);
}
if (!defined($ca_dir))
{
foreach my $dir (@ca_dir_options)
{
if (!defined($dir))
{
next;
}
if (-d "$dir/.")
{
$ca_dir = $dir;
last;
}
}
}
if (!defined($ca_dir))
{
print STDERR "Error determining trusted CA directory\n";
exit(1);
}
print "Updating CA hashes in $ca_dir\n";
if (!-w $ca_dir)
{
print "Error writing to $ca_dir\n";
exit(1);
}
chdir $ca_dir;
my %hashmaps = ();
my @files = ();
my $file;
select STDOUT;
$|=1;
print "Checking files";
foreach $file (<*>)
{
push(@files, $file);
if ($file =~ m|^([a-f0-9]+).[0-9]+$| && ! -l $file)
{
my $oldhash = $1;
my $hash = `"$openssl" x509 -in $file -noout -hash`;
chomp($hash);
print ".";
if ($oldhash ne $hash && !exists($hashmaps{$oldhash}))
{
$hashmaps{$oldhash} = $hash;
}
}
}
print "\n";
if (scalar(keys %hashmaps) == 0)
{
print "Nothing to do\n";
exit(0);
}
print "Linking files";
my $errors = "";
foreach $file (@files)
{
my $new_file = $file;
for my $hash (keys %hashmaps)
{
if ($new_file =~ m/$hash/)
{
my $newhash = $hashmaps{$hash};
$new_file =~ s/$hash/$newhash/;
if (-l $new_file)
{
unlink($new_file);
}
if (!symlink($file, $new_file))
{
$errors .= "symlink($file, $new_file) failed: $!\n";
}
print ".";
}
}
}
print STDERR $errors if $errors ne "";
print "\nDone\n";
exit(1) if $errors ne "";
|