[A couple of my patches are already included, so I'm crypto-enabled in US.]

This patch makes c_rehash portable:

 a) Use File::Copy instead of calling `cp';

 b) Allow arbitrary path separator (e.g., ; in addition to :)

 c) compartmentalize symlinking;

Enjoy,
Ilya

--- ./tools/c_rehash-pre        Tue Sep 30 04:38:14 2003
+++ ./tools/c_rehash    Sun Nov 23 17:44:54 2003
@@ -1,5 +1,18 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
 
+use Config;
+use File::Copy 'copy';
+
+my $can_link;
+
+sub sym_copy($$) {
+    $can_link = eval {symlink("",""); 1} || 0 unless defined $can_link;
+    if ($can_link) {
+       symlink shift, shift or warn "symlink: $!";
+    } else {
+       copy shift, shift or warn "copy: $!";
+    }
+}
 
 # Perl c_rehash script, scan all files in a directory
 # and add symbolic links to their hash values.
@@ -15,12 +28,12 @@ if(defined $ENV{OPENSSL}) {
        $ENV{OPENSSL} = $openssl;
 }
 
-$ENV{PATH} .= ":$dir/bin";
+$ENV{PATH} .= "$Config{path_sep}$dir/bin";
 
 if(! -x $openssl) {
        my $found = 0;
-       foreach (split /:/, $ENV{PATH}) {
-               if(-x "$_/$openssl") {
+       foreach (split /$Config{path_sep}/, $ENV{PATH}) {
+               if(-x "$_/$openssl" or -x "$_/$openssl.exe") {
                        $found = 1;
                        last;
                }       
@@ -34,7 +47,7 @@ if(! -x $openssl) {
 if(@ARGV) {
        @dirlist = @ARGV;
 } elsif($ENV{SSL_CERT_DIR}) {
-       @dirlist = split /:/, $ENV{SSL_CERT_DIR};
+       @dirlist = split /$Config{path_sep}/, $ENV{SSL_CERT_DIR};
 } else {
        $dirlist[0] = "$dir/certs";
 }
@@ -118,12 +131,7 @@ sub link_hash_cert {
                }
                $hash .= ".$suffix";
                print "$fname => $hash\n";
-               $symlink_exists=eval {symlink("",""); 1};
-               if ($symlink_exists) {
-                       symlink $fname, $hash;
-               } else {
-                       system ("cp", $fname, $hash);
-               }
+               sym_copy $fname, $hash;
                $hashlist{$hash} = $fprint;
 }
 
@@ -149,12 +157,7 @@ sub link_hash_crl {
                }
                $hash .= ".r$suffix";
                print "$fname => $hash\n";
-               $symlink_exists=eval {symlink("",""); 1};
-               if ($symlink_exists) {
-                       symlink $fname, $hash;
-               } else {
-                       system ("cp", $fname, $hash);
-               }
+               sym_copy $fname, $hash;
                $hashlist{$hash} = $fprint;
 }
 

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to