diff options
| author | sigoden <sigoden@gmail.com> | 2023-05-04 16:29:34 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-04 16:29:34 +0800 |
| commit | 2489e34993986251a56dbc6dfe2233d85b02ac0e (patch) | |
| tree | 1e512f5fb1ec79bc6282a7676f58b95a93f32a1b /src/config | |
| parent | 439d231e42692448da4fdf575f7797c91d5b8522 (diff) | |
| download | aichat-2489e34993986251a56dbc6dfe2233d85b02ac0e.tar.gz | |
fix: config file with strict perms (#118)
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/mod.rs | 6 |
1 files changed, 6 insertions, 0 deletions
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(()) } |
