Skip to content

Commit 90ba76b

Browse files
author
Pooja Trivedi
committed
Container Manager initial draft
1 parent 45b5569 commit 90ba76b

File tree

14 files changed

+698
-49
lines changed

14 files changed

+698
-49
lines changed

msipackage/package.wix.in

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,13 @@
263263
<RegistryValue Name="AppId" Value="{E9B79997-57E3-4201-AECC-6A464E530DD2}" Type="string" />
264264
<RegistryValue Value="WSLAVirtualMachine" Type="string" />
265265
</RegistryKey>
266-
266+
267+
<!-- WSLASession -->
268+
<RegistryKey Root="HKCR" Key="CLSID\{4877FEFC-4977-4929-A958-9F36AA1892A4}">
269+
<RegistryValue Name="AppId" Value="{E9B79997-57E3-4201-AECC-6A464E530DD2}" Type="string" />
270+
<RegistryValue Value="WSLASession" Type="string" />
271+
</RegistryKey>
272+
267273
<!-- IWSLAUserSession-->
268274
<RegistryKey Root="HKCR" Key="Interface\{82A7ABC8-6B50-43FC-AB96-15FBBE7E8760}">
269275
<RegistryValue Value="IWSLAUserSession" Type="string" />
@@ -288,7 +294,14 @@
288294
</RegistryKey>
289295
</RegistryKey>
290296

291-
297+
<!-- IWSLASession-->
298+
<RegistryKey Root="HKCR" Key="Interface\{EF0661E4-6364-40EA-B433-E2FDF11F3519}">
299+
<RegistryValue Value="IWSLASession" Type="string" />
300+
<RegistryKey Key="ProxyStubClsid32">
301+
<RegistryValue Value="{4EA0C6DD-E9FF-48E7-994E-13A31D10DC61}" Type="string" />
302+
</RegistryKey>
303+
</RegistryKey>
304+
292305
<File Id="wslaservice.exe" Source="${BIN}/wslaservice.exe" KeyPath="yes" />
293306
<File Id="wslaserviceproxystub.dll" Name="wslaserviceproxystub.dll" Source="${BIN}/wslaserviceproxystub.dll" />
294307

src/windows/common/WslSecurity.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ wil::unique_handle wsl::windows::common::security::CreateRestrictedToken(_In_ HA
9999
return restrictedToken;
100100
}
101101

102+
void wsl::windows::common::security::ConfigureForCOMImpersonation(IUnknown* Instance)
103+
{
104+
wil::com_ptr_nothrow<IClientSecurity> clientSecurity;
105+
THROW_IF_FAILED(Instance->QueryInterface(IID_PPV_ARGS(&clientSecurity)));
106+
107+
// Get the current proxy blanket settings.
108+
DWORD authnSvc, authzSvc, authnLvl, capabilites;
109+
THROW_IF_FAILED(clientSecurity->QueryBlanket(Instance, &authnSvc, &authzSvc, NULL, &authnLvl, NULL, NULL, &capabilites));
110+
111+
// Make sure that dynamic cloaking is used.
112+
WI_ClearFlag(capabilites, EOAC_STATIC_CLOAKING);
113+
WI_SetFlag(capabilites, EOAC_DYNAMIC_CLOAKING);
114+
THROW_IF_FAILED(clientSecurity->SetBlanket(Instance, authnSvc, authzSvc, NULL, authnLvl, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, capabilites));
115+
}
116+
102117
LUID wsl::windows::common::security::EnableTokenPrivilege(_Inout_ HANDLE token, _In_ LPCWSTR privilegeName)
103118
{
104119
// Convert privilege name to an LUID.

src/windows/common/WslSecurity.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ std::pair<PSID, std::vector<char>> CreateSid(SID_IDENTIFIER_AUTHORITY Authority,
8787
/// </summary>
8888
wil::unique_handle CreateRestrictedToken(_In_ HANDLE token);
8989

90+
/// <summary>
91+
/// Configures a COM object for impersonation.
92+
/// <summary>
93+
void ConfigureForCOMImpersonation(IUnknown* instance);
94+
9095
/// <summary>
9196
/// Enables a privilege on the token.
9297
/// </summary>

src/windows/wslaclient/DllMain.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Module Name:
1818
#include "wslrelay.h"
1919
#include "wslInstall.h"
2020

21-
namespace {
21+
/* namespace {
2222
2323
void ConfigureComSecurity(IUnknown* Instance)
2424
{
@@ -34,7 +34,7 @@ void ConfigureComSecurity(IUnknown* Instance)
3434
WI_SetFlag(capabilites, EOAC_DYNAMIC_CLOAKING);
3535
THROW_IF_FAILED(clientSecurity->SetBlanket(Instance, authnSvc, authzSvc, NULL, authnLvl, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, capabilites));
3636
}
37-
} // namespace
37+
} // namespace */
3838

3939
class DECLSPEC_UUID("7BC4E198-6531-4FA6-ADE2-5EF3D2A04DFF") CallbackInstance
4040
: public Microsoft::WRL::RuntimeClass<Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, ITerminationCallback, IFastRundown>
@@ -74,9 +74,10 @@ try
7474
wil::com_ptr<IWSLAUserSession> session;
7575

7676
THROW_IF_FAILED(CoCreateInstance(__uuidof(WSLAUserSession), nullptr, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&session)));
77-
ConfigureComSecurity(session.get());
77+
// ConfigureComSecurity(session.get());
78+
wsl::windows::common::security::ConfigureForCOMImpersonation(session.get());
7879

79-
wil::com_ptr<IWSLAVirtualMachine> virtualMachineInstance;
80+
/* wil::com_ptr<IWSLAVirtualMachine> virtualMachineInstance;
8081
8182
VIRTUAL_MACHINE_SETTINGS settings{};
8283
settings.DisplayName = UserSettings->DisplayName;
@@ -91,7 +92,8 @@ try
9192
settings.EnableGPU = UserSettings->GPU.Enable;
9293
9394
THROW_IF_FAILED(session->CreateVirtualMachine(&settings, &virtualMachineInstance));
94-
ConfigureComSecurity(virtualMachineInstance.get());
95+
// ConfigureComSecurity(virtualMachineInstance.get());
96+
wsl::windows::common::security::ConfigureForCOMImpersonation(virtualMachineInstance.get());
9597
9698
// Register termination callback, if specified
9799
if (UserSettings->Options.TerminationCallback != nullptr)
@@ -104,7 +106,7 @@ try
104106
// Callback instance is now owned by the service.
105107
}
106108
107-
*reinterpret_cast<IWSLAVirtualMachine**>(VirtualMachine) = virtualMachineInstance.detach();
109+
*reinterpret_cast<IWSLAVirtualMachine**>(VirtualMachine) = virtualMachineInstance.detach();*/
108110
return S_OK;
109111
}
110112
CATCH_RETURN();

src/windows/wslaservice/exe/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ set(SOURCES
22
application.manifest
33
main.rc
44
ServiceMain.cpp
5+
WSLASession.cpp
56
WSLAUserSession.cpp
67
WSLAUserSessionFactory.cpp
78
WSLAVirtualMachine.cpp
89
)
910

1011
set(HEADERS
12+
WSLASession.h
1113
WSLAUserSession.h
1214
WSLAUserSessionFactory.h
1315
WSLAVirtualMachine.h)
@@ -31,4 +33,4 @@ target_link_libraries(wslaservice
3133
Synchronization.lib)
3234

3335
target_precompile_headers(wslaservice REUSE_FROM common)
34-
set_target_properties(wslaservice PROPERTIES FOLDER windows)
36+
set_target_properties(wslaservice PROPERTIES FOLDER windows)

0 commit comments

Comments
 (0)