From 1c8a98b1b0b3a11b624acddba95117eec4b7d9f1 Mon Sep 17 00:00:00 2001 From: spz Date: Sun, 14 Mar 2010 13:12:04 +0000 Subject: improve gnupg handling --- devel/rt3/Makefile | 3 +- devel/rt3/distinfo | 3 +- devel/rt3/patches/patch-ab | 281 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 285 insertions(+), 2 deletions(-) create mode 100644 devel/rt3/patches/patch-ab (limited to 'devel/rt3') diff --git a/devel/rt3/Makefile b/devel/rt3/Makefile index 0681eca8ba4..02d44f6b61a 100644 --- a/devel/rt3/Makefile +++ b/devel/rt3/Makefile @@ -1,8 +1,9 @@ -# $NetBSD: Makefile,v 1.41 2010/01/17 15:45:54 spz Exp $ +# $NetBSD: Makefile,v 1.42 2010/03/14 13:12:04 spz Exp $ DISTNAME= rt-3.8.7 CATEGORIES= devel MASTER_SITES= http://download.bestpractical.com/pub/rt/release/ +PKGREVISION= 1 MAINTAINER= spz@NetBSD.org HOMEPAGE= http://bestpractical.com/rt/ diff --git a/devel/rt3/distinfo b/devel/rt3/distinfo index 98707a518c9..ceeb6eeab26 100644 --- a/devel/rt3/distinfo +++ b/devel/rt3/distinfo @@ -1,6 +1,7 @@ -$NetBSD: distinfo,v 1.15 2010/01/17 15:45:54 spz Exp $ +$NetBSD: distinfo,v 1.16 2010/03/14 13:12:04 spz Exp $ SHA1 (rt-3.8.7.tar.gz) = 9de5860c5c58d40c5f6914cdde807ecc66a68f20 RMD160 (rt-3.8.7.tar.gz) = 269b7a7ef18afa6f1191c77bf7cadbbb7ef698d1 Size (rt-3.8.7.tar.gz) = 3372703 bytes SHA1 (patch-aa) = 23964ba8d686931e1f92be88fa3a5d5e06070fce +SHA1 (patch-ab) = 0cbfa31fb20b2c53e7beeed5591437361bbcf173 diff --git a/devel/rt3/patches/patch-ab b/devel/rt3/patches/patch-ab new file mode 100644 index 00000000000..2851256aaf1 --- /dev/null +++ b/devel/rt3/patches/patch-ab @@ -0,0 +1,281 @@ +$NetBSD: patch-ab,v 1.3 2010/03/14 13:12:04 spz Exp $ + +--- lib/RT/Crypt/GnuPG.pm.orig 2009-12-11 17:27:20.000000000 +0000 ++++ lib/RT/Crypt/GnuPG.pm +@@ -434,6 +434,7 @@ sub SignEncryptRFC3156 { + ); + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + + # handling passphrase in GnuPGOptions +@@ -484,12 +485,12 @@ sub SignEncryptRFC3156 { + waitpid $pid, 0; + }; + my $err = $@; +- my @signature = readline $handle{'stdout'}; ++ my @signature = readline $handle{'stdout'} if $handle{'stdout'}->opened ; + close $handle{'stdout'}; + + $res{'exit_code'} = $?; + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -545,7 +546,7 @@ sub SignEncryptRFC3156 { + + $res{'exit_code'} = $?; + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -616,6 +617,7 @@ sub _SignEncryptTextInline { + return unless $args{'Sign'} || $args{'Encrypt'}; + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + + # handling passphrase in GnupGOptions +@@ -670,7 +672,7 @@ sub _SignEncryptTextInline { + my $err = $@; + + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -704,6 +706,7 @@ sub _SignEncryptAttachmentInline { + return unless $args{'Sign'} || $args{'Encrypt'}; + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + + # handling passphrase in GnupGOptions +@@ -757,7 +760,7 @@ sub _SignEncryptAttachmentInline { + my $err = $@; + + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -806,6 +809,7 @@ sub SignEncryptContent { + return unless $args{'Sign'} || $args{'Encrypt'}; + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + + # handling passphrase in GnupGOptions +@@ -858,7 +862,7 @@ sub SignEncryptContent { + my $err = $@; + + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -1077,6 +1081,7 @@ sub VerifyAttachment { + my %args = ( Data => undef, Signature => undef, Top => undef, @_ ); + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + $opt{'digest-algo'} ||= 'SHA1'; + $gnupg->options->hash_init( +@@ -1114,7 +1119,7 @@ sub VerifyAttachment { + }; + $res{'exit_code'} = $?; + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -1131,6 +1136,7 @@ sub VerifyRFC3156 { + my %args = ( Data => undef, Signature => undef, Top => undef, @_ ); + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + $opt{'digest-algo'} ||= 'SHA1'; + $gnupg->options->hash_init( +@@ -1161,7 +1167,7 @@ sub VerifyRFC3156 { + }; + $res{'exit_code'} = $?; + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -1184,6 +1190,7 @@ sub DecryptRFC3156 { + ); + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + + # handling passphrase in GnupGOptions +@@ -1226,7 +1233,7 @@ sub DecryptRFC3156 { + }; + $res{'exit_code'} = $?; + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -1237,6 +1244,11 @@ sub DecryptRFC3156 { + # if the decryption is fine but the signature is bad, then without this + # status check we lose the decrypted text + # XXX: add argument to the function to control this check ++ if ( !defined $res{'status'} ) { ++ $res{'message'} = $@? $@: "gpg failed ". ($? >> 8); ++ seek $tmp_fh, 0, 0; ++ return ($tmp_fh, $tmp_fn, %res); ++ } + if ( $res{'status'} !~ /DECRYPTION_OKAY/ ) { + if ( $@ || $? ) { + $res{'message'} = $@? $@: "gpg exitted with error code ". ($? >> 8); +@@ -1262,6 +1274,7 @@ sub DecryptInline { + ); + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + + # handling passphrase in GnuPGOptions +@@ -1369,7 +1382,7 @@ sub _DecryptInlineBlock { + }; + $res{'exit_code'} = $?; + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -1380,6 +1393,11 @@ sub _DecryptInlineBlock { + # if the decryption is fine but the signature is bad, then without this + # status check we lose the decrypted text + # XXX: add argument to the function to control this check ++ if ( !defined $res{'status'} ) { ++ $res{'message'} = $@? $@: "gpg failed ". ($? >> 8); ++ seek $tmp_fh, 0, 0; ++ return ($tmp_fh, $tmp_fn, %res); ++ } + if ( $res{'status'} !~ /DECRYPTION_OKAY/ ) { + if ( $@ || $? ) { + $res{'message'} = $@? $@: "gpg exitted with error code ". ($? >> 8); +@@ -1400,6 +1418,7 @@ sub DecryptAttachment { + ); + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + + # handling passphrase in GnuPGOptions +@@ -1451,6 +1470,7 @@ sub DecryptContent { + ); + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + + # handling passphrase in GnupGOptions +@@ -1489,7 +1509,7 @@ sub DecryptContent { + }; + $res{'exit_code'} = $?; + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -1500,6 +1520,11 @@ sub DecryptContent { + # if the decryption is fine but the signature is bad, then without this + # status check we lose the decrypted text + # XXX: add argument to the function to control this check ++ if ( !defined $res{'status'} ) { ++ $res{'message'} = $@? $@: "gpg failed ". ($? >> 8); ++ seek $tmp_fh, 0, 0; ++ return ($tmp_fh, $tmp_fn, %res); ++ } + if ( $res{'status'} !~ /DECRYPTION_OKAY/ ) { + if ( $@ || $? ) { + $res{'message'} = $@? $@: "gpg exitted with error code ". ($? >> 8); +@@ -2040,6 +2065,7 @@ sub GetKeysInfo { + } + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + $opt{'digest-algo'} ||= 'SHA1'; + $opt{'with-colons'} = undef; # parseable format +@@ -2064,12 +2090,12 @@ sub GetKeysInfo { + waitpid $pid, 0; + }; + +- my @info = readline $handle{'stdout'}; ++ my @info = readline $handle{'stdout'} if $handle{'stdout'}->opened ; + close $handle{'stdout'}; + + $res{'exit_code'} = $?; + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -2239,6 +2265,7 @@ sub DeleteKey { + my $key = shift; + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + $gnupg->options->hash_init( + _PrepareGnuPGOptions( %opt ), +@@ -2270,7 +2297,7 @@ sub DeleteKey { + my %res; + $res{'exit_code'} = $?; + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -2287,6 +2314,7 @@ sub ImportKey { + my $key = shift; + + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + $gnupg->options->hash_init( + _PrepareGnuPGOptions( %opt ), +@@ -2313,7 +2341,7 @@ sub ImportKey { + my %res; + $res{'exit_code'} = $?; + foreach ( qw(stderr logger status) ) { +- $res{$_} = do { local $/; readline $handle{$_} }; ++ $res{$_} = do { local $/; readline $handle{$_} if $handle{$_}->opened }; + delete $res{$_} unless $res{$_} && $res{$_} =~ /\S/s; + close $handle{$_}; + } +@@ -2370,6 +2398,7 @@ properly (and false otherwise). + + sub Probe { + my $gnupg = new GnuPG::Interface; ++ $gnupg->call(RT->Config->Get('GnuPG')->{'Call'}) if RT->Config->Get('GnuPG')->{'Call'}; + my %opt = RT->Config->Get('GnuPGOptions'); + $gnupg->options->hash_init( + _PrepareGnuPGOptions( %opt ), -- cgit v1.2.3