A non-elevated Desktop or CLI could never reach an elevated gateway on
Windows. The client half of the control-pipe identity check opened the
server PID with OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION), which a
filtered token cannot do on a High-integrity process, so every attach
failed with "cannot verify bootstrap peer process" and discovery
reported the generic `authorization`.
The client now also reads the pipe object itself through its own handle:
the owner and DACL (GetSecurityInfo) and the server's session
(GetNamedPipeServerSessionId), next to GetNamedPipeServerProcessId.
judge_pipe_server() decides from those facts and is pure, so it is unit
tested with the Win32 calls injected:
- server process readable: its token user must be this user, as before;
a pipe owned by BUILTIN\Administrators (an elevated creator) seen from
a non-elevated client is refused as `gateway_elevated`.
- server process unreadable: never attached. A pipe owned by this user
or Administrators whose DACL grants exactly this user (the gateway's
own private shape) is this user's gateway across the boundary and is
refused with the existing classify_refused_owner() reason and
refused_owner_remedy() wording; anything else stays the generic
refusal.
The refusal is a PermissionError subclass carrying the reason code, and
discover_gateway_endpoint() reports it directly, so the name no longer
depends on a provable gateway.pid/gateway.lock record.
Refs #134889 (W9)
Refs #140762
Refs #140706
Co-authored-by: Casey <caseyrussell1976@gmail.com>