** Description changed:
- [Impact]
+ [ Impact ]
- 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.
+ * During the first boot of a WSL instance, 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).
+ * The patch herein proposed works by requesting PowerShell to print
`$Env:UserName.ToLower()`
+ instead of just `$Env:UserName` as currently implemented.
- To illustrate how this works:
+ * The gap has been already reported by some users in wrong channels,
+ such as: https://github.com/microsoft/WSL/issues/13576
- ```bash
- j@DESKTOP-551PQ9O:~$ lsb_release -a
- No LSB modules are available.
- Distributor ID: Ubuntu
- Description: Ubuntu 20.04.6 LTS
- Release: 20.04
- Codename: focal
- j@DESKTOP-551PQ9O:~$ powershell.exe -Command '$Env:Username'
- João
+ [ Test Plan ]
- j@DESKTOP-551PQ9O:~$ var="Username"; powershell.exe -NoProfile -Command '& {
- [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
- $Env:'"${var}"'}'
- João
+ * Have a Windows user named with mixed casing, like "AdminUser".
- j@DESKTOP-551PQ9O:~$ var="Username.ToLower()"; powershell.exe -NoProfile
-Command '& {
- [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
- $Env:'"${var}"'}'
- joão
+ * Make sure you don't have any cloud-init data at
`%USERPROFILE%\.cloud-init` that could alter the
+ behaviour of the new instance during first boot.
- ```
+ 1. Register a WSL instance of Noble but do not launch it yet:
+ `wsl --install -d Ubuntu-24.04 --no-launch`
- 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).
+ 2. Install wsl-setup from proposed:
+ `wsl -d Ubuntu-24.04 -- vim /etc/apt/sources.list.d/ ... `
+ `wsl -d Ubuntu-24.04 -- apt update`
+ `wsl -d Ubuntu-24.04 -- apt install -t noble-proposed wsl-setup`
+
+ 3. Launch the new instance.
+ `wsl -d Ubuntu-24.04`
+
+ Observe that it will prompt for a new Linux user name, but will present a
suggestion derived from
+ the Windows user name.
+ Before this patch the suggestion for "AdminUser" would be "dminser".
+ With this patch the suggestion would be "adminuser".
+
+ [ Where problems could occur ]
+
+ * wsl-setup is automatically invoked by the WSL platform during first boot
of a new instance.
+ Errors in this script can result in a malfunctioning instance and maybe
even prevent it from ever
+ boot up.
+ * No other Ubuntu product is affected by this package.
+
+
+ [ Other Info ]
+
+ * The fix herein proposed is already present in Resolute.
+ * We're skipping Plucky due EOL.
+ * We don't publicize interim releases for WSL, but since users can always
do-release-upgrade, we
+ include Questing in this SRU.
** Also affects: wsl-setup (Ubuntu Noble)
Importance: Undecided
Status: New
** Also affects: wsl-setup (Ubuntu Questing)
Importance: Undecided
Status: New
** Changed in: wsl-setup (Ubuntu)
Status: New => Fix Released
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2138661
Title:
[SRU] Case-fold the Windows username before sanitization
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/wsl-setup/+bug/2138661/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs