Skip to content

Commit d060939

Browse files
benhillisBen Hillis
andauthored
[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>
1 parent 1e3ef15 commit d060939

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/linux/init/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ try
690690
}
691691

692692
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));
694694
}
695695

696696
//

test/windows/UnitTests.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,17 +268,24 @@ class UnitTests
268268
{
269269
validateUserSession();
270270

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));
272272
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));
273277
}
274278

275279
// Validate user sessions state with gui apps enabled.
276280
{
277281
WslConfigChange config(LxssGenerateTestConfig({.guiApplications = true}));
278282

279283
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));
281285
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));
282289
}
283290

284291
// Create a 'broken' /run/user and validate that the warning is correctly displayed.

0 commit comments

Comments
 (0)