WSL-DistroLauncher
WSL-DistroLauncher copied to clipboard
When the default user is defined, the wsl.conf is updated accordingly
- The
[user]section may not be available inwsl.confin older Windows 10 versions. A Windows version check may be useful? CreateProcessreturn value is not checked.RunProcesscan be a static function here.WslApiLoader::WslLaunchmay be used instead ofRunProcesswrapper.
Hello @Biswa96,
Thank you for your comments. My answers:
- The [user] section may not be available in wsl.conf in older Windows 10 versions. A Windows version check may be useful? Yes I will include that
- CreateProcess return value is not checked. Yes, because I think that this can be ignored. But help me think, what should happen if it fails, show a warning to the user? Maybe
- RunProcess can be a static function here. Ok
- WslApiLoader::WslLaunch may be used instead of RunProcess wrapper. Ok, I didn't use it, and it was my first option but it runs the distro with the default user. The first time it is ok because the default one is root. But the second time it is a limited user that won't be able to modify wsl.conf. I could add a sudoers exception but I think it is too intrusive.
@Biswa96 I made a code clean up to the PR; please check it. I figure that I addressed all your concerns.
It won't hurt to have [user] not available in older versions; WSL won't use it in older ones. But when the user upgrades Windows, it will be already there configured.
Regards, Carlos