Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codesign --xml requires macOS Monterey or later #1981

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions pkg/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import (
"text/template"
"time"

"github.com/coreos/go-semver/semver"
"github.com/lima-vm/lima/pkg/driver"
"github.com/lima-vm/lima/pkg/driverutil"
"github.com/lima-vm/lima/pkg/osutil"
"github.com/lima-vm/lima/pkg/qemu"
"github.com/lima-vm/lima/pkg/qemu/entitlementutil"

Expand Down Expand Up @@ -125,12 +127,19 @@ func Start(ctx context.Context, inst *store.Instance) error {
// Ask the user to sign the qemu binary with the "com.apple.security.hypervisor" if needed.
// Workaround for https://github.com/lima-vm/lima/issues/1742
if runtime.GOOS == "darwin" && inst.VMType == limayaml.QEMU {
qExe, _, err := qemu.Exe(inst.Arch)
macOSProductVersion, err := osutil.ProductVersion()
if err != nil {
return fmt.Errorf("failed to find the QEMU binary for the architecture %q: %w", inst.Arch, err)
return err
}
if accel := qemu.Accel(inst.Arch); accel == "hvf" {
entitlementutil.AskToSignIfNotSignedProperly(qExe)
// The codesign --xml option is only available on macOS Monterey and later
if !macOSProductVersion.LessThan(*semver.New("12.0.0")) {
qExe, _, err := qemu.Exe(inst.Arch)
if err != nil {
return fmt.Errorf("failed to find the QEMU binary for the architecture %q: %w", inst.Arch, err)
}
if accel := qemu.Accel(inst.Arch); accel == "hvf" {
entitlementutil.AskToSignIfNotSignedProperly(qExe)
}
}
}

Expand Down