launchd: treat absent domain as harmless in bootoutAgent

When an agent's launchd.agents.<name>.domain is changed from gui to
user (or the agent is newly installed on a headless macOS system
where the gui/<UID> domain never existed), bootoutAgent attempts to
unload the agent from the old domain first. On such systems, this
fails with: Boot-out failed: 125: Domain does not support specified
action.

The bootoutAgent function only treated "No such process" as a
non-fatal condition (return 2). This change adds the domain-not-exist
error to the same handling path: the agent wasn't running in a domain
that doesn't exist, so we can safely skip the boot-out and proceed
with bootstrap into the new domain.
This commit is contained in:
Eason20000 2026-07-10 20:32:42 +08:00 committed by Austin Horstman
parent 144f4e36d0
commit 79e6082586
2 changed files with 3 additions and 2 deletions

View file

@ -250,8 +250,8 @@ in
# At this point we know exit code is not 0 because otherwise we
# would have returned by now
# Only show warning if it's not the common "No such process" error
if [[ "$bootout_output" != *"No such process"* ]]; then
# Only show warning if it's not a common harmless error
if [[ "$bootout_output" != *"No such process"* && "$bootout_output" != *"Domain does not support specified action"* ]]; then
warnEcho "Failed to stop agent '$domain/$agentName': $bootout_output"
return 1
else

View file

@ -37,6 +37,7 @@
assertFileContains activate "printf 'user/%s"
assertFileContains activate 'restoreAgent "$oldSrcPath" "$dstPath" "$oldDomain" "$agentName"'
assertFileContains activate 'bootoutAgent "$newDomain" "$agentName"'
assertFileContains activate 'Domain does not support specified action'
assertFileContains activate 'processAgent "$srcPath" "$dstDir" "$oldDir" "$oldDomainsDir" "$newDomainsDir" \'
assertFileContains activate '|| launchdStatus=1'
assertFileContains activate 'done < <(find -L "$newDir" -maxdepth 1 -name'