Case-fold the Windows username before sanitization
| Affects | Status | Importance | Assigned to | Milestone | ||
|---|---|---|---|---|---|---|
| wsl-setup (Ubuntu) | Status tracked in Resolute | |||||
| Resolute |
Fix Released
|
High
|
Unassigned | |||
Bug Description
The `wsl-setup` script reads the Windows user name and sanitizes it,
dropping invalid characters for a Linux user name, including ASCII upper
case letters. We could case fold the username first and then drop the
invalid ones, making it a bit less surprising. That would still have
some nasty cases we cannot handle in a smart way, like `MartínJoão` being
converted into `martnjoo` but that’s why we prompt for the username, to
let users edit that before actual submission.
While case folding can be done with `tr "[:upper:]" "[:lower:]"` or even
better `awk '{print tolower(0)}'` (awk handles Unicode better), better yet
is to leverage PowerShell because then we're guaranteed to respect the
Windows user locale (a WSL instance could be set up with a different
locale and the case-folding results couldn't match the user's
expectation).
To illustrate how this works:
```bash
j@DESKTOP-
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
j@DESKTOP-
João
j@DESKTOP-
[Console]
$Env:'"${var}"'}'
João
j@DESKTOP-
[Console]
$Env:'"${var}"'}'
joão
```
In the example above the username would be sanitized to: `oo`
but with the changes it would at least be: `joo`
(the 'ã' is still dropped, but it's much easier to add it).
The motivation for this change came from a user named `AdminUser`.
That would originally be sanitized to: `dminser`
but now it becomes: `adminuser`
One must remember that in the end this name is just a suggestion
prefilling a read input. User is free to edit it before hitting enter
and submitting the username to the `adduser` program.
Related branches
- Nick Rosbrook (community): Approve
- git-ubuntu import: Pending requested
-
Diff: 1517 lines (+1226/-100)20 files modified.github/actions/get-wsl-image/action.yaml (+118/-0)
.github/actions/validate-wsl/action.yaml (+113/-0)
.github/dependabot.yaml (+18/-0)
.github/workflows/integration.yaml (+328/-0)
.github/workflows/shellcheck.yaml (+27/-0)
.shellcheckrc (+1/-0)
CONTRIBUTING.md (+102/-0)
SECURITY.md (+53/-0)
debian/changelog (+12/-0)
debian/control (+1/-0)
debian/install (+2/-1)
debian/rules (+0/-1)
dev/null (+0/-7)
test/basic-assertions.sh (+30/-0)
test/e2e/setup.expect (+113/-0)
test/systemd-assertions.sh (+33/-0)
test/ubuntu-insights-assertions.sh (+33/-0)
ubuntu-insights.sh (+143/-0)
wait-for-cloud-init (+2/-2)
wsl-setup (+97/-89)
| description: | updated |
| description: | updated |
| summary: |
- [FFe] Case-fold the Windows username before sanitization + Case-fold the Windows username before sanitization |
| description: | updated |
| Changed in wsl-setup (Ubuntu): | |
| status: | Expired → New |
| Changed in wsl-setup (Ubuntu Resolute): | |
| importance: | Undecided → High |

Can you please attach a debdiff of the proposed change, or point to a MR against a git-ubuntu branch? Thanks!