pub fn write_file_atomic_secret(path: &Path, bytes: &[u8]) -> Result<()>Expand description
Atomically write secret material without ever creating a group/world readable temporary file.
On Unix the temp inode is created with OpenOptions::mode(0o600) before
any bytes are written, then the open file descriptor is enforced to exact
0600 before the payload is written. Permission failures are hard errors
and the temp file is removed best-effort. On non-Unix platforms there is no
portable POSIX mode API, so this uses the normal create-new temp file,
fsync, and rename sequence.