[Rt-commit] r7539 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Wed Apr 18 10:50:39 EDT 2007


Author: ruz
Date: Wed Apr 18 10:50:38 2007
New Revision: 7539

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Crypt/GnuPG.pm

Log:
 r4972 at cubic-pc:  cubic | 2007-04-18 05:01:46 +0400
 * parse decryption statuses


Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Crypt/GnuPG.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Crypt/GnuPG.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Crypt/GnuPG.pm	Wed Apr 18 10:50:38 2007
@@ -539,7 +539,7 @@
     $RT::Logger->error( $res{'logger'} ) if $res{'logger'} && $?;
     if ( $@ || $? ) {
         $res{'message'} = $@? $@: "gpg exitted with error code ". ($? >> 8);
-        return (undef, \%res);
+        return %res;
     }
 
     seek $tmp_fh, 0, 0;
@@ -632,8 +632,10 @@
     USERID_HINT
     SIG_CREATED GOODSIG
     END_ENCRYPTION
+    DECRYPTION_FAILED DECRYPTION_OKAY
     BAD_PASSPHRASE GOOD_PASSPHRASE
     ENC_TO
+    NO_SECKEY NO_PUBKEY
     NO_RECP INV_RECP NODATA UNEXPECTED
 );
 
@@ -642,6 +644,7 @@
 my %ignore_keyword = map { $_ => 1 } qw(
     NEED_PASSPHRASE MISSING_PASSPHRASE BEGIN_SIGNING PLAINTEXT PLAINTEXT_LENGTH
     BEGIN_ENCRYPTION SIG_ID VALIDSIG
+    BEGIN_DECRYPTION END_DECRYPTION
     TRUST_UNDEFINED TRUST_NEVER TRUST_MARGINAL TRUST_FULLY TRUST_ULTIMATE
 );
 
@@ -710,6 +713,7 @@
             my %res = (
                 Operation => 'Encrypt',
                 Status    => 'DONE',
+                Message   => 'Data has been encrypted',
             );
             foreach my $line ( reverse @status[ 0 .. $i-1 ] ) {
                 next unless $line =~ /^BEGIN_ENCRYPTION\s+(\S+)\s+(\S+)/;
@@ -718,6 +722,24 @@
             }
             push @res, \%res;
         }
+        elsif ( $keyword eq 'DECRYPTION_FAILED' ) {
+            my %res = (
+                Operation => 'Decrypt',
+                Status    => 'ERROR',
+                Message   => 'Decryption failed',
+                Keyword   => $keyword,
+            );
+            push @res, \%res;
+        }
+        elsif ( $keyword eq 'DECRYPTION_OKAY' ) {
+            my %res = (
+                Operation => 'Decrypt',
+                Status    => 'DONE',
+                Message   => 'Decryption process succeeded',
+                Keyword   => $keyword,
+            );
+            push @res, \%res;
+        }
         elsif ( $keyword eq 'ENC_TO' ) {
             my ($key, $alg, $key_length) = split /\s+/, $args;
             my %res = (
@@ -733,6 +755,20 @@
             $res{'User'} = $user_hint{ $key };
             push @res, \%res;
         }
+        elsif ( $keyword eq 'NO_SECKEY' || $keyword eq 'NO_PUBKEY' ) {
+            my ($key) = split /\s+/, $args;
+            my $type = $keyword eq 'NO_SECKEY'? 'secret': 'public';
+            my %res = (
+                Operation => 'KeyCheck',
+                Status    => 'MISSING',
+                Message   => ucfirst( $type ) ." key $key is not available",
+                Keyword   => $keyword,
+                Key       => $key,
+            );
+            $user_hint{ $key } ||= {};
+            $res{'User'} = $user_hint{ $key };
+            push @res, \%res;
+        }
         # GOODSIG, BADSIG, VALIDSIG, TRUST_*
         elsif ( $keyword eq 'GOODSIG' ) {
             my %res = (


More information about the Rt-commit mailing list