diff --git a/Cargo.toml b/Cargo.toml index 53bb7d831..4388fb062 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,7 +142,6 @@ windows = { version = "0.61", features = [ "Win32_System_Pipes", "Win32_System_Registry", "Win32_System_SystemInformation", - "Win32_System_SystemServices", "Win32_System_Threading", "Win32_UI_Shell", "Win32_UI_WindowsAndMessaging", diff --git a/src/ipc/windows.rs b/src/ipc/windows.rs index 1bb36d359..b98729c8f 100644 --- a/src/ipc/windows.rs +++ b/src/ipc/windows.rs @@ -23,10 +23,7 @@ use windows::{ Storage::FileSystem::{ FILE_FLAG_OVERLAPPED, FILE_GENERIC_READ, FILE_WRITE_DATA, SECURITY_IDENTIFICATION, }, - System::{ - Pipes::{GetNamedPipeServerProcessId, GetNamedPipeServerSessionId}, - SystemServices::ACCESS_ALLOWED_ACE_TYPE, - }, + System::Pipes::{GetNamedPipeServerProcessId, GetNamedPipeServerSessionId}, }, }; @@ -36,6 +33,7 @@ const CLIENT_ACCESS: u32 = FILE_GENERIC_READ.0 | FILE_WRITE_DATA.0; const PIPE_BUSY_RETRY: Duration = Duration::from_millis(50); const AUTH_LOG_INTERVAL: Duration = Duration::from_secs(5); const SYSTEM_SID: &str = "S-1-5-18"; +const ACCESS_ALLOWED_ACE_TYPE_U8: u8 = 0; struct LocalAllocation(*mut c_void); @@ -174,7 +172,7 @@ fn ensure_restricted_dacl(dacl: *const ACL, owner: PSID) -> ResultType<()> { unsafe { GetAce(dacl, index.into(), &mut ace) } .context("Failed to read IPC server access rule")?; let header = unsafe { &*(ace as *const ACE_HEADER) }; - if header.AceType != (ACCESS_ALLOWED_ACE_TYPE as u8) + if header.AceType != ACCESS_ALLOWED_ACE_TYPE_U8 || usize::from(header.AceSize) < std::mem::size_of::() { bail!("Unsupported IPC server access rule"); diff --git a/src/server.rs b/src/server.rs index b839a6921..ed11624fa 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1003,6 +1003,8 @@ mod windows_gui_startup_tests { const CHILD_TEST: &str = "RUSTDESK_TEST_GUI_IPC_CHILD"; const CHILD_TIMEOUT_MS: u32 = 10_000; + // An unmatched test filter exits with zero without running the child assertions. + const CHILD_SUCCESS_EXIT_CODE: i32 = 42; #[test] fn windows_gui_survives_ipc_bind_failure() { @@ -1021,7 +1023,7 @@ mod windows_gui_startup_tests { }); start_server(true, false); assert!(!crate::common::is_server_running()); - return; + std::process::exit(CHILD_SUCCESS_EXIT_CODE); } let mut child = Command::new(std::env::current_exe().unwrap()) @@ -1040,9 +1042,10 @@ mod windows_gui_startup_tests { child.wait().unwrap(); panic!("GUI IPC startup test timed out or failed to wait: {result:?}"); } - assert!( - child.wait().unwrap().success(), - "GUI process did not survive" + assert_eq!( + child.wait().unwrap().code(), + Some(CHILD_SUCCESS_EXIT_CODE), + "GUI subprocess did not complete the startup assertions" ); } }