#[cfg(windows)]
use std::env;
pub fn configured_sddl() -> Option<String> {
env::var("IPC_BROKER_PIPE_SDDL").ok()
}
pub fn sddl_is_insecure(sddl: &str) -> bool {
let s = sddl.to_ascii_lowercase();
s.contains("wd") || s.contains("everyone")
}
pub fn effective_sddl() -> Result<Option<String>, String> {
if let Some(cfg) = configured_sddl() {
if sddl_is_insecure(&cfg) {
return Err(format!(
"Refusing to use insecure SDDL provided in IPC_BROKER_PIPE_SDDL: '{}'",
cfg
));
}
return Ok(Some(cfg));
}
let default = "D:(A;;GA;;;AU)(A;;GA;;;BA)".to_string();
Ok(Some(default))
}
pub fn guidance_msg() -> &'static str {
"Set IPC_BROKER_PIPE_SDDL to a suitable SDDL string (avoid 'WD'/Everyone)."
}
#[cfg(not(windows))]
compile_error!("src/windows_acl.rs must only be compiled on Windows targets");