discuss -name and default_ca more correctly (I hope)
[oweals/openssl.git] / tools / c_rehash.in
index baec7c14ff4308a3062996597f0c27a1dbef54d0..69da98ff2cf2e71e58b5f2b26624696a084c8e43 100644 (file)
@@ -100,7 +100,7 @@ sub check_file {
 
 sub link_hash_cert {
                my $fname = $_[0];
-               my ($hash, $fprint) = `$openssl x509 -hash -fingerprint -noout -in $fname`;
+               my ($hash, $fprint) = `$openssl x509 -hash -fingerprint -noout -in "$fname"`;
                chomp $hash;
                chomp $fprint;
                $fprint =~ s/^.*=//;
@@ -117,7 +117,12 @@ sub link_hash_cert {
                }
                $hash .= ".$suffix";
                print "$fname => $hash\n";
-               symlink $fname, $hash;
+               $symlink_exists=eval {symlink("",""); 1};
+               if ($symlink_exists) {
+                       symlink $fname, $hash;
+               } else {
+                       system ("cp", $fname, $hash);
+               }
                $hashlist{$hash} = $fprint;
 }
 
@@ -125,7 +130,7 @@ sub link_hash_cert {
 
 sub link_hash_crl {
                my $fname = $_[0];
-               my ($hash, $fprint) = `$openssl crl -hash -fingerprint -noout -in $fname`;
+               my ($hash, $fprint) = `$openssl crl -hash -fingerprint -noout -in "$fname"`;
                chomp $hash;
                chomp $fprint;
                $fprint =~ s/^.*=//;
@@ -142,7 +147,12 @@ sub link_hash_crl {
                }
                $hash .= ".r$suffix";
                print "$fname => $hash\n";
-               symlink $fname, $hash;
+               $symlink_exists=eval {symlink("",""); 1};
+               if ($symlink_exists) {
+                       symlink $fname, $hash;
+               } else {
+                       system ("cp", $fname, $hash);
+               }
                $hashlist{$hash} = $fprint;
 }