Skip to content

Commit 34d0ed8

Browse files
Merge pull request #1659 from ardaguclu/ocpbugs-27489
OCPBUGS-27489: Use correct hash sum of extracted tarball after re-signing with codesign
2 parents 36702f9 + 93729f4 commit 34d0ed8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pkg/cli/admin/release/extract_tools.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,22 @@ func (o *ExtractOptions) extractCommand(command string) error {
814814
if (target.InjectReleaseVersion || target.InjectReleaseImage) && target.SignMachOBinary {
815815
if err = codesign.ResignMacho(layer.Mapping.To, target.AsArchive, target.Command, target.LinkTo); err != nil {
816816
klog.Infof("Unable to resign macho binaries: %v", err)
817+
} else {
818+
if target.AsArchive {
819+
// Since we rewrite tarball after signing mach-o files in darwin/arm64,
820+
// we should reflect the modified hash sum of this tarball to prevent mismatches.
821+
h := hashFn()
822+
archived, err := os.Open(layer.Mapping.To)
823+
if err != nil {
824+
return false, err
825+
}
826+
if _, err = io.Copy(h, archived); err != nil {
827+
archived.Close()
828+
return false, err
829+
}
830+
hash = h
831+
archived.Close()
832+
}
817833
}
818834
}
819835

@@ -1032,6 +1048,7 @@ func copyAndReplace(errorOutput io.Writer, w io.Writer, r io.Reader, bufferSize
10321048
copy(buf[:writeTo], buf[writeTo:end])
10331049
offset = end - writeTo
10341050
}
1051+
10351052
}
10361053

10371054
func findClusterIncludeConfigFromInstallConfig(ctx context.Context, installConfigPath string) (manifestInclusionConfiguration, error) {

0 commit comments

Comments
 (0)