fix(migration): generate NM wifi keyfiles in Python pre-reboot with correct SSID encoding#521
fix(migration): generate NM wifi keyfiles in Python pre-reboot with correct SSID encoding#521mrosseel wants to merge 3 commits into
Conversation
…orrect SSID encoding
…ration code lives on main, one implementation (brickbots#521)
…on only and lives on main (brickbots#521)
…back rotation and verifies nothing
|
Added a second fix to the bundle: |
|
Third fix, from a live 2GB-board migration attempt: the initramfs mounts /tmp with the tmpfs default cap (50% of RAM), so copying a 1GB tarball to RAM failed on a 2GB board even though total RAM sufficed — and the failure stranded the device in a console-only debug shell. Now: (1) tmpfs cap raised to 90% (the explicit MemAvailable checks remain the guard); (2) a pre-reboot feasibility gate in nixos_migration.sh fails on the running OS, never in the initramfs; (3) any initramfs failure before formatting restores the old OS's boot config and reboots back instead of dropping to a shell. |
|
Scope restored: this PR is the wifi keyfile fix (+ the Attic key one-liner). The RAM/stranding fixes moved to their own PR: #523. |
…wner-1000 files (pre-stage runs as the app user)
Fixes the bug that leaves every migrated device unable to join its wifi network, by replacing the busybox-shell keyfile converter with a unit-tested Python generator that runs on Debian before reboot; the initramfs just copies the pre-staged keyfiles.
The bug
The shell converter wrote SSIDs into NetworkManager keyfiles as hex byte lists (
ssid=61;70;6f;…), but NM's keyfile format only parses decimal — the garbage was stored as a literal-string SSID, so the device scanned for a network literally named61;70;6f;6c;6c;6f;("apollo"). Diagnosed on real hardware (profiles repaired in place withnmcli). Corollary: an SSID whose hex pairs were all decimal digits ("0x20") parsed "successfully" into different garbage — a phantomNnetwork.The fix
PiFinder/nixos_migration_wifi.py: parses wpa_supplicant.conf and emits NM keyfiles with decimal byte lists; also decodes wpa_supplicant's unquoted-hex SSID form (how SSIDs with special characters are stored) with non-UTF-8 bytes round-tripping via surrogateescape; hex PSKs kept verbatim; filenames sanitised.nixos_migration.shpre-stages the keyfiles into the initramfs;nixos_migration_init.shdrops its shell converter and just copies them (pre-existing NM keyfiles on the Debian side still preserved as-is).Generating on full Debian instead of in busybox after the rootfs is staged is what makes this testable — the class of bug being fixed is exactly the kind that untested initramfs shell accumulates.
🤖 Generated with Claude Code