Skip to main content

write_owner_only

Function write_owner_only 

Source
pub fn write_owner_only(path: &Path, contents: &[u8]) -> Result<()>
Expand description

Writes contents to path with owner-only permissions, in one step.

The same replacement as [write], with two differences that matter only for key material: the file is created 0600 before a single byte reaches it, and the target’s permissions are not inherited — a key file that was somehow left world readable must not stay that way.

On Windows there is no mode to set, so nothing here narrows anything: the file inherits the ACL of the directory it is created in. For the repository’s own key that is the protection git gives .git/config, which is the same protection as the rest of the checkout. For export-key the user picks the directory, so the directory is the protection. Weaker than 0600 either way, and recorded as a limitation in README.md §Known limitations and in context/foundation/zalozenia.md — the founding document claimed owner-only ACLs here until 2026-08-05, which was never true of any build.

§Errors

As [write].