Skip to content

Commit

Permalink
[backend] implement pubkey replacement in kiwitree case
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Dec 5, 2012
1 parent 2d3f129 commit f58c4bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/backend/bs_repserver
Expand Up @@ -1556,7 +1556,7 @@ sub receivekiwitree {
$found = 1;
}
}
} elsif ($file =~ /\.asc$/s) {
} elsif ($file =~ /\.(?:asc|key)$/s) {
push @tosign, $file;
}
$todo{$file} = 1 unless $found;
Expand Down
18 changes: 17 additions & 1 deletion src/backend/bs_signer
Expand Up @@ -295,18 +295,25 @@ sub signjob {
my $projid = $info->{'project'};
my @files = sort(ls($jobdir));
my @signfiles = grep {/\.(?:d?rpm|sha256|iso|pkg\.tar\.gz|pkg\.tar\.xz)$/} @files;
my $needpubkey;
if (grep {$_ eq '.kiwitree_tosign'} @files) {
for my $f (split("\n", readstr("$jobdir/.kiwitree_tosign"))) {
next if $f eq '';
$f =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/ge;
die("bad file in kiwitree_tosign: $f\n") if "/$f/" =~ /\/\.{0,2}\//s;
if ($f =~ /.\.key$/) {
next unless ((-s "$jobdir/$f") || 0) == 8192;
$needpubkey = 1;
push @signfiles, $f;
next;
}
die("bad file in kiwitree_tosign: $f\n") unless $f =~ /^(.*)\.asc$/s;
push @signfiles, $f if -s "$jobdir/$f" && -e "$jobdir/$1";
}
}
if (@signfiles) {
my @signargs;
my $needpubkey = grep {/\.iso$/} @signfiles;
$needpubkey ||= grep {/\.iso$/} @signfiles;
push @signargs, '--project', $projid if $BSConfig::sign_project;
my $param = {
'uri' => "$BSConfig::srcserver/getsignkey",
Expand Down Expand Up @@ -346,6 +353,15 @@ sub signjob {
@signmode = ('-d');
$signfile =~ s/\.asc$//s;
}
if ($signfile =~ /\.key$/s) {
next unless (-s "$jobdir/$signfile") == 8192;
my $signfilec = readstr("$jobdir/$signfile");
next if substr($signfilec, 0, 8) ne "sIGnMeP\n";
$pubkey ||= signfilter(undef, @signargs, '-p');
die("pubkey is not available\n") unless $pubkey;
writestr("$jobdir/$signfile.tmp$$", "$jobdir/$signfile", $pubkey);
next;
}
if (system($BSConfig::sign, @signargs, @signmode, "$jobdir/$signfile")) {
unlink("$uploaddir/signer.$$") if $signkey;
close F;
Expand Down

0 comments on commit f58c4bd

Please sign in to comment.