[GH 13837] Remove trailing slash from $XDG_RUNTIME_DIR (#13929)

* [GH 13837] Remove trailing slash from $XDG_RUNTIME_DIR * pr feedback --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com>

Ben Hillis committed Dec 16, 2025 at 18:52 UTC d0609393e441394598b7bdbe838843f3c9bbdfdc
2 files changed +10 -3
src/linux/init/init.cpp
+1 -1
@@ -690,7 +690,7 @@ try
690 }
691
692 Common->Environment.AddVariable("DBUS_SESSION_BUS_ADDRESS", std::format("unix:path=/run/user/{}/bus", PasswordEntry->pw_uid));
693 - Common->Environment.AddVariable(XDG_RUNTIME_DIR_ENV, std::format("/run/user/{}/", PasswordEntry->pw_uid));
693 + Common->Environment.AddVariable(XDG_RUNTIME_DIR_ENV, std::format("/run/user/{}", PasswordEntry->pw_uid));
694 }
695
696 //
test/windows/UnitTests.cpp
+9 -2
@@ -268,8 +268,12 @@ class UnitTests
268 {
269 validateUserSession();
270
271 - auto [out, err] = LxsstuLaunchWslAndCaptureOutput(std::format(L"echo $DISPLAY", LXSST_TEST_USERNAME));
271 + auto [out, err] = LxsstuLaunchWslAndCaptureOutput(std::format(L"--user {} echo $DISPLAY", LXSST_TEST_USERNAME));
272 VERIFY_ARE_EQUAL(out, L"\n");
273 +
274 + // N.B. The XDG_RUNTIME_DIR variable is always set by init even if gui apps are disabled.
275 + std::tie(out, err) = LxsstuLaunchWslAndCaptureOutput(std::format(L"--user {} echo $XDG_RUNTIME_DIR", LXSST_TEST_USERNAME));
276 + VERIFY_ARE_EQUAL(out, std::format(L"/run/user/{}\n", TestUid));
277 }
278
279 // Validate user sessions state with gui apps enabled.
@@ -277,8 +281,11 @@ class UnitTests
281 WslConfigChange config(LxssGenerateTestConfig({.guiApplications = true}));
282
283 validateUserSession();
280 - auto [out, err] = LxsstuLaunchWslAndCaptureOutput(std::format(L"echo $DISPLAY", LXSST_TEST_USERNAME));
284 + auto [out, err] = LxsstuLaunchWslAndCaptureOutput(std::format(L"--user {} echo $DISPLAY", LXSST_TEST_USERNAME));
285 VERIFY_ARE_EQUAL(out, L":0\n");
286 +
287 + std::tie(out, err) = LxsstuLaunchWslAndCaptureOutput(std::format(L"--user {} echo $XDG_RUNTIME_DIR", LXSST_TEST_USERNAME));
288 + VERIFY_ARE_EQUAL(out, std::format(L"/run/user/{}\n", TestUid));
289 }
290
291 // Create a 'broken' /run/user and validate that the warning is correctly displayed.