Repository navigation
fix(cli): create rclone credentials with private permissions - #1924
Conversation
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Signed-off-by: phernandez <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c37677bc7f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Signed-off-by: phernandez <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
## Why Atomic writes stage content in a file created with ordinary permissions, then restore the target's mode only after writing. Under umask 000, rewriting a private 0600 note stages its bytes in a 0666 file. Fixes #1906. ## What Changed Create the content-bearing staging inode with mode 0600 from the outset for both text and binary writers. Preserve the target's final permissions; newly created targets retain their normal umask-derived final mode. ## Implementation Details Capture the existing target mode, or determine the umask-derived mode using an empty probe in a private temporary directory for a new target. This avoids mutating the process-wide umask and prevents an observer from opening the content inode before permissions tighten. Existing publication-time chmod remains in place, preserving read-only and shared target behavior. No content reaches the staging file until reservation returns. Stacked on #1924; only atomic staging permissions and their regression tests are new here. ## Testing - Before the fix: all three real staging regressions failed under umask 000. A later real-open observer also failed against chmod-after-create, reproducing the descriptor-retention gap; the inode now starts private. - `uv run pytest tests/utils/test_atomic_staging_permissions.py tests/utils/test_file_utils.py -q --no-cov`: 60 passed. - `just fast-check`: passed, including repository type checking. - `just doctor`: passed sandboxed write/index/search self-test. ## Risks / Follow-ups This closes the staging-content permission window without changing final file modes or the atomic rename protocol. POSIX permission regressions skip Windows, which uses native ACL semantics. --------- Signed-off-by: phernandez <[email protected]>
Why
Rclone credentials inherit ordinary filesystem permissions. Under umask 000, a real configuration call creates a 0777 directory and a 0666 credential file. Existing loose files and backups remain exposed. Fixes #1914.
What Changed
Create/tighten the rclone directory to 0700 and config/backup files to 0600 before writing credential bytes. Preserve other remote sections and backup content.
Implementation Details
Use explicit creation modes and tighten existing files before writing through the opened handle. Backup copying uses a private destination rather than copy2's ordinary file creation. POSIX regressions use a real temporary home and permissive umask without mocks. Windows keeps its native ACL semantics; POSIX mode assertions skip there.
Stacked on #1923; only rclone permission handling and its tests are new here.
Testing
uv run pytest tests/cli/cloud/test_rclone_permissions.py tests/cli/cloud/test_rclone_config_and_bmignore_filters.py -q --no-cov: 15 passed.just fast-check: passed, including repository type checking.just doctor: passed sandboxed write/index/search self-test.Existing configs are tightened on discovery, before parsing can fail. The malformed-config regression failed before that fix. Reads and writes retain the original locale-default encoding.
Risks / Follow-ups
Existing rclone directory permissions are intentionally tightened to owner-only, including access to its other configured remotes. Backups retain content but no longer copy source timestamps. This is a local credential-file fix, not a claim of remote exposure.