Hi,

I attached a patch to show you what I mean.

-- 
tschau , Uwe Gansert
-------------------------------------------------------------------------------
echo '$e=5;$p=3;$q=13;$h=$p*$q;while(($e*++$d)%($h-$p-$q+1)-1){};while($t=subst
r("82758c1b8939c7ef5c5d0����������������������������������1eaa4aa38516aed5559fe
27fd0f5b0b464474b2316eac~~~~        [EMAIL PROTECTED]        ~~~~390a03",$i,3)){$_.=pa
ck"I",(hex($t)%$h)**$d%$����������������������������������h+95;s/_/ /g;$_=($i+=
3)%2?uc:lc;print"$_\n";}'|perl -ne"chomp;s/�|~|\s*ug@[^~]*//g;print"|perl
--- /tmp/OpenSSL.pm     Mon Aug 27 13:03:40 2001
+++ OpenSSL.pm  Mon Aug 27 12:45:43 2001
@@ -67,7 +67,9 @@
         verify => undef,
         sign => undef,
         errno => undef,
-        errval => undef
+        errval => undef,
+         debug_handle => undef,
+         debug => 0         # 0 => no debugging
 );
 
 ## Create an instance of the Class
@@ -105,7 +107,8 @@
                $self->{tmpDir} = '/tmp';
        };
 
-       if( not -e "$self->{shell}" ) {
+#      if( not -e "$self->{shell}" ) {
+       if( not -x "$self->{shell}" ) {   # exists and can be executed
                return;
        };
 
@@ -127,9 +130,11 @@
                $self->{cnf} = $params->{$key}     if ( $key =~ /CONFIG/ );
                $self->{shell} = $params->{$key}   if ( $key =~ /SHELL/  );
                $self->{tmpDir} = $params->{$key}  if ( $key =~ /TMPDIR/ );
-               $self->{binDir} = $params->{$key} if ( $key =~ /BINDIR/ );
+               $self->{binDir} = $params->{$key}  if ( $key =~ /BINDIR/ );
                $self->{verify} = $params->{$key}  if ( $key =~ /VERIFY/ );
-               $self->{sign} = $params->{$key}  if ( $key =~ /SIGN/ );
+               $self->{sign} = $params->{$key}    if ( $key =~ /SIGN/ );
+                $self->{'debug'} = $params->{$key} if ( $key =~ /^DEBUG$/ and 
+$params->{$key} =~ /\d+/ ); # debugging on ? Level == Digit ?
+                $self->{'debug_handle'} = $params->{$key} if( $key =~ 
+/^DEBUG_HANDLE$/ and ref($params->{$key}) eq 'FileHandle' );
                open STDERR, $params->{$key} if ( $key =~ /STDERR/ );
        }
 
@@ -193,6 +198,7 @@
        $command .= $bits if( defined($bits) );
 
        $ENV{'pwd'} = $passwd if( defined( $passwd));
+        $self->debug( $command ) if( $self->{'debug'} & 2 );
        open(FD, "$command|" ) or return;
                ## Send Password
                ## if( $passwd ) {
@@ -268,6 +274,7 @@
        $command .= "-key $keyfile ";
 
        $ENV{'pwd'} = "$passwd" if( defined($passwd));
+        $self->debug( $command ) if( $self->{'debug'} & 2 );
        open( FD, "|$command" ) or return ;
                ## if( $passwd ne "" ) {
                ##      print FD "$passwd\n";
@@ -347,6 +354,7 @@
        }
 
        $ENV{'pwd'} = $passwd if( defined($passwd) );
+        $self->debug( $command ) if( $self->{'debug'} & 2 );
        $ret = `$command`;
        delete( $ENV{'pwd'} ) if( defined($passwd) );
 
@@ -439,11 +447,13 @@
        }
 
        if( defined($infile) && $infile ne "" ) {
-               $ret=`$command`;
+            $self->debug( $command ) if( $self->{'debug'} & 2 );
+            $ret=`$command`;
        } else {
-               open( FD, "|$command" ) or return;
-                       print FD "$data";
-               close( FD );
+            $self->debug( $command ) if( $self->{'debug'} & 2 );
+            open( FD, "|$command" ) or return;
+            print FD "$data";
+            close( FD );
        }
        ## return if( $? != 0 );
 
@@ -591,13 +601,15 @@
 
        if( $reqfile ne "" ) {
                $ENV{'pwd'} = $passwd;
+                $self->debug( $command ) if( $self->{'debug'} & 2 );
                $ret = `$command`;
                $ENV{'pwd'} = "";
                return if( $? != 0);
        } else {
                $ENV{'pwd'} = $passwd;
+                $self->debug( $command ) if( $self->{'debug'} & 2 );
                open( FD, "|$command" ) or return;
-                       print "$reqdata";
+                print "$reqdata";
                close(FD);
                $ENV{'pwd'} = "";
 
@@ -640,6 +652,7 @@
        $command .= "-cert $cacert " if ( defined($cacert) && $cacert ne "" );
 
        $ENV{'pwd'} = $passwd;
+        $self->debug( $command ) if( $self->{'debug'} & 2 );
        open( FD, "$command|" ) or return;
                while( $tmp = <FD> ) {
                        $ret .= $tmp;
@@ -702,6 +715,7 @@
        $command .= "-extfile $extfile " if ( defined($extfile) && $extfile ne "" );
 
        $ENV{'pwd'} = $passwd;
+        $self->debug( $command ) if( $self->{'debug'} & 2 );
        $ret = `$command`;
        #$ENV{'pwd'} = "";
        delete( $ENV{'pwd'} );
@@ -762,6 +776,7 @@
                $command .= "-out $tmpfile ";
        }
 
+        $self->debug( $command ) if( $self->{'debug'} & 2 );
        open( FD, "|$command" ) or return;
        close( FD );
 
@@ -821,6 +836,7 @@
 
        $command .= "<\"$tmpfile\"";
 
+        $self->debug( $command ) if( $self->{'debug'} & 2 );
        $ret = `$command`;
        $ret =~ s/\n//g;
 
@@ -1009,6 +1025,7 @@
 
        $cmd .= "-$attribute " if (exists $keys->{ATTRIBUTE} );
 
+        $self->debug( $cmd ) if( $self->{'debug'} & 2 );
        $ret = `$cmd`;
 
        unlink( $tmpfile );
@@ -1062,6 +1079,7 @@
                $command .= "-out $tmpfile ";
        }
 
+        $self->debug( $command ) if( $self->{'debug'} & 2 );
        $ret = `$command 2>&1`;
        if( $? > 0 ) {
                $self->{errno} = "$?";
@@ -1086,6 +1104,21 @@
        }
 }
 
+sub debug {
+    my $this   = shift;
+    my $string = shift;
+
+    my ($package, $filename, $line) = caller;
+    $string = "Package : $package, Line : $line\n$string" if( $this->{debug} & 1 );
+    if( ref($this->{debug_handle}) eq 'FileHandle' ) {
+        my $fh = $this->{debug_handle};
+        print $fh "$string\n";
+    } else {
+        print STDERR "$string\n";
+    }
+    return;
+}
+
 # Autoload methods go after =cut, and are processed by the autosplit program.
 
 1;
@@ -1131,10 +1164,22 @@
        This function can handle the internal module data such as the
        backend path or the tmp dir. Accepted parameters are:
 
-               SHELL   - Path to the openssl command.
-               CONFIG  - Path to the openssl config file.
-               TMPDIR  - Temporary files directory.
-               STDERR  - Where to redirect the STDERR file.
+               SHELL        - Path to the openssl command.
+               CONFIG       - Path to the openssl config file.
+               TMPDIR       - Temporary files directory.
+               STDERR       - Where to redirect the STDERR file.
+                DEBUG        - Bitmask with currently 2 bits.
+                               BIT 0 - log caller information
+                               BIT 1 - log all openssl calls
+                               For example 'DEBUG=>2' means
+                               'log all openssl calls, no caller info'
+                               'DEBUG=>3' means
+                               'log all openssl calls, with caller info'
+                               Default is 0 (no debugging) (*)
+                DEBUG_HANDLE - a FileHandle object where the
+                               debugging information goes to.
+                               See also 'perldoc FileHandle'.
+                               Default is STDERR. (*)
 
        (*) - Optional parameters;
 
@@ -1143,6 +1188,8 @@
                $openssl->setParams( SHELL=>'/usr/local/ssl/bin/openssl',
                                     CONFIG=>$ca/stuff/openssl.cnf,
                                     TMPDIR=>'/tmp',
+                                     DEBUG=>2,
+                                     DEBUG_HANDLE=>$fh,
                                     STDERR=>'/dev/null' );
 
 =head2 sub errno () - Get last command errno value.
@@ -1383,7 +1430,7 @@
 =head1 SEE ALSO
 
 OpenCA::X509, OpenCA::CRL, OpenCA::REQ, OpenCA::TRIStateCGI,
-OpenCA::Configuration
+OpenCA::Configuration, FileHandle
 
 =cut
 

PGP signature

Reply via email to