fix(cli): owner-only engine state and a clean refusal for an untrusted lock dir - #1162
Merged
Merged
Conversation
…perms # Conflicts: # CHANGELOG.md
…perms # Conflicts: # CHANGELOG.md # src/openkos/cli/main.py
…perms # Conflicts: # CHANGELOG.md # docs/cli.md
…perms # Conflicts: # src/openkos/application/doctor.py
…perms # Conflicts: # CHANGELOG.md
…perms # Conflicts: # CHANGELOG.md
…perms # Conflicts: # CHANGELOG.md
…perms # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
<tmp>/openkos-locks-<uid>) is trusted only if it is a real directory, owned by the current euid, with no group/other bits; the lock file is opened withO_NOFOLLOWand mode0600. AnyOSErrorfrom creating/opening maps to a new typedWorkspaceLockUnavailableError, which_guard_workspace_lockturns into a clean refusal (exit 1, naming the path and the fix) instead of a traceback. Exit 3 stays reserved for genuine contention, because this refusal is not fixed by retrying..openkos/andbundle/.state/(plus dirs beneath it)0700; every SQLite store0600before first write (WAL/-shm inherit it, verified by test). Existing files/dirs are left as found;bundle/,raw/and concepts are untouched.doctorreports exposed engine state with a one-linechmod go-rwxfix. It emits a line only when something is exposed, so the fixed check count is unchanged.Related issue
Closes #1134
Closes #1135
Type of change
How was this tested
Strict TDD: RED observed first for both issues, then GREEN. Mutation-checked uid, mode, symlink,
O_NOFOLLOW,touch_privatemode and the doctor mask.ruff check,ruff format --check,mypy .clean; fullpytest tests7713 passed, 2 skipped. Mode/ownership tests are POSIX-only (skipif Windows); owner mismatch is simulated by patchingos.geteuid.Checklist
derived-index-cache,doctor-command), CHANGELOG### Security,docs/cli.mdexit-code noteNotes for reviewers
doctortest fixtures that hand-build.openkos/now run under a0o077umask so they stay quiet.