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

ruz at bestpractical.com ruz at bestpractical.com
Mon Oct 8 12:28:39 EDT 2007


Author: ruz
Date: Mon Oct  8 12:28:36 2007
New Revision: 9236

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

Log:
 r9173 at cubic-pc (orig r9172):  sartak | 2007-09-28 01:12:08 +0400
  r43192 at onn:  sartak | 2007-09-27 17:11:56 -0400
  Fix DrySign, add support for dry-signing update
 


Modified: rt/branches/3.7-EXPERIMENTAL/html/Ticket/Create.html
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Ticket/Create.html	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Ticket/Create.html	Mon Oct  8 12:28:36 2007
@@ -319,33 +319,34 @@
 }
 
 my $checks_failure = 0;
-
-# check to see if we have a good passphrase
 my $cannot_sign = 0;
-if ( $ARGS{'Sign'} ) {
-    if (!RT::Crypt::GnuPG::DrySign($QueueObj->CorrespondAddress, "x")) {
-        $cannot_sign = 1;
-        $checks_failure = 1;
-    }
-}
-
 my @gnupg_keys_issues;
-if ( !exists $ARGS{'AddMoreAttach'} && ($ARGS{'id'}||'') eq 'new' && $ARGS{'Encrypt'} ) {
+if ( !exists $ARGS{'AddMoreAttach'} && ($ARGS{'id'}||'') eq 'new' ) {
 
-    my @recipients = $m->comp(
-        '/Ticket/Elements/PreviewScrips:GetRecipientsOnCreate',
-        %ARGS
-    );
-
-    RT::Crypt::GnuPG::UseKeyForEncryption(
-        map { (/^UseKey-(.*)$/)[0] => $ARGS{ $_ } }
-        grep $ARGS{$_} && /^UseKey-/,
-        keys %ARGS
-    );
-
-    my $status;
-    ($status, @gnupg_keys_issues) = RT::Crypt::GnuPG::CheckRecipients( @recipients );
-    $checks_failure = 1 unless $status;
+    # check to see if we have a good passphrase
+    if ( $ARGS{'Sign'} ) {
+        if (!RT::Crypt::GnuPG::DrySign($QueueObj->CorrespondAddress, "x")) {
+            $cannot_sign = 1;
+            $checks_failure = 1;
+        }
+    }
+
+    if ( $ARGS{'Encrypt'} ) {
+        my @recipients = $m->comp(
+            '/Ticket/Elements/PreviewScrips:GetRecipientsOnCreate',
+            %ARGS
+        );
+
+        RT::Crypt::GnuPG::UseKeyForEncryption(
+            map { (/^UseKey-(.*)$/)[0] => $ARGS{ $_ } }
+            grep $ARGS{$_} && /^UseKey-/,
+            keys %ARGS
+        );
+
+        my $status;
+        ($status, @gnupg_keys_issues) = RT::Crypt::GnuPG::CheckRecipients( @recipients );
+        $checks_failure = 1 unless $status;
+    }
 }
 
 

Modified: rt/branches/3.7-EXPERIMENTAL/html/Ticket/Update.html
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Ticket/Update.html	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Ticket/Update.html	Mon Oct  8 12:28:36 2007
@@ -60,6 +60,10 @@
 <input type="hidden" class="hidden" name="DefaultStatus" value="<% $DefaultStatus ||''%>" />
 <input type="hidden" class="hidden" name="Action" value="<% $ARGS{Action}||'' %>" />
 
+% if ($cannot_sign) {
+<& /Elements/GnuPGSignIssues &>
+% }
+
 <& /Elements/GnuPGKeyIssues, Issues => \@gnupg_keys_issues &>
 
 <table border="0">
@@ -245,29 +249,44 @@
 # }}}
 
 my @results;
+my $cannot_sign = 0;
 my @gnupg_keys_issues;
-if ( $ARGS{'SubmitTicket'} && $ARGS{'Encrypt'} ) {
+if ( $ARGS{'SubmitTicket'} ) {
 
-    # skip any email addresses that we won't be sending mail to
-    my %squelch = $m->comp(
-                      '/Ticket/Elements/PreviewScrips:SquelchRecipients',
-                      %ARGS, TicketObj => $TicketObj
-                  );
-    my %seen = map { lc($_) => 1 } @{ $squelch{'EmailAddresses'} };
-
-    my @recipients = grep {!$seen{lc $_}} $m->comp(
-        '/Ticket/Elements/PreviewScrips:GetRecipients',
-        %ARGS, TicketObj => $TicketObj
-    );
+    # check to see if we have a good passphrase
+    if ( $ARGS{'Sign'} ) {
+        my $address = $ARGS{'UpdateType'} eq "private"
+                    ? $TicketObj->QueueObj->CommentAddress
+                    : $TicketObj->QueueObj->CorrespondAddress;
+        if (!RT::Crypt::GnuPG::DrySign($address, "x")) {
+            $cannot_sign = 1;
+            $checks_failure = 1;
+        }
+    }
 
-    RT::Crypt::GnuPG::UseKeyForEncryption(
-        map { (/^UseKey-(.*)$/)[0] => $ARGS{ $_ } }
-        grep $ARGS{$_} && /^UseKey-/,
-        keys %ARGS
-    );
-    my $status;
-    ($status, @gnupg_keys_issues) = RT::Crypt::GnuPG::CheckRecipients( @recipients );
-    $checks_failure = 1 unless $status;
+    if ( $ARGS{'Encrypt'} ) {
+
+        # skip any email addresses that we won't be sending mail to
+        my %squelch = $m->comp(
+                        '/Ticket/Elements/PreviewScrips:SquelchRecipients',
+                        %ARGS, TicketObj => $TicketObj
+                    );
+        my %seen = map { lc($_) => 1 } @{ $squelch{'EmailAddresses'} };
+
+        my @recipients = grep {!$seen{lc $_}} $m->comp(
+            '/Ticket/Elements/PreviewScrips:GetRecipients',
+            %ARGS, TicketObj => $TicketObj
+        );
+
+        RT::Crypt::GnuPG::UseKeyForEncryption(
+            map { (/^UseKey-(.*)$/)[0] => $ARGS{ $_ } }
+            grep $ARGS{$_} && /^UseKey-/,
+            keys %ARGS
+        );
+        my $status;
+        ($status, @gnupg_keys_issues) = RT::Crypt::GnuPG::CheckRecipients( @recipients );
+        $checks_failure = 1 unless $status;
+    }
 }
 
 if ( !$checks_failure && exists $ARGS{SubmitTicket} ) {

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	Mon Oct  8 12:28:36 2007
@@ -2018,16 +2018,18 @@
     my @message = @_;
 
     my $mime = MIME::Entity->build(
+        Type    => "multipart/mixed",
         From    => $from,
         To      => 'nobody at localhost',
         Subject => "dry run",
-        Message => \@message,
+        Data    => \@message,
     );
 
     my %res = SignEncrypt(
         Sign    => 1,
         Encrypt => 0,
         Entity  => $mime,
+        Signer  => $from,
     );
 
     return $res{exit_code} == 0;


More information about the Rt-commit mailing list