]> vilimpoc.org git repositories - dotfiles/blob - README.md
dotfiles: Windows XP VM provisioning
[dotfiles] / README.md
1 # dotfiles
2
3 Windows development-box provisioning scripts.
4
5 `setup-windows.bat` takes a fresh Windows install to a working C++ / native
6 development environment: editors and shells, Python, the Visual Studio 2022
7 toolchain (including the Clang and Windows XP targeting toolsets), the Windows
8 Driver Kit, and a handful of analysis tools (Sysinternals, OpenCppCoverage,
9 BinSkim, the Windows Performance Toolkit). It also sets the box up to be driven
10 remotely: OpenSSH Server plus an rsync build for Windows, which is what makes a
11 throwaway VM reachable from a Linux host.
12
13 `setup-windows-xp.bat` does the equivalent job for the Windows XP VM the
14 XP-toolset builds get tested on: an SSH server and the last Python that still
15 runs there. It shares no machinery with the modern script, because XP has none
16 of it.
17
18 ## Files
19
20 | File | Purpose |
21 | --- | --- |
22 | `setup-windows.bat` | Entry point. Runs the non-elevated, per-user half (winget installs, user `PATH` edits, global git config), then launches the elevated half and prints its log. |
23 | `setup-windows-xp.bat` | Standalone, for a Windows XP VM. Installs and configures an SSH server, fixes the two XP logon policies that silently break SSH password auth, and installs Python 3.4.4. Installs nothing it did not find staged on disk first. |
24 | `xp-fetch.py` | Downloads over TLS 1.2 from inside the XP VM, which the OS itself cannot do. Verifies against `cacert.pem` beside it, since XP's root store is too old to validate anything current. `--tls-check HOST` reports the negotiated protocol and cipher, which separates "TLS stack too old" from "certificate store too old". |
25 | `setup-windows-with-uac.ps1` | The elevated half, started via UAC by the batch file. Enables `ssh-agent`, installs and starts OpenSSH Server, installs `rsync.exe` to the machine `PATH`, then installs Visual Studio 2022 Community with the required components, the WDK, and the Windows Performance Toolkit. Can also be run directly from an Administrator prompt. |
26
27 ## Usage
28
29 1. **Edit `setup-windows.bat` first.** The global git identity near the middle of
30    the file is placeholder text:
31
32    ```bat
33    git config --global user.name "PLACEHOLDER_NAME"
34    git config --global user.email "PLACEHOLDER_EMAIL"
35    ```
36
37    Substitute your own name and email, or comment both lines out to keep your
38    identity per-repository.
39
40 2. Run it from a normal (non-elevated) prompt:
41
42    ```bat
43    setup-windows.bat
44    ```
45
46    It will raise a single UAC prompt for the elevated half. Accept it — declining
47    leaves Visual Studio and the WDK uninstalled, and the script says so.
48
49 3. Restart your shell afterwards so the updated user `PATH` is picked up, and
50    reboot if a step reported that a restart was required.
51
52 ## Notes
53
54 - The elevated half writes a transcript to `setup-windows-uac.log` next to the
55   script; the batch file prints it when the elevated window closes. The log is
56   gitignored, as it contains local paths.
57 - Both halves are idempotent — re-running skips anything already installed.
58   BinSkim in particular checks NuGet for the newest stable version *before*
59   downloading: the package is a self-contained .NET build well over 100 MB, and
60   re-provisioning an up-to-date box should not pay for it. The installed version
61   is tracked in `nupkg-version.txt` beside the tool.
62 - **Remote access.** OpenSSH Server is installed from the Windows on-demand
63   capability (10/1809+), set to start automatically, and given an inbound TCP 22
64   firewall rule on *all* profiles — a VM's host-only or bridged adapter is
65   routinely classified Public, which is the usual reason a running `sshd` is
66   unreachable. Windows ships no `rsync`, so a build of it
67   ([nuket/rsync-windows](https://github.com/nuket/rsync-windows)) is installed to
68   `C:\Tools\rsync` and added to the **machine** `PATH`. That last detail matters:
69   the remote end of an `rsync` runs non-interactively, with no login shell, and
70   Win32-OpenSSH builds that environment from the registry `PATH` rather than from
71   a profile. Key auth needs `~/.ssh/authorized_keys` ACL'd to just you and
72   `SYSTEM`; accounts in the Administrators group use
73   `C:\ProgramData\ssh\administrators_authorized_keys` instead.
74 - Visual Studio is installed in three labelled passes (base workload, Clang/LLVM,
75   XP toolset) so a failure identifies which component group is responsible.
76 - The scripts were extracted from a native Windows project, so the component
77   selection is tuned for that: Spectre-mitigated runtimes, the v141/XP toolset,
78   and driver-kit headers. Trim the component lists in the `.ps1` if you don't
79   need them — each group is a plain array near the top.
80
81 ## The XP VM
82
83 XP is far enough back that the usual approach inverts. There is no winget, no
84 PowerShell, no `where.exe`, no `setx.exe` and no `curl` — and XP's SChannel tops
85 out at TLS 1.0, so the VM cannot fetch anything from python.org, sourceforge or
86 github over HTTPS. `setup-windows-xp.bat` therefore **downloads nothing**. Run
87 it with nothing staged and it prints exactly which files to fetch on the host
88 and where to drop them (`vendor-xp/`, gitignored), then stops.
89
90 Run it from your normal account first. It finds that it is not an
91 administrator, copies itself and the payload to `C:\xp-setup` — a share mounted
92 under your account is invisible to the Administrator account, which is the whole
93 reason for the copy — and prints the `runas` line to use, including the `--user`
94 flag that tells the elevated run which account you will actually SSH in as.
95 `--help` prints the full option list.
96
97 - **SSH server.** OpenSSH for Windows 3.8.1p1-1, the 2004 `sshwindows` build:
98   one unattended installer, a real service, authentication against local
99   accounts, no runtime and no network. Its crypto is of its era, so the script
100   finishes by printing the `ssh` flags and the matching `~/.ssh/config` block a
101   current client needs (`diffie-hellman-group1-sha1`, `ssh-rsa`, `aes128-cbc`).
102   Bitvise 6.x and Cygwin 2.5.2 from the Cygwin Time Machine are the two
103   modern-crypto alternatives, both noted in the script's comments.
104
105   **Unresolved.** The 3.8.1p1 *binary* is no longer in the SourceForge file
106   release — that folder now holds only the NSIS installer source. The one
107   binary still published under the project is 3.7.1p1 from October 2003, which
108   sits on the wrong side of that autumn's OpenSSH buffer-management advisories.
109   So the payload manifest asks for a file that cannot currently be fetched. The
110   backend is under review, and Cygwin is the likely replacement: it is served
111   over plain HTTP, so XP's TLS ceiling does not apply, and its unattended
112   installer can be driven from the host through `VBoxManage guestcontrol`.
113 - **The two policies that break SSH on XP.** `sshd` authenticates with a network
114   logon, and two XP defaults sabotage exactly that: `forceguest=1` collapses
115   every network logon to Guest (the default in a workgroup, which a VM always
116   is), and `limitblankpassworduse=1` blocks accounts with an empty password. The
117   script switches the first to Classic — `--keep-forceguest` opts out, and it
118   prints the line to revert — and only reports the second, since the fix there is
119   to give the account a password rather than weaken the policy.
120 - **Python.** 3.4.4 is the last CPython that supports XP; 3.5 raised the floor to
121   Vista. `--python27` adds 2.7.18 alongside it. The 3.4 MSI has no "add to PATH"
122   option, so the script edits the machine `PATH` in the registry and restarts
123   `sshd`, which would otherwise hand SSH sessions the pre-Python environment.
124   Bootstrapping `pip` prefers a staged `get-pip.py` (pip 19.1.1, the last release
125   supporting 3.4) over `ensurepip` (pip 6, which today's PyPI turns away).
126   Installing from PyPI later is its own problem — expect to stage wheels on the
127   host and use `pip install --no-index --find-links`.
128 - Batch on XP is unforgiving about what can go in a message string: no `!`, no
129   `<` or `>`, and no parentheses. The `:say` helper documents each one, all found
130   the hard way.