Skip to content

Commit d1caf41

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 < v1.9
1 parent 09ddd49 commit d1caf41

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

lib/Module/Signature.pm

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,14 @@ sub _vercmp {
165165
}
166166

167167
sub _has_gpg {
168-
my $gpg = _which_gpg() or return;
168+
my %args = (@_);
169+
my $gpg = _which_gpg(%args) or return;
169170
`$gpg --version` =~ /GnuPG.*?(\S+)\s*$/m or return;
171+
# This is a workaround for RT#126994 meant to be reverted when no longer
172+
# needed. Run git blame on this line to find out which commit that is.
173+
if ($args{gpg1}) {
174+
_vercmp($1, "1.9.0") < 0 or return;
175+
}
170176
return $1;
171177
}
172178

@@ -245,8 +251,15 @@ my $which_gpg;
245251
sub _which_gpg {
246252
# Cache it so we don't need to keep checking.
247253
return $which_gpg if $which_gpg;
254+
my %args = (@_);
255+
my @cands;
256+
if ($args{gpg1}) {
257+
@cands = ('gpg1', 'gpg', 'gnupg1', 'gnupg');
258+
} else {
259+
@cands = ('gpg', 'gpg2', 'gnupg', 'gnupg2');
260+
}
248261

249-
for my $gpg_bin ('gpg', 'gpg2', 'gnupg', 'gnupg2') {
262+
foreach my $gpg_bin (@cands) {
250263
my $version = `$gpg_bin --version 2>&1`;
251264
if( $version && $version =~ /GnuPG/ ) {
252265
$which_gpg = $gpg_bin;
@@ -424,7 +437,7 @@ sub sign {
424437
return unless <STDIN> =~ /[Yy]/;
425438
}
426439

427-
if (my $version = _has_gpg()) {
440+
if (my $version = _has_gpg(gpg1 => 1)) {
428441
_sign_gpg($SIGNATURE, $plaintext, $version);
429442
}
430443
elsif (eval {require Crypt::OpenPGP; 1}) {
@@ -449,7 +462,7 @@ sub _sign_gpg {
449462
local *D;
450463
my $set_key = '';
451464
$set_key = qq{--default-key "$AUTHOR"} if($AUTHOR);
452-
open D, "| $gpg $set_key --clearsign --openpgp --personal-digest-preferences RIPEMD160 >> $sigfile.tmp"
465+
open D, "| $gpg $set_key --clearsign --openpgp --personal-digest-preferences SHA1 >> $sigfile.tmp"
453466
or die "Could not call $gpg: $!";
454467
print D $plaintext;
455468
close D;

0 commit comments

Comments
 (0)