[Rt-commit] r7663 - in rt/branches/3.7-EXPERIMENTAL-TUNIS:
lib/RT/Crypt
ruz at bestpractical.com
ruz at bestpractical.com
Tue Apr 24 02:45:08 EDT 2007
Author: ruz
Date: Tue Apr 24 02:45:08 2007
New Revision: 7663
Modified:
rt/branches/3.7-EXPERIMENTAL-TUNIS/ (props changed)
rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Crypt/GnuPG.pm
Log:
sync from head
Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Crypt/GnuPG.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Crypt/GnuPG.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Crypt/GnuPG.pm Tue Apr 24 02:45:08 2007
@@ -467,8 +467,10 @@
my $io = $entity->open('r');
while ( defined($_ = $io->getline) ) {
next unless /-----BEGIN PGP (SIGNED )?MESSAGE-----/;
+ my $type = $1? 'signed': 'encrypted';
+ $RT::Logger->debug("Found $type inline part");
return {
- Type => ( $1? 'signed': 'encrypted' ),
+ Type => $type,
Format => 'Inline',
Data => $entity,
};
@@ -495,6 +497,7 @@
$RT::Logger->info( "Skipping protocol '$protocol', only 'application/pgp-encrypted' is supported" );
return ();
}
+ $RT::Logger->debug("Found encrypted according to RFC3156 part");
return {
Type => 'encrypted',
Format => 'RFC3156',
@@ -507,6 +510,7 @@
$RT::Logger->info( "Skipping protocol '$protocol', only 'application/pgp-signature' is supported" );
return ();
}
+ $RT::Logger->debug("Found signed according to RFC3156 part");
return {
Type => 'signed',
Format => 'RFC3156',
@@ -538,6 +542,7 @@
}
$skip{"$data_part"}++;
+ $RT::Logger->debug("Found signature in attachment '$sig_name' of attachment '$file_name'");
push @res, {
Type => 'signed',
Format => 'Attachment',
@@ -555,6 +560,7 @@
foreach my $part ( @encrypted_files ) {
$skip{"$part"}++;
+ $RT::Logger->debug("Found encrypted attachment '". $part->head->recommended_filename ."'");
push @res, {
Type => 'encrypted',
Format => 'Attachment',
@@ -613,46 +619,7 @@
sub VerifyInline {
my %args = ( Data => undef, Top => undef, @_ );
-
- my $gnupg = new GnuPG::Interface;
- my %opt = RT->Config->Get('GnuPGOptions');
- $opt{'digest-algo'} ||= 'SHA1';
- $gnupg->options->hash_init(
- _PrepareGnuPGOptions( %opt ),
- meta_interactive => 0,
- );
-
- my %handle;
- my $handles = GnuPG::Handles->new(
- stdin => ($handle{'input'} = new IO::Handle),
- stdout => ($handle{'output'} = new IO::Handle),
- stderr => ($handle{'error'} = new IO::Handle),
- logger => ($handle{'logger'} = new IO::Handle),
- status => ($handle{'status'} = new IO::Handle),
- );
-
- my %res;
- eval {
- local $SIG{'CHLD'} = 'DEFAULT';
- my $pid = _safe_run_child { $gnupg->verify( handles => $handles ) };
- $args{'Data'}->bodyhandle->print( $handle{'input'} );
- close $handle{'input'};
-
- waitpid $pid, 0;
- };
- $res{'exit_code'} = $?;
- foreach ( qw(error logger status) ) {
- $res{$_} = do { local $/; readline $handle{$_} };
- delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s;
- close $handle{$_};
- }
- $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;
+ return DecryptInline( %args );
}
sub VerifyAttachment {
More information about the Rt-commit
mailing list