The c_rehash script always return 0.
the attached patch is a fix to it: check the status and return error
vlaue,not all return 0,and then the caller can check it's return
value.
diff -Npur openssl-1.0.0a-orig/tools/c_rehash openssl-1.0.0a/tools/c_rehash
--- openssl-1.0.0a-orig/tools/c_rehash	2010-07-19 15:59:27.000000000 +0800
+++ openssl-1.0.0a/tools/c_rehash	2010-07-19 16:30:51.000000000 +0800
@@ -38,7 +38,8 @@ if(! -x $openssl) {
 	}
 	if($found == 0) {
 		print STDERR "c_rehash: rehashing skipped ('openssl' program not available)\n";
-		exit 0;
+		#return error,so the caller can check it's return value
+		exit 1;
 	}
 }
 
@@ -56,12 +57,28 @@ if (-d $dirlist[0]) {
 	chdir $pwd;
 }
 
+my $tmp_err = 0;
+my $tmp_i = 0;
 foreach (@dirlist) {
 	if(-d $_ and -w $_) {
 		hash_dir($_);
 	}
+	else {
+		$tmp_err=1;
+		$err_msg[$tmp_i]="$_";
+		$tmp_i++;
+	}
 }
 
+if ($tmp_err == 1) {
+	foreach (@err_msg) {
+		print STDERR "c_rehash: dir $_ doesn't exist or can't write to it\n";
+	}
+	#return error,so the caller can check it's return value
+	exit 1;
+}
+
+
 sub hash_dir {
 	my %hashlist;
 	print "Doing $_[0]\n";

Reply via email to