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 Swift SDK bundles not working due to quarantine #6426

Merged
merged 10 commits into from
May 11, 2023

Conversation

MaxDesiatov
Copy link
Contributor

@MaxDesiatov MaxDesiatov commented Apr 13, 2023

When using swift experimental-sdk install subcommand with bundle archives or bundles unpacked from archives downloaded manually in the browser, installed executables are quarantined and trigger an error message when used by swift build

Steps To Reproduce:

  1. Download a destination bundle archive
  2. Unpack and install the bundle with swift experimental-destination install
  3. Confirm that the destination is installed and note its ID with swift experimental-destination list
  4. Build using the newly installed destination with swift build --experimental-destination-selector <destination-id>

Actual result:
Building with this destination triggers an error: "swift-driver cannot be opened because the developer cannot be verified."

rdar://107392863

Modifications:

We now suggest that users run xattr -r -d -s com.apple.quarantine on the bundles they trust to remove the quarantine attribute.

Result

The error message is clear and actionable.

"Cross-compilation destination" is a very verbose name. "Swift SDK" (note that this is distinct from just plain "SDK" used in other contexts) is a nicer alternative. Not all of the types and functions were renamed yet, especially `Destination`, which has been present in the codebase for long time. Renaming that type will be potentially source-breaking for libSwiftPM clients. This change is focused and updating user-visible strings and renaming types and functions that were only recently added. CLI subcommands were renamed accordingly.
When using `swift experimental-sdk install` subcommand with bundle archives or bundles unpacked from archives downloaded manually in the browser, installed executables are quarantined and trigger an error message when used by `swift build`

Steps To Reproduce:
1. Download a destination bundle archive
2. Unpack and install the bundle with `swift experimental-destination install`
3. Confirm that the destination is installed and note its ID with `swift experimental-destination list`
4. Build using the newly installed destination with `swift build --experimental-destination-selector <destination-id>`

Actual result:
Building with this destination triggers an error: "`swift-driver` cannot be opened because the developer cannot be verified."

rdar://107392863
#if os(macOS)
// Remove the quarantine attribute from bundles downloaded manually in the browser.
let result = try Process.popen(
arguments: ["xattr", "-d", "-r", "-s", "com.apple.quarantine", installedBundlePath.pathString]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use removexattr (or similar) instead of shelling out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 if possible

@MaxDesiatov MaxDesiatov deleted the branch main April 15, 2023 07:32
@neonichu neonichu deleted the maxd/fix-quarantine-error branch April 17, 2023 00:04
@MaxDesiatov MaxDesiatov restored the maxd/fix-quarantine-error branch April 17, 2023 14:11
@MaxDesiatov MaxDesiatov reopened this Apr 17, 2023
@MaxDesiatov MaxDesiatov changed the base branch from maxd/swift-sdks-renaming to main April 17, 2023 14:12
@MaxDesiatov
Copy link
Contributor Author

@@ -12,6 +12,7 @@

import Basics

import protocol TSCBasic.FileSystem
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: sort imports

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test windows

1 similar comment
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test windows

@MaxDesiatov MaxDesiatov requested a review from neonichu May 10, 2023 18:02
@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test windows

1 similar comment
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test windows

@MaxDesiatov MaxDesiatov merged commit 738f5f3 into main May 11, 2023
@MaxDesiatov MaxDesiatov deleted the maxd/fix-quarantine-error branch May 11, 2023 13:20
@MaxDesiatov MaxDesiatov restored the maxd/fix-quarantine-error branch May 11, 2023 13:20
@MaxDesiatov MaxDesiatov deleted the maxd/fix-quarantine-error branch May 11, 2023 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants