Skip to content

Commit 7a2c4a8

Browse files
committed
Put CLI and container-core-images in a keychain access group.
- Closes #1253 (hopefully). - Requires apple/containerization#553. - We share a keychain between the CLI and the image helper, but the user needs to opt-in the image helper for access to entries created by the CLI. Since both apps are notarized with the same team ID, we should be able to use an access group to avoid this step for release builds.
1 parent 9f9a7c9 commit 7a2c4a8

9 files changed

Lines changed: 29 additions & 8 deletions

File tree

Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,11 @@ $(STAGING_DIR):
117117
.PHONY: installer-pkg
118118
installer-pkg: $(STAGING_DIR)
119119
@echo Signing container binaries...
120-
@codesign $(CODESIGN_OPTS) --identifier com.apple.container.cli "$(join $(STAGING_DIR), bin/container)"
120+
@codesign $(CODESIGN_OPTS) --identifier com.apple.container.cli --entitlements=signing/container.entitlements "$(join $(STAGING_DIR), bin/container)"
121121
@codesign $(CODESIGN_OPTS) --identifier com.apple.container.apiserver "$(join $(STAGING_DIR), bin/container-apiserver)"
122-
@codesign $(CODESIGN_OPTS) --prefix=com.apple.container. "$(join $(STAGING_DIR), libexec/container/plugins/container-core-images/bin/container-core-images)"
122+
@codesign $(CODESIGN_OPTS) --prefix=com.apple.container. --entitlements=signing/container-core-images.entitlements "$(join $(STAGING_DIR), libexec/container/plugins/container-core-images/bin/container-core-images)"
123123
@codesign $(CODESIGN_OPTS) --prefix=com.apple.container. --entitlements=signing/container-runtime-linux.entitlements "$(join $(STAGING_DIR), libexec/container/plugins/container-runtime-linux/bin/container-runtime-linux)"
124124
@codesign $(CODESIGN_OPTS) --prefix=com.apple.container. --entitlements=signing/container-network-vmnet.entitlements "$(join $(STAGING_DIR), libexec/container/plugins/container-network-vmnet/bin/container-network-vmnet)"
125-
126125
@echo Creating application installer
127126
@pkgbuild --root "$(STAGING_DIR)" --identifier com.apple.container-installer --install-location /usr/local --version ${RELEASE_VERSION} $(PKG_PATH)
128127
@rm -rf "$(STAGING_DIR)"

Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/ContainerCommands/Registry/RegistryList.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ extension Application {
3838
aliases: ["ls"])
3939

4040
public func run() async throws {
41-
let keychain = KeychainHelper(securityDomain: Constants.keychainID)
41+
let keychain = KeychainHelper(securityDomain: Constants.keychainID, accessGroup: Constants.keychainGroup)
4242
let registries = try keychain.list()
4343
try printRegistries(registries: registries, format: format)
4444
}

Sources/ContainerCommands/Registry/RegistryLogin.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ extension Application {
5757
}
5858
password = String(decoding: passwordData, as: UTF8.self).trimmingCharacters(in: .whitespacesAndNewlines)
5959
}
60-
let keychain = KeychainHelper(securityDomain: Constants.keychainID)
60+
let keychain = KeychainHelper(securityDomain: Constants.keychainID, accessGroup: Constants.keychainGroup)
6161
if username == "" {
6262
username = try keychain.userPrompt(hostname: server)
6363
}

Sources/ContainerCommands/Registry/RegistryLogout.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extension Application {
3434
var registry: String
3535

3636
public func run() async throws {
37-
let keychain = KeychainHelper(securityDomain: Constants.keychainID)
37+
let keychain = KeychainHelper(securityDomain: Constants.keychainID, accessGroup: Constants.keychainGroup)
3838
let r = Reference.resolveDomain(domain: registry)
3939
try keychain.delete(hostname: r)
4040
}

Sources/Services/ContainerAPIService/Client/Constants.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@
1818
public enum Constants {
1919
/// The keychain ID to use for registry credentials.
2020
public static let keychainID = "com.apple.container.registry"
21+
/// The application access group to use for registry credentials.
22+
public static let keychainGroup = "com.apple.container.keychain"
2123
}

Sources/Services/ContainerImagesService/Server/ImagesService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ extension ImagesService {
427427
if let authentication {
428428
return try await body(authentication)
429429
}
430-
let keychain = KeychainHelper(securityDomain: Constants.keychainID)
430+
let keychain = KeychainHelper(securityDomain: Constants.keychainID, accessGroup: Constants.keychainGroup)
431431
do {
432432
authentication = try keychain.lookup(hostname: host)
433433
} catch let err as KeychainHelper.Error {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>keychain-access-groups</key>
6+
<array>
7+
<string>$(AppIdentifierPrefix)com.apple.container.keychain</string>
8+
</array>
9+
</dict>
10+
</plist>

signing/container.entitlements

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>keychain-access-groups</key>
6+
<array>
7+
<string>$(AppIdentifierPrefix)com.apple.container.keychain</string>
8+
</array>
9+
</dict>
10+
</plist>

0 commit comments

Comments
 (0)