Skip to content

Fix settingsOverrideScriptPath crash when path contains a space - #389

Open
PeetMcK wants to merge 1 commit into
twocanoes:developfrom
peetinc:fix/clitask-space-in-path
Open

Fix settingsOverrideScriptPath crash when path contains a space#389
PeetMcK wants to merge 1 commit into
twocanoes:developfrom
peetinc:fix/clitask-space-in-path

Conversation

@PeetMcK

@PeetMcK PeetMcK commented May 20, 2026

Copy link
Copy Markdown

Summary

Found this bug when trying to locate my settingsOverrideScriptPath in /Library/Application Support.

DefaultsOverride.swift:69 calls cliTask(prefScriptPath). The single-string overload splits command on " " to derive launchPath (UNIXUtilities.swift:29), corrupting any settingsOverrideScriptPath that contains a space. NSConcreteTask then throws launch path not accessible, crashing the plugin during refreshCachedPrefs() and stalling the auth chain.

The backslash-rebuild branch in cliTask can't rescue this caller — refreshCachedPrefs pre-validates with FileManager.fileExists(atPath:) on the raw string, so an escaped path fails fileExists and an unescaped path crashes cliTask.

Fix

-            let scriptRes=cliTask(prefScriptPath)
+            let scriptRes=cliTask(prefScriptPath, arguments: [])

Takes the existing arguments != nil branch in cliTask, which uses command verbatim as launchPath.

cliTask's single-string overload splits the command by " " to derive
launchPath, so a settingsOverrideScriptPath like

    /Library/Application Support/vendor/xcreds-override-helper

becomes launchPath="/Library/Application", arguments=["Support/vendor/...
xcreds-override-helper"]. NSConcreteTask then throws

    *** NSInvalidArgumentException: launch path not accessible

from `DefaultsOverride.refreshCachedPrefs()` during plugin init, which
takes down the SecurityAgent auth chain — loginwindow hangs on a black
screen with no XCreds UI on every full logout cycle.

The cliTask backslash-escape branch can't rescue this caller because
the preceding `FileManager.fileExists(atPath:)` validation in
`refreshCachedPrefs()` runs on the raw string. A backslash-escaped
path satisfies cliTask but fails fileExists; an unescaped path
satisfies fileExists but crashes cliTask. There is no value of
settingsOverrideScriptPath that works when the helper lives under
a path with a space — including Apple's conventional
`/Library/Application Support/<vendor>/` install location.

Fix: call the existing `arguments: [String]?` overload with an empty
array so cliTask takes its no-split branch and uses the command
verbatim as launchPath. settingsOverrideScriptPath is documented as
the *path* to the helper (not a shell command line), so callers that
relied on undocumented space-splitting were always wrong.

Reproduced on macOS 26.4.1 (arm64). Verified the fix on the same
configuration with the helper at
`/Library/Application Support/lithiumbridge/xcreds-override-helper`.

Single-line change to DefaultsOverride.swift; no API surface impact.
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.

1 participant