Skip to content

Commit a9ac99b

Browse files
committed
Workaround for RT#126994
This commit should be reverted when no longer needed. Also change RIPEMD-160 to (at least) SHA-256 when that happens. - Set gpg digest preference to SHA1 - Only sign with gpg <= v2.1.15
1 parent 49c529b commit a9ac99b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/Module/Signature.pm

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ use constant SIGNATURE_MISMATCH => -4;
1717
use constant MANIFEST_MISMATCH => -5;
1818
use constant CIPHER_UNKNOWN => -6;
1919

20+
# Enable workaround for RT#126994
21+
use constant RT126994 => 1;
22+
use vars qw($Signing);
23+
$Signing = 0;
24+
2025
use ExtUtils::Manifest ();
2126
use Exporter;
2227
use File::Spec;
@@ -248,7 +253,12 @@ sub _which_gpg {
248253

249254
for my $gpg_bin ('gpg', 'gnupg', 'gpg2', 'gnupg2', 'gpg1', 'gnupg1') {
250255
my $version = `$gpg_bin --version 2>&1`;
251-
if( $version && $version =~ /GnuPG/ ) {
256+
if( $version && $version =~ /GnuPG.*?(\S+)\s*$/m ) {
257+
# This is a workaround for RT#126994 meant to be reverted when no longer
258+
# needed. Run git blame on this line to find out which commit that is.
259+
if (RT126994 and $Signing) {
260+
_vercmp($1, "2.1.15") <= 0 or next;
261+
}
252262
$which_gpg = $gpg_bin;
253263
return $which_gpg;
254264
}
@@ -424,6 +434,8 @@ sub sign {
424434
return unless <STDIN> =~ /[Yy]/;
425435
}
426436

437+
$Signing = 1;
438+
427439
if (my $version = _has_gpg()) {
428440
_sign_gpg($SIGNATURE, $plaintext, $version);
429441
}
@@ -449,7 +461,7 @@ sub _sign_gpg {
449461
local *D;
450462
my $set_key = '';
451463
$set_key = qq{--default-key "$AUTHOR"} if($AUTHOR);
452-
open D, "| $gpg $set_key --clearsign --openpgp --personal-digest-preferences RIPEMD160 >> $sigfile.tmp"
464+
open D, "| $gpg $set_key --clearsign --openpgp --personal-digest-preferences SHA1 >> $sigfile.tmp"
453465
or die "Could not call $gpg: $!";
454466
print D $plaintext;
455467
close D;

0 commit comments

Comments
 (0)