For developers · Orchestrator
Keychains, signing and dialogs
On this page
A worker never opens a keychain, password or administrator dialog on the computer it runs on (#1607). Nobody at Gitoodo answers such a dialog, and the person at that computer cannot tell what it wants: a worker that searched for a signing certificate opened the password dialog of a separate signing keychain in the user's search list, and its owner did not know which password was meant.
Workers run in the signed-in user's desktop session on purpose (login keychain, desktop checks,
crates/core/src/gui_session.rs). In that session macOS answers a call that needs a locked
keychain with a password dialog instead of an error, so moving workers elsewhere is no option.
Gitoodo prevents the dialogs in three layers instead. Implemented in
crates/core/src/keychain_guard.rs (plan, environment) and keychain_guard/mac.rs (the guard's
run); the worker spawns add it in crates/cli/src/worker_broker.rs (guard, workers on this
computer) and crates/cli/src/satellite.rs (workers on worker machines). Nothing changes a
keychain, its settings or the search list.
1. Builds sign ad-hoc#
Every worker gets:
| Variable | Value | Effect |
|---|---|---|
XCODE_XCCONFIG_FILE | <state>/worker-guard/worker.xcconfig (macOS) | Xcode builds (also through other build tools that call it) sign to run locally: CODE_SIGN_IDENTITY = -, CODE_SIGN_STYLE = Manual, no team or provisioning profile. Xcode applies the file above every target's settings, so no identity is searched and no keychain opened. |
APPLE_SIGNING_IDENTITY | - | App bundlers that read it (Tauri among them) sign ad-hoc. |
GCM_INTERACTIVE | never | A git credential helper never opens a sign-in window. |
GIT_TERMINAL_PROMPT | 0 | git never waits for a user name or password in the terminal. |
Signing and notarising with a real identity belong to the release process, not to a worker. The
worker brief says so (SIGNING_RULE in crates/core/src/orchestration/brief.rs): build unsigned
or ad-hoc, never touch keychains, certificates or trust settings, and when signing is left out,
say so in the result.
2. security and codesign go through a guard (macOS)#
The folder <state>/worker-guard comes first on the worker's PATH and holds two small scripts,
security and codesign, that run gitoodo keychain-guard <tool> …. The guard reads the search
list and the default keychain (security list-keychains, default-keychain), asks each keychain
the call can reach whether it is locked (with user interaction switched off for its own process,
so the question itself never opens a dialog), and then:
- Refuses with a reason for the worker what would need a locked keychain: settings or contents of a named locked keychain, writing into a locked default keychain, and any other call that names no keychain while one in the search list is locked.
- Refuses always what asks a person:
unlock-keychainandcreate-keychainwithout-p, any-P(password through a dialog),set-keychain-password, trust settings changes (add-trusted-cert,remove-trusted-cert, …),authorizationdbchanges,authorize, interactive mode-i. - Skips locked keychains in searches that take keychains as arguments
(
find-generic-password,find-internet-password, theirdelete-forms,dump-keychain): the unlocked keychains of the search list are passed explicitly. An agent reading its own login from the login keychain keeps working while another keychain is locked. - Signs only from unlocked keychains:
codesign -s <identity>(not-) with a locked keychain in the search list looks the identity up in the unlocked ones (security find-identity, which never opens a keychain) and signs with--keychain <that one>; if only a locked keychain has it, the call is refused.codesign --keychain <locked>is refused. - Runs unchanged what cannot open a keychain: listing keychains, certificate and identity
searches, verifying and displaying signatures, ad-hoc signing,
lock-keychain.
Stopped when a dialog still appears#
Some dialogs cannot be foreseen: an unlocked keychain can still ask whether a program may use an
item. The guard runs the tool as its child; when a keychain dialog process (SecurityAgent)
appears that was not running when the call started and the call is still running after three
seconds, the guard ends the call, closes that dialog process (otherwise its dialog stays on the
screen after the caller is gone; macOS starts it again for the next request) and tells the worker:
signing needs a keychain, build unsigned or ad-hoc. A dialog process that was already running is
someone else's; then the guard does not interfere.
Limits#
- Tools that call
/usr/bin/securityor/usr/bin/codesignby their full path bypass the scripts. Xcode does, which is why its builds sign ad-hoc through the override file instead. - A worker's shell that rebuilds
PATHfrom scratch in its startup files loses the folder. Startup files that only put folders in front keep it working, since those folders hold neither tool. - Linux and Windows have no such keychain dialogs from these tools; workers there get only the environment variables.
Checked on a real Mac#
In the desktop session of a worker machine, with throwaway keychains (one locked with a
self-signed code signing identity, one unlocked with an item that trusts no application), through
the guard: security show-keychain-info <locked> and codesign --keychain <locked> -s … were
refused in under a second without a dialog; codesign -s <identity only in the locked keychain>
was refused; certificate searches in the locked keychain, the agent's login read, ad-hoc signing
and verifying ran as before; reading the item that trusts no application was stopped after three
seconds and its dialog closed. Without the guard the same show-keychain-info call opened a
password dialog and hung.