Skip to content

The agent that grows with you

test(gateway): deny Everyone full access for the reporters'-ACL Windows test

Tekniumdda8a0dd0f52
diff --git a/tests/tools/test_bot_live_delivery_windows_acl.py b/tests/tools/test_bot_live_delivery_windows_acl.py
index 24f9e14f739..32336e6ec14 100644
--- a/tests/tools/test_bot_live_delivery_windows_acl.py
+++ b/tests/tools/test_bot_live_delivery_windows_acl.py
@@ -140,13 +140,13 @@ _UNUSABLE_CHILD = _DROP_PRIVILEGES + textwrap.dedent(r"""
def test_startup_skips_bot_recovery_on_the_reporters_mailbox_acl(tmp_path):
root = tmp_path / "runtime" / "bot_live_delivery"
root.mkdir(parents=True)
- # The reporters' shape: owned by someone else, inheritance cut, no ACE for this token. The CI
- # runner's own identity is not knowable up front (it may hold SYSTEM or Administrators, which an
- # Administrators-owner/SYSTEM-only DACL would still let in), so the owner and the only ACE go to
- # LocalService (S-1-5-19), which no runner token carries. Without SeBackup/SeRestore the child has
- # no route to list or create in it, so os.open(.lock) fails exactly as in #138872.
- for args in (["/inheritance:r", "/grant:r", "*S-1-5-19:(OI)(CI)F"], ["/setowner", "*S-1-5-19"]):
- subprocess.run(["icacls", str(root), *args], check=True, capture_output=True)
+ # The reporters' effect: this token can neither list nor create in the dir (#138872: no ACE for the
+ # user). Reassigning the owner to an identity outside the runner's token needs SeRestore inside icacls
+ # (exit 5 on the hosted runner), and an Administrators-owned, SYSTEM-only DACL still let the runner in.
+ # A deny ACE for Everyone is definitive for every identity the runner might hold; with SeBackup and
+ # SeRestore removed the child has no bypass, so os.open(.lock) fails as in the reports. The owner's
+ # implicit WRITE_DAC is untouched, which is what lets the finally block lift the deny again.
+ subprocess.run(["icacls", str(root), "/deny", "*S-1-1-0:(F)"], check=True, capture_output=True)
try:
child = subprocess.run([sys.executable, "-c", _UNUSABLE_CHILD, str(tmp_path)], cwd=_REPO,
capture_output=True, text=True, check=False, timeout=180)
@@ -160,8 +160,4 @@ def test_startup_skips_bot_recovery_on_the_reporters_mailbox_acl(tmp_path):
assert str(root.resolve()) in warnings[0] and "(owner " in warnings[0]
assert "icacls" in warnings[0] and "/reset" in warnings[0]
finally:
- # Give the dir back to this (elevated) test so pytest can delete tmp_path: take ownership
- # (icacls uses SeRestore), then the owner's implicit WRITE_DAC lets the grant and reset through.
- subprocess.run(["icacls", str(root), "/setowner", "*S-1-5-32-544"], check=False, capture_output=True)
- subprocess.run(["icacls", str(root), "/grant", "*S-1-5-32-544:(OI)(CI)F"], check=False, capture_output=True)
- subprocess.run(["icacls", str(root), "/reset", "/t", "/c"], check=False, capture_output=True)
+ subprocess.run(["icacls", str(root), "/remove:d", "*S-1-1-0"], check=False, capture_output=True)