From 2489e34993986251a56dbc6dfe2233d85b02ac0e Mon Sep 17 00:00:00 2001 From: sigoden Date: Thu, 4 May 2023 16:29:34 +0800 Subject: fix: config file with strict perms (#118) --- src/config/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/config') diff --git a/src/config/mod.rs b/src/config/mod.rs index 19f21a0..376f923 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -538,6 +538,12 @@ fn create_config_file(config_path: &Path) -> Result<()> { } ensure_parent_exists(config_path)?; std::fs::write(config_path, raw_config).with_context(|| "Failed to write to config file")?; + #[cfg(unix)] + { + use std::os::unix::prelude::PermissionsExt; + let perms = std::fs::Permissions::from_mode(0o600); + std::fs::set_permissions(config_path, perms)?; + } Ok(()) } -- cgit v1.2.3