Skip to content

Commit

Permalink
WSLg: allow alternate rdp file via .wslgconfig (#832)
Browse files Browse the repository at this point in the history
Co-authored-by: Hideyuki Nagase <hideyukn@ntdev.microsoft.com>
  • Loading branch information
hideyukn88 and Hideyuki Nagase authored Sep 21, 2022
1 parent 0c544da commit 690c91c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions Microsoft.WSLg.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<file src="package/WSLDVCPlugin_ARM64.pdb" target="build/native/bin/arm64/WSLDVCPlugin.pdb" />

<file src="package/wslg.rdp" target="build/native/bin/wslg.rdp" />
<file src="package/wslg_desktop.rdp" target="build/native/bin/wslg_desktop.rdp" />
</files>
</package>
4 changes: 4 additions & 0 deletions Microsoft.WSLg.targets
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<Link>wslg.rdp</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)native\bin\wslg_desktop.rdp">
<Link>wslg_desktop.rdp</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
18 changes: 17 additions & 1 deletion WSLGd/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ constexpr auto c_mstscFullPath = "/mnt/c/Windows/System32/mstsc.exe";
constexpr auto c_westonShellOverrideEnv = "WSL2_WESTON_SHELL_OVERRIDE";
constexpr auto c_westonRdprailShell = "rdprail-shell";

constexpr auto c_rdpFileOverrideEnv = "WSL2_RDP_CONFIG_OVERRIDE";
constexpr auto c_rdpFile = "wslg.rdp";

void LogException(const char *message, const char *exceptionDescription) noexcept
{
fprintf(stderr, "<3>WSLGd: %s %s", message ? message : "Exception:", exceptionDescription);
Expand Down Expand Up @@ -446,7 +449,20 @@ try {
else
wslDvcPlugin = "/plugin:WSLDVC";

std::string rdpFilePath = wslInstallPath + "\\wslg.rdp";
std::filesystem::path rdpFilePath(wslInstallPath);
auto rdpFile = getenv(c_rdpFileOverrideEnv);
if (rdpFile) {
if (strstr(rdpFile, "..\\")) {
LOG_ERROR("RDP file must be placed under WSL install path (%s)", rdpFile);
rdpFile = nullptr;
}
}
if (rdpFile) {
rdpFilePath /= rdpFile;
} else {
rdpFilePath /= c_rdpFile;
}

monitor.LaunchProcess(std::vector<std::string>{
std::move(rdpClientExePath),
std::move(remote),
Expand Down
5 changes: 5 additions & 0 deletions package/wslg_desktop.rdp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
audiocapturemode:i:2
authentication level:i:0
disableconnectionsharing:i:1
enablecredsspsupport:i:0
hvsocketenabled:i:1

0 comments on commit 690c91c

Please sign in to comment.