diff --git a/DistroLauncher/DistributionInfo.cpp b/DistroLauncher/DistributionInfo.cpp index 4742f59f..4a838f6b 100644 --- a/DistroLauncher/DistributionInfo.cpp +++ b/DistroLauncher/DistributionInfo.cpp @@ -9,13 +9,22 @@ bool DistributionInfo::CreateUser(std::wstring_view userName) { // Create the user account. DWORD exitCode; - std::wstring commandLine = L"/usr/sbin/adduser --quiet --gecos '' "; + std::wstring commandLine = L"useradd -m -s $SHELL "; commandLine += userName; + commandLine = L"/bin/sh -c \"" + commandLine + L'"'; HRESULT hr = g_wslApi.WslLaunchInteractive(commandLine.c_str(), true, &exitCode); if ((FAILED(hr)) || (exitCode != 0)) { return false; } + // Input password. + commandLine = L"/usr/bin/passwd "; + commandLine += userName; + hr = g_wslApi.WslLaunchInteractive(commandLine.c_str(), true, &exitCode); + if ((FAILED(hr)) || (exitCode != 0)) { + return false; + } + // Add the user account to any relevant groups. commandLine = L"/usr/sbin/usermod -aG adm,cdrom,sudo,dip,plugdev "; commandLine += userName;