[Rt-commit] r8833 - in rt/branches/3.7-EXPERIMENTAL: . lib/RT/Crypt

sartak at bestpractical.com sartak at bestpractical.com
Thu Aug 30 11:32:25 EDT 2007


Author: sartak
Date: Thu Aug 30 11:32:24 2007
New Revision: 8833

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

Log:
 r37628 at onn:  sartak | 2007-08-30 11:32:11 -0400
 Now we store the decrypted version even if the signature fails


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	Thu Aug 30 11:32:24 2007
@@ -1074,9 +1074,14 @@
     $RT::Logger->debug( $res{'status'} ) if $res{'status'};
     $RT::Logger->warning( $res{'error'} ) if $res{'error'};
     $RT::Logger->error( $res{'logger'} ) if $res{'logger'} && $?;
-    if ( $@ || $? ) {
-        $res{'message'} = $@? $@: "gpg exitted with error code ". ($? >> 8);
-        return %res;
+
+    # if the encryption is fine but the signature is bad, then without this
+    # status check we lose the decrypted text
+    if ( $res{'status'} !~ /DECRYPTION_OKAY/ ) {
+        if ( $@ || $? ) {
+            $res{'message'} = $@? $@: "gpg exitted with error code ". ($? >> 8);
+            return %res;
+        }
     }
 
     seek $tmp_fh, 0, 0;

Modified: rt/branches/3.7-EXPERIMENTAL/t/mail/gnupg-bad.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/t/mail/gnupg-bad.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL/t/mail/gnupg-bad.t	Thu Aug 30 11:32:24 2007
@@ -1,13 +1,9 @@
 #!/usr/bin/perl
 use strict;
 use warnings;
-use Test::More tests => 10;
-use File::Temp;
+use Test::More tests => 14;
 use RT::Test;
 use Cwd 'getcwd';
-use String::ShellQuote 'shell_quote';
-use IPC::Run3 'run3';
-use Digest::MD5 qw(md5_hex);
 
 my $homedir = File::Spec->catdir( getcwd(), qw(lib t data crypt-gnupg) );
 
@@ -39,6 +35,9 @@
 
 diag "good encryption, unknown signer" if $ENV{TEST_VERBOSE};
 {
+    my $signer = RT::Test->load_or_create_user(EmailAddress => 'ruz at bestpractical.com');
+    $signer->PrincipalObj->GrantRight(Right => 'CreateTicket');
+
     email_ok(glob => "encrypted-badsig.txt",
              subject => "test",
              encrypted => 1,


More information about the Rt-commit mailing list