diff options
Diffstat (limited to 'src/doctor.rs')
| -rw-r--r-- | src/doctor.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/doctor.rs b/src/doctor.rs index 42d24a8..65fca50 100644 --- a/src/doctor.rs +++ b/src/doctor.rs | |||
| @@ -19,7 +19,20 @@ pub fn run(cfg: &Config) -> i32 { | |||
| 19 | 19 | ||
| 20 | match config::key_source() { | 20 | match config::key_source() { |
| 21 | KeySource::Env => row(true, "key", "present in OPENCODE_API_KEY"), | 21 | KeySource::Env => row(true, "key", "present in OPENCODE_API_KEY"), |
| 22 | KeySource::File(path) => row(true, "key", &format!("present in {}", path.display())), | 22 | KeySource::File(path) => { |
| 23 | row(true, "key", &format!("present in {}", path.display())); | ||
| 24 | use std::os::unix::fs::PermissionsExt; | ||
| 25 | if let Ok(meta) = std::fs::metadata(&path) { | ||
| 26 | if meta.permissions().mode() & 0o077 != 0 { | ||
| 27 | println!( | ||
| 28 | "{:<13} {:<4} {} is readable by other users; chmod 600 it", | ||
| 29 | "key perms", | ||
| 30 | "WARN", | ||
| 31 | path.display() | ||
| 32 | ); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | } | ||
| 23 | KeySource::Missing => { | 36 | KeySource::Missing => { |
| 24 | row( | 37 | row( |
| 25 | false, | 38 | false, |
