From 9b4e1134d536caeb1fdbc2b8a0a875be8afccb9b Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 27 Nov 2026 16:18:46 +0700 Subject: [PATCH] platform: the inherit-only test checks the Users entry apart from the runner's On a GitHub Windows runner the temp folder's Administrators entry is inherited and comes first, so the folder check reported it before the Users entry the test adds and the assertion on Users failed. --- crates/platform/src/owner_only.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/platform/src/owner_only.rs b/crates/platform/src/owner_only.rs index fcfdad684e..b37ecdf9f7 100644 --- a/crates/platform/src/owner_only.rs +++ b/crates/platform/src/owner_only.rs @@ -778,9 +778,17 @@ $n = [CraftProbe.Console]::GetConsoleProcessList($ids, 256) let ok = std::process::Command::new("icacls").arg(&dir).arg("/grant").arg("*S-1-5-32-545:(OI)(CI)(IO)R").output().unwrap(); assert!(ok.status.success(), "{}", String::from_utf8_lossy(&ok.stderr)); let sddl = sddl_of(&dir).unwrap(); - assert!(sddl.contains(";IO;") && sddl.contains(";S-1-5-32-545)"), "the inherit-only entry for Users is read: {sddl}"); + let users = sddl + .split('(') + .filter_map(|ace| ace.split(')').next()) + .find(|ace| ace.split(';').nth(1).is_some_and(|flags| flags.contains("IO")) && ace.ends_with(";S-1-5-32-545")); + let users = users.unwrap_or_else(|| panic!("the inherit-only entry for Users is read: {sddl}")); + // The folder also inherits the temp folder's entries (Administrators on a CI runner), which the check reports + // first, so it is asked about the Users entry alone. let me = current_user_sid().unwrap(); - assert!(foreign_folder_access(&sddl, &me).is_some_and(|p| p.contains("S-1-5-32-545")), "{sddl}"); + let only_users = format!("O:{}D:({users})", section(&sddl, "O:").unwrap()); + assert!(foreign_folder_access(&only_users, &me).is_some_and(|p| p.contains("S-1-5-32-545")), "{sddl}"); + assert_eq!(foreign_access(&only_users, &me), None, "a file's check skips the inherit-only entry: {sddl}"); let _ = std::fs::remove_dir_all(&dir); }