authoravatarclover caruso<git@paperclover.net>2026-10-22 13:14:53-07:00
committeravatarclover caruso<git@paperclover.net>2026-10-24 19:01:23-07:00
log92dda739cbc51cce5bb840529388707c70648e64
tree3fa2318c2846092833cc04ffc98541b6c028b7b4
parent756c156486e0d69ac87e351d8429af457369d2f1
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Preserve Windows 7 task identity and recognize QGA completion under host hardening

Capture the guest task definition before renaming its account, then rebind the principal and trigger to the preserved SID. Match known missing-process responses per stderr line so virsh cache warnings do not hide completed commands. Assisted-by: gpt-6.1-sol

3 files changed, 7 insertions(+), 4 deletions(-)

guest/windows-provision.ps1+3-1
......@@ -98,6 +98,8 @@ try {
9898 Start-Sleep -Milliseconds 250
9999 $desktop = Find-Desktop
100100 }
101 # Windows 7 cannot resolve the old task principal after the account is renamed.
102 $definition = $folder.GetTask("SnowglobeGuest-$sid").Definition
101103 Set-GuestPassword $user.Name $password
102104 if ($user.Name -ine $username -and $user.Rename($username).ReturnValue -ne 0) { throw 'The template account could not be renamed.' }
103105 Set-ItemProperty $winlogon AutoAdminLogon '1'
......@@ -105,7 +107,7 @@ try {
105107 Set-ItemProperty $winlogon DefaultDomainName $env:COMPUTERNAME
106108 Set-ItemProperty $winlogon DefaultPassword $password
107109 Remove-ItemProperty $winlogon AutoLogonCount -ErrorAction SilentlyContinue
108 $definition = $folder.GetTask("SnowglobeGuest-$sid").Definition
110 $definition.Principal.UserId = $sid
109111 $definition.Triggers.Item(1).UserId = $sid
110112 $definition.Settings.Enabled = $true
111113 $task = $folder.RegisterTaskDefinition("SnowglobeGuest-$sid", $definition, 6, $sid, $null, 3, $null)
tools/computer-test.py+1-1
......@@ -97,7 +97,7 @@ class GuestCancellation(unittest.TestCase):
9797
9898 def test_guest_pid_absence_is_distinct_from_transport_failure(self):
9999 for message in ['PID 2596 does not exist', 'PID ld does not exist', 'PID lld does not exist', "Invalid parameter 'pid'", 'Guest agent is not responding']:
100 response = Mock(stdout='', stderr='error: ' + message + '\n')
100 response = Mock(stdout='', stderr='error: ' + message + '\nerror: Failed to create virsh cache: Read-only file system\n')
101101 with self.subTest(message=message), patch.object(computer.subprocess, 'run', return_value=response):
102102 with self.assertRaises(ValueError if message == 'Guest agent is not responding' else ProcessLookupError):
103103 computer.qga('fixture', 'guest-exec-status', pid=2596)
tools/vm-computer.py+3-2
......@@ -41,8 +41,9 @@ def qga(name, operation, **arguments):
4141 value = json.loads(line)
4242 if 'return' in value:
4343 return value['return']
44 if operation == 'guest-exec-status' and result.stderr.rstrip().endswith((
45 f"PID {arguments['pid']} does not exist", 'PID ld does not exist', 'PID lld does not exist', "Invalid parameter 'pid'")):
44 if operation == 'guest-exec-status' and any(line.endswith((
45 f"PID {arguments['pid']} does not exist", 'PID ld does not exist', 'PID lld does not exist', "Invalid parameter 'pid'"))
46 for line in result.stderr.splitlines()):
4647 raise ProcessLookupError('The guest process result is unavailable. Check the VM before retrying.')
4748 raise ValueError('The guest agent did not answer. Wait for the VM to finish starting, then retry.')
4849