From 04782a953284439efc89099f887f8cc7dd43246d Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Sat, 17 Jan 2026 09:21:03 +0100 Subject: [PATCH] fix: Ensure OS is considered for auth cache file '0o600' permissions are only possible on unix. Wrap it with the conditional compilation. --- openstack_sdk/src/state.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/openstack_sdk/src/state.rs b/openstack_sdk/src/state.rs index 307696a6f..a4607c9e4 100644 --- a/openstack_sdk/src/state.rs +++ b/openstack_sdk/src/state.rs @@ -22,6 +22,7 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::fs::{DirBuilder, File}; use std::io::prelude::*; +#[cfg(unix)] use std::os::unix::fs::PermissionsExt; use std::path::PathBuf; use tracing::{debug, info, trace, warn}; @@ -275,8 +276,19 @@ impl State { match file.metadata() { Ok(metadata) => { let mut permissions = metadata.permissions(); - permissions.set_mode(0o600); - let _ = file.set_permissions(permissions); + #[cfg(unix)] + { + // This code only exists on Linux/macOS/etc. + permissions.set_mode(0o600); + let _ = file.set_permissions(permissions); + } + + #[cfg(windows)] + { + // On Windows, only readonly is possible and reasonable. + permissions.set_readonly(true); + let _ = file.set_permissions(permissions); + } } Err(_) => { warn!("Cannot set permissions for the cache file");