Skip to content

Commit a620670

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 a620670

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lib/Module/Signature.pm

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,12 @@ 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+
if ($args{gpg1}) {
172+
_vercmp($1, "1.9.0") < 0 or return;
173+
}
170174
return $1;
171175
}
172176

@@ -245,8 +249,15 @@ my $which_gpg;
245249
sub _which_gpg {
246250
# Cache it so we don't need to keep checking.
247251
return $which_gpg if $which_gpg;
252+
my %args = (@_);
253+
my @cands;
254+
if ($args{gpg1}) {
255+
@cands = ('gpg1', 'gpg', 'gnupg1', 'gnupg');
256+
} else {
257+
@cands = ('gpg', 'gpg2', 'gnupg', 'gnupg2');
258+
}
248259

249-
for my $gpg_bin ('gpg', 'gpg2', 'gnupg', 'gnupg2') {
260+
foreach my $gpg_bin (@cands) {
250261
my $version = `$gpg_bin --version 2>&1`;
251262
if( $version && $version =~ /GnuPG/ ) {
252263
$which_gpg = $gpg_bin;
@@ -424,7 +435,7 @@ sub sign {
424435
return unless <STDIN> =~ /[Yy]/;
425436
}
426437

427-
if (my $version = _has_gpg()) {
438+
if (my $version = _has_gpg(gpg1 => 1)) {
428439
_sign_gpg($SIGNATURE, $plaintext, $version);
429440
}
430441
elsif (eval {require Crypt::OpenPGP; 1}) {
@@ -449,7 +460,7 @@ sub _sign_gpg {
449460
local *D;
450461
my $set_key = '';
451462
$set_key = qq{--default-key "$AUTHOR"} if($AUTHOR);
452-
open D, "| $gpg $set_key --clearsign --openpgp --personal-digest-preferences RIPEMD160 >> $sigfile.tmp"
463+
open D, "| $gpg $set_key --clearsign --openpgp --personal-digest-preferences SHA1 >> $sigfile.tmp"
453464
or die "Could not call $gpg: $!";
454465
print D $plaintext;
455466
close D;

0 commit comments

Comments
 (0)