Expand description
Selecting a distribution and asking it the five questions that decide whether the product may manage it.
§One invocation shape, and only one
Every Linux command this adapter runs is
wsl.exe --distribution <NAME> --user <USER> --exec <PROGRAM> [ARG ...]as an argument vector — LinuxCommand::wsl_arguments builds it, and it
is the only thing that does. --exec is what makes that true end to end:
Microsoft documents it as “execute the specified command without using the
default Linux shell”, so the arguments reach execvp as they were written
and no ;, &&, $(…) or quote in a distribution name, a path or a
version string is ever interpreted by anything
(https://learn.microsoft.com/en-us/windows/wsl/basic-commands).
The Windows half is the same story: super::exec::CommandRequest holds a
Vec<OsString> and std::process::Command quotes each element for
CommandLineToArgvW. There is no point in the chain at which a string is
split back into arguments.
§The five preflight questions
02-target-architecture.md step 1 is “validate that NAME is installed as
WSL2, starts as root, and runs systemd”, and 03-security-and-lifecycle.md
adds the architecture row to the failure table. probe_readiness asks
them in the order in which a failing answer is most useful:
- Installed, exactly.
wsl --list --verbose, matched case-sensitively. - WSL2. A WSL1 distribution has no systemd and no separate kernel;
refusing here is
Compatibility’s “explicit preflight failure”. - Root.
id -umust answer0. The provider installs a system service and writes/usr/local/bin; discovering that it cannot halfway through is the failure mode this question removes. - A supported Linux architecture.
uname -m, mapped to the architectures the release actually publishes. - systemd.
systemctl is-system-running. WSL runs systemd only when the distribution opts in and the WSL build is 0.67.6 or newer (https://learn.microsoft.com/en-us/windows/wsl/systemd), and the Linux daemon is a system unit.
No question in this list mutates anything. That is what
03-security-and-lifecycle.md’s “WSL/systemd preflight — no mutation and no
device login” means in code: a failure here happens before a credential has
been issued, before a byte has been written into the distribution, and
before a Windows task exists.
Structs§
- Distribution
Readiness - Everything the preflight established about one distribution.
- Linux
Command - A program to run inside a named distribution, as a literal argument vector.
- WslExecutable
wsl.exe, as found on this host or as a test says it is.- WslInvoker
- Runs
wsl.exe, through whateverCommandRunnerit was given.
Enums§
- Systemd
State - What
systemctl is-system-runningsaid.
Constants§
- LINUX_
USER - The Linux account every managed command runs as.
Functions§
- architecture_
from_ uname - Maps
uname -monto the architectures the release publishes. - probe_
readiness - Asks the five preflight questions. Mutates nothing.