fix(windows): address IPC review follow-ups (#16885)

Require a dedicated child success exit code so an unmatched test filter cannot pass the GUI startup regression. Replace the ACE type binding with a local constant and drop the unused SystemServices feature.

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou authored and GitHub committed 2026-11-05 23:43:54 +08:00
1 parent 2c085f91db
commit cbde394666
3 files changed
+10 -10

No files matched your search

-1
View File
@@ -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",
+3 -5
View File
@@ -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::<ACCESS_ALLOWED_ACE>()
{
bail!("Unsupported IPC server access rule");
+7 -4
View File
@@ -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"
);
}
}