microsoft / microsoft/WSL

Global DefaultUid value (Lxss, for all distros)

Open
#10,631 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

**Is your feature request related to a problem? Please describe.**
Currently, AFAIK the Windows registry key `DefaultUid` can only be set for a specific distro, like `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\{xxxx-xxx-xxx}`.

**Describe the solution you'd like**
I think that could be a global value, set directly under `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss` and used when nothing is set explicitly for a specific distro. Of course, some mechanism would have to be implemented to fall back to UID 0 if a given distro doesn't have the value of `Lxss/DefaultUid` (e.g., no entry within `/etc/passwd`).

**Describe alternatives you've considered**
None. Well, I tried setting the value in `Lxss` directly to no avail.

**Additional context**
I'm currently in the process of managing WSL2 and distros via SCCM (and probably Intune in the future) at my company. It would really be nice to have a global setting for `DefaultUid` because in a company environment, I want these kinds of things be set the same for all distros so I can manage them better and reduce user experience edge cases. The workaround that I'm currently following is (via PowerShell):
1. Iterate over `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss` and find the UUID of the distro which has `DistributionName` set to what was installed using SCCM
2. Set `HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\\DefaultUid` to the UID I setup in my WSL image.

This could be reduced to 1 simple step without all this iterating, and also reduce code and therefore errors when writing PowerShell as a bonus.

**Output of wsl --version**
```
WSL-Version: 1.2.5.0
Kernelversion: 5.15.90.1
WSLg-Version: 1.0.51
MSRDC-Version: 1.2.3770
Direct3D-Version: 1.608.2-61064218
DXCore-Version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows-Version: 10.0.19045.3570
```

Be aware that this is my private PC, at work we use Windows 10 Enterprise which might have a different Windows version number, but it's Windows 10 either way. This issue however applies to both Windows 10 and 11 I think.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source file, test, or entry point. Start by tracing how WSL reads per-distro Lxss\\\\DefaultUid during distro startup; verify precedence for a global Lxss\\DefaultUid and the UID 0 fallback, then add coverage for global, per-distro, and missing-value cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.