@@ -89,7 +89,7 @@ class PluginTests
8989 return true ;
9090 }
9191
92- void ConfigurePlugin (PluginTestType testCase, LPCWSTR mountFolder = L" " ) const
92+ void ConfigurePlugin (PluginTestType testCase) const
9393 {
9494 StopWslService ();
9595 if (!DeleteFile (logFile.c_str ()))
@@ -100,7 +100,6 @@ class PluginTests
100100 const auto testKey = OpenTestRegistryKey (KEY_SET_VALUE );
101101 WriteDword (testKey.get (), nullptr , c_testType, static_cast <DWORD >(testCase));
102102 WriteString (testKey.get (), nullptr , c_logFile, logFile.c_str ());
103- WriteString (testKey.get (), nullptr , c_mountFolder, mountFolder);
104103
105104 const auto lxssKey =
106105 CreateKey (HKEY_LOCAL_MACHINE , L" SOFTWARE\\ Microsoft\\ Windows\\ CurrentVersion\\ Lxss\\ Plugins" , KEY_SET_VALUE , nullptr , 0 );
@@ -173,62 +172,6 @@ class PluginTests
173172 ValidateLogFile (ExpectedOutput);
174173 }
175174
176- WSL2_TEST_METHOD (MountFolderAccess)
177- {
178- const auto testFolder = std::filesystem::current_path () / " deny-write" ;
179- VERIFY_IS_TRUE (std::filesystem::create_directory (testFolder));
180-
181- auto cleanup = wil::scope_exit_log (WI_DIAGNOSTICS_INFO , [&]() { std::filesystem::remove_all (testFolder); });
182-
183- const auto user = wil::get_token_information<TOKEN_USER >();
184- EXPLICIT_ACCESSW access{};
185- access.grfAccessPermissions = FILE_ADD_FILE ;
186- access.grfAccessMode = DENY_ACCESS ;
187- access.grfInheritance = NO_INHERITANCE ;
188- access.Trustee .TrusteeForm = TRUSTEE_IS_SID ;
189- access.Trustee .ptstrName = static_cast <LPWSTR >(user->User .Sid );
190-
191- PACL acl = nullptr ;
192- wil::unique_hlocal descriptor;
193- THROW_IF_WIN32_ERROR (GetNamedSecurityInfoW (
194- testFolder.c_str (), SE_FILE_OBJECT , DACL_SECURITY_INFORMATION , nullptr , nullptr , &acl, nullptr , &descriptor));
195-
196- wsl::windows::common::security::unique_acl newAcl;
197- THROW_IF_WIN32_ERROR (SetEntriesInAclW (1 , &access, acl, &newAcl));
198- THROW_IF_WIN32_ERROR (SetNamedSecurityInfoW (
199- const_cast <LPWSTR >(testFolder.c_str ()), SE_FILE_OBJECT , DACL_SECURITY_INFORMATION , nullptr , nullptr , newAcl.get (), nullptr ));
200-
201- const auto testFile = testFolder / L" plugin-test.txt" ;
202- wil::unique_hfile deniedFile{CreateFileW (testFile.c_str (), GENERIC_WRITE , 0 , nullptr , CREATE_NEW , FILE_ATTRIBUTE_NORMAL , nullptr )};
203- VERIFY_IS_TRUE (!deniedFile);
204- VERIFY_ARE_EQUAL (GetLastError (), ERROR_ACCESS_DENIED );
205-
206- auto resetAcl = wil::scope_exit_log (WI_DIAGNOSTICS_INFO , [&]() {
207- wsl::windows::common::security::unique_acl restoredAcl;
208- access.grfAccessPermissions = 0 ;
209- access.grfAccessMode = REVOKE_ACCESS ;
210-
211- THROW_IF_WIN32_ERROR (SetEntriesInAclW (1 , &access, acl, &restoredAcl));
212-
213- THROW_IF_WIN32_ERROR (SetNamedSecurityInfoW (
214- const_cast <LPWSTR >(testFolder.c_str ()), SE_FILE_OBJECT , DACL_SECURITY_INFORMATION , nullptr , nullptr , restoredAcl.get (), nullptr ));
215- });
216-
217- ConfigurePlugin (PluginTestType::MountFolderAccess, testFolder.c_str ());
218-
219- constexpr auto ExpectedOutput =
220- LR"( Plugin loaded. TestMode=25
221- VM created (settings->CustomConfigurationFlags=0)
222- /bin/sh: line 1: /test-plugin-access/plugin-test.txt: Permission denied
223- Distribution started, name=test_distro, package=, PidNs=*, InitPid=*, Flavor=debian, Version=13
224- Distribution Stopping, name=test_distro, package=, PidNs=*, Flavor=debian, Version=13
225- VM Stopping)" ;
226-
227- StartWsl (0 );
228- VERIFY_IS_FALSE (std::filesystem::exists (testFile));
229- ValidateLogFile (ExpectedOutput);
230- }
231-
232175 WSL2_TEST_METHOD (CustomKernelOverriddenByPolicy)
233176 {
234177 RegistryKeyChange policy (
0 commit comments