Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions distributions/validate-modern.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
'tmp.mount',
'NetworkManager.service',
'NetworkManager-wait-online.service',
'console-getty.service',
'networking.service',
'hypervkvpd.service']

Expand Down
4 changes: 4 additions & 0 deletions src/linux/init/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ int GenerateSystemdUnits(int Argc, char** Argv)
// Mask NetworkManager-wait-online.service for the same reason, as it causes timeouts on distros using NetworkManager.
THROW_LAST_ERROR_IF(symlink("/dev/null", std::format("{}/NetworkManager-wait-online.service", installPath).c_str()) < 0);

// Mask console-getty.service since /dev/tty devices are shared at the VM level across all distros.
// When multiple distros are running, the second distro's getty fails because the tty is already held.
THROW_LAST_ERROR_IF(symlink("/dev/null", std::format("{}/console-getty.service", installPath).c_str()) < 0);

// Only create the wslg unit if both enabled in wsl.conf, and if the wslg folder actually exists.
if (enableGuiApps && access("/mnt/wslg/runtime-dir", F_OK) == 0)
{
Expand Down
16 changes: 9 additions & 7 deletions test/windows/UnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,18 @@ class UnitTests
VERIFY_IS_TRUE(IsSystemdRunning(L"--system"));

// Validate that systemd-networkd-wait-online.service is masked.
auto [out, _] =
LxsstuLaunchWslAndCaptureOutput(L"systemctl status systemd-networkd-wait-online.service | grep -iF Loaded:");

VERIFY_ARE_EQUAL(out, L" Loaded: masked (Reason: Unit systemd-networkd-wait-online.service is masked.)\n");
std::wstring out;
std::wstring err;
std::tie(out, err) = LxsstuLaunchWslAndCaptureOutput(L"systemctl show -p LoadState systemd-networkd-wait-online.service");
VERIFY_ARE_EQUAL(out, L"LoadState=masked\n");

// Validate that NetworkManager-wait-online.service is masked.
auto [outNm, __] =
LxsstuLaunchWslAndCaptureOutput(L"systemctl status NetworkManager-wait-online.service | grep -iF Loaded:");
std::tie(out, err) = LxsstuLaunchWslAndCaptureOutput(L"systemctl show -p LoadState NetworkManager-wait-online.service");
VERIFY_ARE_EQUAL(out, L"LoadState=masked\n");

VERIFY_ARE_EQUAL(outNm, L" Loaded: masked (Reason: Unit NetworkManager-wait-online.service is masked.)\n");
// Validate that console-getty.service is masked (tty devices are shared at VM level across distros).
std::tie(out, err) = LxsstuLaunchWslAndCaptureOutput(L"systemctl show -p LoadState console-getty.service");
VERIFY_ARE_EQUAL(out, L"LoadState=masked\n");
}

TEST_METHOD(SystemdUser)
Expand Down
Loading