Skip to content

fix: lower default permissions for stronghold file #481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 2.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion engine/src/snapshot/logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{
convert::TryInto,
fs::{rename, File, OpenOptions},
io::{Read, Write},
os::unix::prelude::OpenOptionsExt,
path::Path,
sync::atomic::{AtomicU8, Ordering},
};
Expand Down Expand Up @@ -188,7 +189,13 @@ pub fn encrypt_file(plain: &[u8], path: &Path, key: &Key) -> Result<(), WriteErr
s.push(hex::encode(salt));
let tmp = Path::new(&s);

let mut f = OpenOptions::new().write(true).create_new(true).open(tmp)?;
let mut options = OpenOptions::new();
#[cfg(unix)]
{
options.mode(0o600);
}

let mut f = options.write(true).create_new(true).open(tmp)?;
// write magic and version bytes
f.write_all(&MAGIC)?;
f.write_all(&VERSION)?;
Expand Down