Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSLGd: allow alternate rdp file via .wslgconfig #832

Merged
merged 1 commit into from
Sep 21, 2022
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 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