Skip to content

Commit 0b25384

Browse files
authored
Merge pull request #353 from tannevaled/fix/codesign-virtualization-entitlement
fix(fix-machos): force adhoc signing for virtualization/hypervisor entitlements
2 parents e59cb36 + 1769b1f commit 0b25384

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

lib/bin/fix-machos.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@ def codesign!(filename)
7676
entitlements_xml, _, _ = Open3.capture3("codesign", "-d", "--entitlements", ":-", filename)
7777
has_entitlements = !entitlements_xml.strip.empty?
7878

79+
# Some entitlements (notably `com.apple.security.virtualization` and
80+
# `com.apple.security.hypervisor`) require either adhoc signing or a
81+
# Developer ID with a matching provisioning profile. When pantry CI
82+
# has imported a Developer ID via `apple-actions/import-codesign-certs`,
83+
# `signing_id` is that Developer ID — but it generally has no matching
84+
# provisioning, so macOS Virtualization.framework / hypervisor.framework
85+
# refuse the entitlement at runtime (the binary launches but vz / hv
86+
# calls fail). Homebrew sidesteps this by always adhoc-signing these
87+
# binaries. Mirror that: force adhoc when these entitlements are present.
88+
# See pkgxdev/pantry#7853.
89+
privileged_entitlements = %w[
90+
com.apple.security.virtualization
91+
com.apple.security.hypervisor
92+
]
93+
if has_entitlements and privileged_entitlements.any? { |k| entitlements_xml.include?(k) }
94+
resign_with_entitlements!(filename, "-", entitlements_xml)
95+
return
96+
end
97+
7998
# `--preserve-metadata=flags` does NOT preserve the adhoc flag (0x2)
8099
# when re-signing — codesign treats the adhoc bit as identity-derived
81100
# rather than a preservable flag. The result is a signed-but-not-adhoc

0 commit comments

Comments
 (0)