[Rt-commit] r9916 - in rt/branches/3.7-RTIR-RELENG: lib/RT/Crypt

ruz at bestpractical.com ruz at bestpractical.com
Wed Dec 12 12:28:31 EST 2007


Author: ruz
Date: Wed Dec 12 12:28:30 2007
New Revision: 9916

Modified:
   rt/branches/3.7-RTIR-RELENG/html/Admin/Users/GnuPG.html
   rt/branches/3.7-RTIR-RELENG/lib/RT/Crypt/GnuPG.pm

Log:
* returning all keys if passed id is empty was bad idea as there are
  several places where it's unexpected

Modified: rt/branches/3.7-RTIR-RELENG/html/Admin/Users/GnuPG.html
==============================================================================
--- rt/branches/3.7-RTIR-RELENG/html/Admin/Users/GnuPG.html	(original)
+++ rt/branches/3.7-RTIR-RELENG/html/Admin/Users/GnuPG.html	Wed Dec 12 12:28:30 2007
@@ -21,7 +21,7 @@
     Name         => 'PrivateKey',
     Description  => loc('Private Key'),
     Values       => [ map $_->{'Key'}, @{ $keys_meta{'info'} } ],
-    CurrentValue => $private_key,
+    CurrentValue => $UserObj->PrivateKey,
     DefaultLabel => loc('No private key'),
 &>
 
@@ -47,7 +47,7 @@
 $id = $ARGS{'id'} = $UserObj->id;
 
 my $email = $UserObj->EmailAddress;
-my %keys_meta = RT::Crypt::GnuPG::GetKeysForSigning( $email );
+my %keys_meta = RT::Crypt::GnuPG::GetKeysForSigning( $email, 'force' );
 
 $ARGS{'PrivateKey'} = $m->comp('/Widgets/Form/Select:Process',
     Name      => 'PrivateKey',
@@ -60,8 +60,6 @@
     push @results, $msg;
 }
 
-my $private_key = $UserObj->PrivateKey;
-
 my $title = loc("User's GnuPG keys");
 
 </%INIT>

Modified: rt/branches/3.7-RTIR-RELENG/lib/RT/Crypt/GnuPG.pm
==============================================================================
--- rt/branches/3.7-RTIR-RELENG/lib/RT/Crypt/GnuPG.pm	(original)
+++ rt/branches/3.7-RTIR-RELENG/lib/RT/Crypt/GnuPG.pm	Wed Dec 12 12:28:30 2007
@@ -1623,7 +1623,7 @@
 
 sub GetKeysForEncryption {
     my $key_id = shift;
-    my %res = GetKeysInfo( $key_id, 'public' );
+    my %res = GetKeysInfo( $key_id, 'public', @_ );
     return %res if $res{'exit_code'};
     return %res unless $res{'info'};
 
@@ -1644,7 +1644,7 @@
 
 sub GetKeysForSigning {
     my $key_id = shift;
-    my %res = GetKeysInfo( $key_id, 'public' );
+    my %res = GetKeysInfo( $key_id, 'public', @_ );
     return %res if $res{'exit_code'};
     return %res unless $res{'info'};
 
@@ -1729,11 +1729,11 @@
 }
 
 sub GetPublicKeyInfo {
-    return GetKeyInfo(shift, 'public');
+    return GetKeyInfo( shift, 'public', @_ );
 }
 
 sub GetPrivateKeyInfo {
-    return GetKeyInfo(shift, 'private');
+    return GetKeyInfo( shift, 'private', @_ );
 }
 
 sub GetKeyInfo {
@@ -1745,6 +1745,11 @@
 sub GetKeysInfo {
     my $email = shift;
     my $type = shift || 'public';
+    my $force = shift;
+
+    unless ( $email ) {
+        return (exit_code => 0) unless $force;
+    }
 
     my $gnupg = new GnuPG::Interface;
     my %opt = RT->Config->Get('GnuPGOptions');


More information about the Rt-commit mailing list