Skip to content

feat(services): PostgreSQL as a service MixEngine runs (T34, T34a) - #6

Merged
haiquang9994 merged 17 commits into
masterfrom
feat/t34-postgres
Aug 20, 2026
Merged

feat(services): PostgreSQL as a service MixEngine runs (T34, T34a)#6
haiquang9994 merged 17 commits into
masterfrom
feat/t34-postgres

Conversation

@haiquang9994

Copy link
Copy Markdown
Collaborator

PostgreSQL becomes a service MixEngine can run: a recipe that lays down the files, a first-run
initdb ritual, a pg_hba.conf that admits nothing but the local machine, and a superuser
credential that is named rather than written down.

The suite that judges it starts a real server, queries it with the password MixEngine generated,
stops it, and asserts the ritual does not run twice. It runs on all three operating systems in CI,
against a real PostgreSQL fetched by the workflow.

T34a — a supervised child never inherits Administrators

Getting there needed the Windows spawn path rewritten. A daemon started elevated used to hand its
whole token to every child; now every supervised process and every one-shot is created from a
restricted copy with BUILTIN\Administrators and Power Users disabled. ADR 0010 records the
decision.

Two findings are written down where the next person will meet them:

  • A restricted token has to keep granting its own user. A child from the restricted token died
    at 0xC0000142 before its first instruction. The cause is the token's default access control
    list: an elevated administrator's names SYSTEM and BUILTIN\Administrators and nothing else, so
    disabling that group leaves the child unable to open the objects it creates itself. The window
    station was the plausible candidate and was measured innocent — that is recorded too, so the
    afternoon is not spent twice.
  • A reused hyper connection has to wait until it can take the next request. hyper allows exactly
    one request before its connection task has signalled ready. The CLI's handshake spends it, so
    every real mix command was request number two and could fail with connection was not ready.
    Reproduced on Linux 1 round in 10, then 15 clean rounds after ready().await. This one was a live
    bug in mix, not only in tests.

Verification

CI run 32392948163 is green on all seven jobs — lint, test and bench on Windows, macOS and
Linux — with the PostgreSQL suite passing against a real server on each.

…s on (T34a)

CreateProcessAsUserW requires the token it is given to be able to open the
window station and the desktop the child starts on. A station granted to
BUILTIN\Administrators rather than to a logon SID is one a token holding that
group deny-only cannot open, and the child dies at STATUS_DLL_INIT_FAILED
before its first instruction.

Measured rather than guessed: on the Windows runner the restricted child exited
0xC0000142 on WinSta0 while the same spawn from this process's own token ran and
printed.

restricted::admit adds an entry for the child's own user to both objects, once
per process and only where this process holds an enabled Administrators, so an
ordinary machine writes to nothing.
hyper's dispatcher lets exactly one request through before it has said it wants
one, and every request after that only once the connection task has been polled
since the last response. Sending straight away raced that task: the request was
refused before it was written, with `canceled: connection was not ready`, which
reads like a daemon that hung up.

The CLI client meets this on every command, because the handshake spends the one
free request. Reproduced on WSL at roughly one run in ten of the daemon's
runtimes suite, and seen once on the Linux CI leg; fifteen runs after the fix
are clean.

Fixed in the client and in the three test suites that reuse a connection. The
suites that open one per request are already covered by hyper's first-request
allowance.
The window station was the wrong object. Granting the user WINSTA_ALL_ACCESS on
WinSta0 and every right on its desktop changed nothing; that route is reverted
here rather than left in, because it wrote to a shared machine object for no
gain.

Bisecting the restriction on an elevated machine found the real one: nothing
disabled runs, Power Users disabled runs, Administrators disabled dies at
STATUS_DLL_INIT_FAILED. An elevated administrator's token carries a default
access control list naming SYSTEM and BUILTIN\Administrators and nothing else,
because that group is the token's owner — so disabling it leaves a child with no
access to the kernel objects it creates itself, including the ones the loader
and CSRSS create while it is starting.

keep_what_a_child_creates_reachable merges one allow entry for the token's own
user into that list, unconditionally: it changes a token just made and no object
anybody else can see. Verified in an elevated shell, which is the configuration
the runner has and a developer's machine does not.
@haiquang9994
haiquang9994 merged commit b88fb27 into master Aug 20, 2026
7 checks passed
@haiquang9994
haiquang9994 deleted the feat/t34-postgres branch August 20, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant