Skip to content

Commit

Permalink
Don't generate WSL distributions for docker-desktop* (#4156)
Browse files Browse the repository at this point in the history
These utility distributions are used by Docker for Windows' WSL2
integration. They are not intended for user consumption.

* [x] Closes #3556
* [x] CLA signed.
* [x] Tests added/passed
* [x] Requires documentation to be updated
* [x] I've discussed this with core contributors already.

There is a minimal chance that a user _has_ a distribution named `docker-desktop` or some superstring thereof, but this is taken as an acceptable level of risk.
  • Loading branch information
DHowett authored and msftbot[bot] committed Jan 9, 2020
1 parent 988f0a6 commit 8a21698
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cascadia/TerminalApp/WslDistroGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <fcntl.h>
#include "DefaultProfileUtils.h"

static constexpr std::wstring_view DockerDistributionPrefix{ L"docker-desktop" };

using namespace ::TerminalApp;

// Legacy GUIDs:
Expand Down Expand Up @@ -106,6 +108,14 @@ std::vector<TerminalApp::Profile> WslDistroGenerator::GenerateProfiles()
{
std::wstring distName;
std::getline(wlinestream, distName, L'\r');

if (distName.substr(0, std::min(distName.size(), DockerDistributionPrefix.size())) == DockerDistributionPrefix)
{
// Docker for Windows creates some utility distributions to handle Docker commands.
// Pursuant to GH#3556, because they are _not_ user-facing we want to hide them.
continue;
}

size_t firstChar = distName.find_first_of(L"( ");
// Some localizations don't have a space between the name and "(Default)"
// https://github.com/microsoft/terminal/issues/1168#issuecomment-500187109
Expand Down

0 comments on commit 8a21698

Please sign in to comment.