Repository navigation
Description
What happened
runCommand forces LC_ALL=C and LANG=C for ps and lsof. In the C locale, lsof escapes non-ASCII bytes in file names (for example \xed\x99\x88). The owner-lock lookup filters lsof names by basename only, so escaped paths pass the filter and are then passed to lstat(), which fails. The lookup returns an error, and every owner under such a Codex home is refused with owner_lock_file_lookup_failed (plus owner_holds_other_thread_locks).
Reproduced with a fixture Codex home whose path contains Hangul characters:
classification "live_owner", safeToUnlock false,
blockers ["owner_lock_file_lookup_failed", "owner_holds_other_thread_locks"]
lsof (LC_ALL=C): n/.../\xed\x99\x88 codex/thread-writer-locks/<id>.lock
lsof (en_US.UTF-8): n/.../<original UTF-8 path>/thread-writer-locks/<id>.lock
What you expected
Owner lock files are matched correctly for Codex homes with non-ASCII paths (for example non-ASCII user names on Linux or a custom CODEX_HOME), while still failing closed on genuinely unresolvable paths.
Environment
codex-unlock0.4.0 at6227e6c- macOS 27.0 arm64, Node.js 22.14.0
Source evidence
- C locale forced for diagnostic commands:
Line 50 in 6227e6c
env: { ...process.env, LC_ALL: "C", LANG: "C" }, - Basename-only filter, then
lstatof the escaped name:Lines 292 to 323 in 6227e6c
} const candidates = result.stdout .split(/[\0\n]/) .filter((token) => token.startsWith("n")) .map((token) => token.slice(1)) .filter((path) => /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\.lock(?: \(deleted\))?$/i.test(basename(path))) .filter((path) => basename(dirname(path)) === "thread-writer-locks"); let intendedCanonical: string; try { const intendedDirectory = await realpath(dirname(intendedLockPath)); intendedCanonical = join(intendedDirectory, basename(intendedLockPath)); } catch (error) { return { paths: [], error: `intended lock directory is unresolved: ${errorText(error)}` }; } const paths: string[] = []; for (const path of candidates) { if (path.endsWith(" (deleted)")) { return { paths: [], error: `open lock path was deleted: ${path}` }; } if (!isAbsolute(path)) { return { paths: [], error: `lsof returned a relative lock path: ${path}` }; } try { const value = await lstat(path); if (value.isSymbolicLink() || !value.isFile()) { return { paths: [], error: `open lock path is a symlink or non-regular file: ${path}` }; } const canonicalDirectory = await realpath(dirname(path)); const canonicalPath = join(canonicalDirectory, basename(path)); paths.push(canonicalPath === intendedCanonical ? intendedLockPath : canonicalPath); } catch (error) { return { paths: [], error: `open lock path is unresolved: ${errorText(error)}` }; - Resulting blocker:
Line 78 in 6227e6c
if (context.ownerLockError) addOnce(blockers, "owner_lock_file_lookup_failed");
Acceptance criteria
- Lock files are matched without relying on
lsofname rendering, for example by comparinglsof -Fdevice/inode fields with the probed lock's device/inode, or by strictly decodinglsofescapes. - A test covers a Codex home path with non-ASCII characters.
Scope and limitations
- Fails in the safe direction (always refuses); no bypass was found. This is an availability defect for users with non-ASCII home paths.
Checked
- security: inherited COLUMNS truncates ps args and hides shared app-server owners on Linux #52 (
COLUMNStruncation) and security: resolve ps and lsof only from fixed system paths #61 (fixedps/lsofpaths) affect the same command execution layer but not locale-dependent name escaping.
Activity
fix: parse Linux lsof file sets and call spawn directly
fix: harden diagnostic command execution
fix: parse Linux lsof file sets and call spawn directly