[Rt-commit] r10679 - in rt/branches/3.999-DANGEROUS: . html/Admin/Queues html/Ticket/Elements lib/RT/Interface/Email/Auth t/mail
jesse at bestpractical.com
jesse at bestpractical.com
Sat Feb 2 18:26:03 EST 2008
Author: jesse
Date: Sat Feb 2 18:25:57 2008
New Revision: 10679
Modified:
rt/branches/3.999-DANGEROUS/ (props changed)
rt/branches/3.999-DANGEROUS/html/Admin/Queues/index.html
rt/branches/3.999-DANGEROUS/html/Ticket/Elements/ShowGnuPGStatus
rt/branches/3.999-DANGEROUS/lib/RT/Crypt/GnuPG.pm
rt/branches/3.999-DANGEROUS/lib/RT/Interface/Email/Auth/GnuPG.pm
rt/branches/3.999-DANGEROUS/t/mail/crypt-gnupg.t
Log:
r76111 at pinglin: jesse | 2008-02-02 18:24:29 -0500
* More GnuPg fixes
Modified: rt/branches/3.999-DANGEROUS/html/Admin/Queues/index.html
==============================================================================
--- rt/branches/3.999-DANGEROUS/html/Admin/Queues/index.html (original)
+++ rt/branches/3.999-DANGEROUS/html/Admin/Queues/index.html Sat Feb 2 18:25:57 2008
@@ -87,7 +87,7 @@
$format ||= q{'<a href="__WebPath__/Admin/Queues/Modify.html?id=__id__">__id__</a>/TITLE:#'}
.q{,'<a href="__WebPath__/Admin/Queues/Modify.html?id=__id__">__name__</a>/TITLE:name'}
- .q{,__description__,__Address__,__Priority__,__default_due_in__,__disabled__};
+ .q{,__description__,__address__,__priority__,__default_due_in__,__disabled__};
</%INIT>
<%ARGS>
Modified: rt/branches/3.999-DANGEROUS/html/Ticket/Elements/ShowGnuPGStatus
==============================================================================
--- rt/branches/3.999-DANGEROUS/html/Ticket/Elements/ShowGnuPGStatus (original)
+++ rt/branches/3.999-DANGEROUS/html/Ticket/Elements/ShowGnuPGStatus Sat Feb 2 18:25:57 2008
@@ -94,9 +94,9 @@
my $parser = RT::EmailParser->new();
$parser->smart_parse_mime_entity_from_scalar(
- Message => $original->content,
- Decode => 0,
- Exact => 1,
+ message => $original->content,
+ decode => 0,
+ exact => 1,
);
my $entity = $parser->entity;
unless ( $entity ) {
@@ -119,8 +119,8 @@
my @status = RT::Crypt::GnuPG::parse_status( $res[0]->{'status'} );
for ( @status ) {
- if ( $_->{'Operation'} eq 'Verify' && $_->{'Status'} eq 'DONE' ) {
- $top->add_header( 'X-RT-Incoming-Signature' => $_->{'UserString'} );
+ if ( $_->{'operation'} eq 'verify' && $_->{'status'} eq 'DONE' ) {
+ $top->add_header( 'X-RT-Incoming-Signature' => $_->{'user_string'} );
$needs_unsigned_warning = 0;
}
}
@@ -131,10 +131,10 @@
my @messages;
foreach my $run ( @runs ) {
foreach my $line ( @$run ) {
- if ( $line->{'Operation'} eq 'KeyCheck' ) {
+ if ( $line->{'operation'} eq 'key_check' ) {
next unless $Reverify;
# if a public key was missing during verification then we want try again
- next unless $line->{'KeyType'} eq 'public' && $line->{'Status'} eq 'MISSING';
+ next unless $line->{'key_type'} eq 'public' && $line->{'status'} eq 'MISSING';
# but only if we have key
my %key = RT::Crypt::GnuPG::get_public_key_info( $line->{'Key'} );
@@ -150,19 +150,19 @@
push @messages, _( "Public key '0x%1' is required to verify signature", $line->{'Key'} );
}
}
- elsif ( $line->{'Operation'} eq 'PassphraseCheck' ) {
- next if $line->{'Status'} eq 'DONE';
- push @messages, _( $line->{'Message'} );
+ elsif ( $line->{'operation'} eq 'passphrase_check' ) {
+ next if $line->{'status'} eq 'DONE';
+ push @messages, _( $line->{'message'} );
}
- elsif ( $line->{'Operation'} eq 'Decrypt' ) {
- push @messages, _( $line->{'Message'} );
+ elsif ( $line->{'operation'} eq 'decrypt' ) {
+ push @messages, _( $line->{'message'} );
}
- elsif ( $line->{'Operation'} eq 'Verify' ) {
- push @messages, _( $line->{'Message'} );
+ elsif ( $line->{'operation'} eq 'verify' ) {
+ push @messages, _( $line->{'message'} );
}
else {
- next if $line->{'Status'} eq 'DONE';
- push @messages, _( $line->{'Message'} );
+ next if $line->{'status'} eq 'DONE';
+ push @messages, _( $line->{'message'} );
}
}
}
Modified: rt/branches/3.999-DANGEROUS/lib/RT/Crypt/GnuPG.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/Crypt/GnuPG.pm (original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Crypt/GnuPG.pm Sat Feb 2 18:25:57 2008
@@ -1706,7 +1706,7 @@
algorithm => $alg,
);
- push @{ $res{'EncryptedTo'} ||= [] }, \%encrypted_to;
+ push @{ $res{'encrypted_to'} ||= [] }, \%encrypted_to;
}
push @res, \%res;
@@ -1714,14 +1714,14 @@
my ($key) = split /\s+/, $args;
my $type = $keyword eq 'NO_SECKEY' ? 'secret' : 'public';
my %res = (
- operation => 'KeyCheck',
+ operation => 'key_check',
status => 'MISSING',
message => ucfirst($type) . " key '0x$key' is not available",
key => $key,
key_type => $type,
);
$res{'user'} = ( $user_hint{$key} ||= {} );
- $res{'user'}{ ucfirst($type) . 'KeyMissing' } = 1;
+ $res{'user'}{ ucfirst($type) . 'key_missing' } = 1;
push @res, \%res;
}
Modified: rt/branches/3.999-DANGEROUS/lib/RT/Interface/Email/Auth/GnuPG.pm
==============================================================================
--- rt/branches/3.999-DANGEROUS/lib/RT/Interface/Email/Auth/GnuPG.pm (original)
+++ rt/branches/3.999-DANGEROUS/lib/RT/Interface/Email/Auth/GnuPG.pm Sat Feb 2 18:25:57 2008
@@ -69,20 +69,20 @@
sub get_current_user {
my %args = (
- Message => undef,
- RawMessageRef => undef,
+ message => undef,
+ raw_message_ref => undef,
@_
);
- $args{'Message'}->head->delete($_)
- for qw(X-RT-GnuPG-Status X-RT-Incoming-Encrypton
+ $args{'message'}->head->delete($_)
+ for qw(X-RT-GnuPG-status X-RT-Incoming-Encrypton
X-RT-Incoming-Signature X-RT-Privacy);
- my $msg = $args{'Message'}->dup;
+ my $msg = $args{'message'}->dup;
- my ( $status, @res ) = verify_decrypt( entity => $args{'Message'} );
+ my ( $status, @res ) = verify_decrypt( entity => $args{'message'} );
if ( $status && !@res ) {
- $args{'Message'}
+ $args{'message'}
->head->add( 'X-RT-Incoming-Encryption' => 'Not encrypted' );
return 1;
@@ -94,38 +94,38 @@
unless ($status) {
Jifty->log->error("Had a problem during decrypting and verifying");
my $reject
- = handle_errors( Message => $args{'Message'}, Result => \@res );
+ = handle_errors( message => $args{'message'}, result => \@res );
return ( 0,
'rejected because of problems during decrypting and verifying' )
if $reject;
}
# attach the original encrypted message
- $args{'Message'}->attach(
- type => 'application/x-rt-original-message',
+ $args{'message'}->attach(
+ Type => 'application/x-rt-original-message',
Disposition => 'inline',
- Data => ${ $args{'RawMessageRef'} },
+ Data => ${ $args{'raw_message_ref'} },
);
- $args{'Message'}->head->add( 'X-RT-GnuPG-Status' => $_->{'status'} )
+ $args{'message'}->head->add( 'X-RT-GnuPG-status' => $_->{'status'} )
foreach @res;
- $args{'Message'}->head->add( 'X-RT-Privacy' => 'PGP' );
+ $args{'message'}->head->add( 'X-RT-Privacy' => 'PGP' );
# XXX: first entity only for now
if (@res) {
my $decrypted;
my @status = RT::Crypt::GnuPG::parse_status( $res[0]->{'status'} );
for (@status) {
- if ( $_->{Operation} eq 'Decrypt' && $_->{Status} eq 'DONE' ) {
+ if ( $_->{operation} eq 'decrypt' && $_->{status} eq 'DONE' ) {
$decrypted = 1;
}
- if ( $_->{Operation} eq 'Verify' && $_->{Status} eq 'DONE' ) {
- $args{'Message'}->head->add(
- 'X-RT-Incoming-Signature' => $_->{UserString} );
+ if ( $_->{operation} eq 'verify' && $_->{status} eq 'DONE' ) {
+ $args{'message'}->head->add(
+ 'X-RT-Incoming-Signature' => $_->{user_string} );
}
}
- $args{'Message'}->head->add(
+ $args{'message'}->head->add(
'X-RT-Incoming-Encryption' => $decrypted
? 'Success'
: 'Not encrypted'
@@ -137,37 +137,37 @@
sub handle_errors {
my %args = (
- Message => undef,
- Result => [],
+ message => undef,
+ result => [],
@_
);
my $reject = 0;
my %sent_once = ();
- foreach my $run ( @{ $args{'Result'} } ) {
+ foreach my $run ( @{ $args{'result'} } ) {
my @status = RT::Crypt::GnuPG::parse_status( $run->{'status'} );
- unless ( $sent_once{'Noprivate_key'} ) {
+ unless ( $sent_once{'no_private_key'} ) {
unless (
check_no_private_key(
- Message => $args{'Message'},
- Status => \@status
+ message => $args{'message'},
+ status => \@status
)
)
{
- $sent_once{'Noprivate_key'}++;
+ $sent_once{'no_private_key'}++;
$reject = 1;
}
}
- unless ( $sent_once{'BadData'} ) {
+ unless ( $sent_once{'bad_data'} ) {
unless (
check_bad_data(
- Message => $args{'Message'},
- Status => \@status
+ message => $args{'message'},
+ status => \@status
)
)
{
- $sent_once{'BadData'}++;
+ $sent_once{'bad_data'}++;
$reject = 1;
}
}
@@ -176,34 +176,34 @@
}
sub check_no_private_key {
- my %args = ( Message => undef, Status => [], @_ );
- my @status = @{ $args{'Status'} };
+ my %args = ( message => undef, status => [], @_ );
+ my @status = @{ $args{'status'} };
- my @decrypts = grep $_->{'Operation'} eq 'Decrypt', @status;
+ my @decrypts = grep $_->{'operation'} eq 'decrypt', @status;
return 1 unless @decrypts;
foreach my $action (@decrypts) {
# if at least one secrete key exist then it's another error
return 1
- if grep !$_->{'User'}{'SecretKeyMissing'},
- @{ $action->{'EncryptedTo'} };
+ if grep !$_->{'user'}{'secret_key_missing'},
+ @{ $action->{'encrypted_to'} };
}
Jifty->log->error("Couldn't decrypt a message: have no private key");
my $address = (
RT::Interface::Email::parse_sender_address_from_head(
- $args{'Message'}->head
+ $args{'message'}->head
)
)[0];
my ($status) = RT::Interface::Email::send_email_using_template(
To => $address,
template => 'Error: no private key',
- Arguments => {
- Message => $args{'Message'},
- ticket_obj => $args{'Ticket'},
+ arguments => {
+ message => $args{'message'},
+ ticket_obj => $args{'ticket'},
},
- InReplyTo => $args{'Message'},
+ in_reply_to => $args{'message'},
);
unless ($status) {
Jifty->log->error("Couldn't send 'Error: no private key'");
@@ -212,11 +212,11 @@
}
sub check_bad_data {
- my %args = ( Message => undef, Status => [], @_ );
+ my %args = ( message => undef, status => [], @_ );
my @bad_data_messages
- = map $_->{'Message'},
- grep $_->{'Status'} ne 'DONE' && $_->{'Operation'} eq 'Data',
- @{ $args{'Status'} };
+ = map $_->{'message'},
+ grep $_->{'status'} ne 'DONE' && $_->{'operation'} eq 'data',
+ @{ $args{'status'} };
return 1 unless @bad_data_messages;
Jifty->log->error( "Couldn't process a message: " . join ', ',
@@ -224,17 +224,17 @@
my $address = (
RT::Interface::Email::parse_sender_address_from_head(
- $args{'Message'}->head
+ $args{'message'}->head
)
)[0];
my ($status) = RT::Interface::Email::send_email_using_template(
- To => $address,
+ to => $address,
template => 'Error: bad GnuPG data',
- Arguments => {
- Messages => [@bad_data_messages],
- ticket_obj => $args{'Ticket'},
+ arguments => {
+ messages => [@bad_data_messages],
+ ticket_obj => $args{'ticket'},
},
- InReplyTo => $args{'Message'},
+ in_reply_to => $args{'message'},
);
unless ($status) {
Jifty->log->error("Couldn't send 'Error: bad GnuPG data'");
@@ -267,14 +267,5 @@
return $status, @res, @nested;
}
-eval "require RT::Interface::Email::Auth::GnuPG_Vendor";
-die $@
- if ( $@
- && $@ !~ qr{^Can't locate RT/Interface/Email/Auth/GnuPG_Vendor.pm} );
-eval "require RT::Interface::Email::Auth::GnuPG_Local";
-die $@
- if ( $@
- && $@ !~ qr{^Can't locate RT/Interface/Email/Auth/GnuPG_Local.pm} );
-
1;
Modified: rt/branches/3.999-DANGEROUS/t/mail/crypt-gnupg.t
==============================================================================
--- rt/branches/3.999-DANGEROUS/t/mail/crypt-gnupg.t (original)
+++ rt/branches/3.999-DANGEROUS/t/mail/crypt-gnupg.t Sat Feb 2 18:25:57 2008
@@ -42,7 +42,7 @@
is( $status[0]->{'status'}, 'DONE', 'good passphrase');
is( $status[1]->{'operation'}, 'sign', 'operation is correct');
is( $status[1]->{'status'}, 'DONE', 'done');
- is( $status[1]->{'User'}->{'email'}, 'rt at example.com', 'correct email');
+ is( $status[1]->{'user'}->{'email'}, 'rt at example.com', 'correct email');
ok( $entity->is_multipart, 'signed message is multipart' );
is( $entity->parts, 2, 'two parts' );
@@ -57,7 +57,7 @@
is scalar @res, 1, 'one operation';
@status = RT::Crypt::GnuPG::parse_status( $res[0]{'status'} );
is( scalar @status, 1, 'one record');
- is( $status[0]->{'operation'}, 'Verify', 'operation is correct');
+ is( $status[0]->{'operation'}, 'verify', 'operation is correct');
is( $status[0]->{'status'}, 'DONE', 'good passphrase');
is( $status[0]->{'trust'}, 'ULTIMATE', 'have trust value');
}
More information about the Rt-commit
mailing list