Skip to content

fix(cli): create exports owner-only and make connect's config write safe - #1678

Merged
ajianaz merged 1 commit into
developfrom
fix/export-and-connect-file-modes-1668
Nov 4, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/export-and-connect-file-modes-1668

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

What

  • New uteke_core::private_file::create_private: creates a file with mode 0600 on Unix (default elsewhere); with replace it tightens an existing file's mode before truncating it.
  • namespace migrate's pre-migration export uses it (write_export).
  • Other full-export writers found and fixed: uteke export --output in commands/maintenance.rs, both the plain and the --full branch. Nothing else in the repo writes a store export (the hook log, init and upgrade files hold no memories).
  • connect's write_atomic creates its temp file with the original file's mode (0600 when there is none) from the start, then restores the exact mode; a leftover temp is removed first so a planted symlink is not followed. Before the rename it re-reads the target and compares it with what was read: if another program changed it (or created it), nothing is written and the error says so, and the temp file is removed. The manifest write goes through the same check.
  • docs/cli-reference.md and CHANGELOG updated. namespace migrate and connect are unreleased, so no compatibility shim; the uteke export change only tightens permissions.

Why

The export holds every memory and was typically 0644; a private ~/.claude/settings.json was briefly readable while the temp was written; and a concurrent write by the agent between read and rename was silently lost.

Closes #1668

Testing

  • Unix permission bits: create_private (new, replace, must-not-exist), the namespace migrate export, and uteke export --output over an existing 0644 file; the connect temp file's mode at creation (checked while the handle is open), including the no-original case and the leftover-symlink case.
  • A config changed between read and rename is not overwritten and reports why; a file created in between is not overwritten; an unchanged config is replaced.
  • cargo fmt --check, cargo clippy -D warnings.

…afe (#1668)

namespace migrate's export and uteke export are created 0600 on Unix. connect's
temp config is created with the original file's mode from the start, and a
config changed between read and rename is not overwritten.
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit a9b4832 into develop Nov 4, 2026
15 checks passed
@ajianaz
ajianaz deleted the fix/export-and-connect-file-modes-1668 branch November 4, 2026 06:46
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.

fix(cli): namespace migrate's export and connect's temp config are created world-readable

1 participant