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

fix: properly raise error if macOS codesign - ing fails #1479

Merged
merged 2 commits into from
Mar 12, 2025

Conversation

wolfv
Copy link
Member

@wolfv wolfv commented Mar 11, 2025

@zbowling unfortunately, conda-forge ships and uses sigtool which advertises itself as codesign as well, but does not support these extra options.

My current idea is to:

  • use extra options if /usr/bin/codesign is the codesign
  • not use extra options if we find codesign somewhere else

Unfortunately neither sigtool "codesign" nor codesign have a --version that we could use easily.

Their --help outputs do look differnet though, so we could also use that as indicator.

Or we could first try with the extra args, and if it fails, fall back ...

Happy to hear other thoughts. Also pinging @minrk who uncovered all of this.

@wolfv wolfv changed the title properly raise error if codesigning fails fix: properly raise error if macOS codesign - ing fails Mar 11, 2025
@zbowling
Copy link
Contributor

zbowling commented Mar 11, 2025

Oh wowwa! Is this implementation? https://github.com/thefloweringash/sigtool ?

Another way to fix this, and it's where I started before I went down this path, was to rather pass entitlements from the yaml all the way down explicitly. I have a branch where I was working on that. It's unfortunate because it makes rattler-build more aware of details done by lower level build systems but it would work for sigtool and codesign since they both seem to take an explicit plist for entitlements.

@wolfv
Copy link
Member Author

wolfv commented Mar 11, 2025

@zbowling do you happen to know if Apple's codesign has supported these extra arguments for a long time?

@zbowling
Copy link
Contributor

@wolfv --preserve-metadata= has been supported since 10.9 at least so 12+ years at least.

@minrk
Copy link
Contributor

minrk commented Mar 12, 2025

confirming this works for me, and if I force it to use sigtool with the unsupported arg, I get the expected signing failure:

Running codesign: "/Users/minrk/conda/conda-bld/bld/rattler-build_test-relink_1741771957/build_env/bin/codesign" "-f" "-s" "-" "--preserve-metadata=entitlements,requirements" "/var/folders/qr/3vxfnp1x2t1fw55dr288mphc0000gn/T/test-relinkN6U4iT/lib/librelative.dylib"
2025-03-12T09:32:49.556226Z ERROR Running build for{recipe="test-relink-0.0.0-h9dcc729_0"}:Packaging new files: rattler_build::macos::link: codesign failed with status exit status: 109.
  stdout:
  stderr: The following argument was not expected: --preserve-metadata=entitlements,requirements
Run with --help for more information.

Error:   × Codesign failed

@wolfv
Copy link
Member Author

wolfv commented Mar 12, 2025

@minrk - just to double check - you manually moved sigtool to /usr/bin/codesign? Because with these changes we should detect if codesign comes from /usr/bin -> use extended arguments - otherwise we should always use the simple args.

@minrk
Copy link
Contributor

minrk commented Mar 12, 2025

Almost. I didn't modify the system, but I disabled the if is_system_codesign check so the arg is always added to make it fail.

@wolfv wolfv merged commit 87dfaf9 into prefix-dev:main Mar 12, 2025
15 checks passed
@wolfv wolfv deleted the codesign-fail branch March 12, 2025 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants