From a89e65475d8371742c176db42e3b2977760ec153 Mon Sep 17 00:00:00 2001 From: Aleksandr Bogomiakov Date: Thu, 1 Oct 2026 00:31:21 +0100 Subject: [PATCH] Implement Debug manually for PipeSecurityAttributes on Windows The windows_sys::Win32::Security::SECURITY_ATTRIBUTES struct is a raw C FFI struct that does not implement std::fmt::Debug. Deriving Debug on PipeSecurityAttributes failed Windows compilation with E0277. Key changes: - In crates/tsunagi/src/ipc/windows.rs, remove #[derive(Debug)] on PipeSecurityAttributes and provide an explicit std::fmt::Debug implementation formatting nLength, lpSecurityDescriptor, and bInheritHandle. Validation on Linux: - Verified type check against Windows target via rustc. - cargo fmt --all -- --check passed. - cargo clippy --locked --workspace --all-targets -- -D warnings passed. - cargo test --locked --workspace --all-targets --jobs 2 -- --test-threads=2 passed (349 tests passed). --- crates/tsunagi/src/ipc/windows.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/tsunagi/src/ipc/windows.rs b/crates/tsunagi/src/ipc/windows.rs index 603bd04..d7a5dfb 100644 --- a/crates/tsunagi/src/ipc/windows.rs +++ b/crates/tsunagi/src/ipc/windows.rs @@ -61,11 +61,20 @@ const ERROR_PIPE_BUSY: i32 = 231; /// - `S:(ML;;NW;;;ME)`: SACL Mandatory Label with Medium Integrity (`ME`) and No Write Up (`NW`). /// This allows unprivileged user-space processes (Medium Integrity) to write to the /// named pipe even when the agent runs as an elevated Administrator (High Integrity). -#[derive(Debug)] struct PipeSecurityAttributes { attrs: windows_sys::Win32::Security::SECURITY_ATTRIBUTES, } +impl std::fmt::Debug for PipeSecurityAttributes { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("PipeSecurityAttributes") + .field("nLength", &self.attrs.nLength) + .field("lpSecurityDescriptor", &self.attrs.lpSecurityDescriptor) + .field("bInheritHandle", &self.attrs.bInheritHandle) + .finish() + } +} + impl PipeSecurityAttributes { fn new() -> Result { use std::ffi::OsStr;