File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed
Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -2618,17 +2618,20 @@ void PostProcessImportedDistribution(wsl::shared::MessageWriter<LX_MINI_INIT_IMP
26182618 THROW_LAST_ERROR_IF (chdir (ExtractedPath) < 0 );
26192619 THROW_LAST_ERROR_IF (chroot (" ." ) < 0 );
26202620
2621+ Message->ValidDistribution = false ;
2622+
26212623 for (auto * path : {" /etc" , " /bin/sh" })
26222624 {
2623- if (access (path, F_OK) < 0 )
2625+ if (access (path, F_OK) >= 0 )
26242626 {
2625- LOG_ERROR (" Failed to access {} {}" , path, errno);
2626- Message->ValidDistribution = false ;
2627- return ;
2627+ Message->ValidDistribution = true ;
26282628 }
26292629 }
26302630
2631- Message->ValidDistribution = true ;
2631+ if (!Message->ValidDistribution )
2632+ {
2633+ return ;
2634+ }
26322635
26332636 auto [flavor, version] = UtilReadFlavorAndVersion (" /etc/os-release" );
26342637
Original file line number Diff line number Diff line change @@ -5854,6 +5854,19 @@ Error code: Wsl/InstallDistro/WSL_E_INVALID_JSON\r\n",
58545854 // TODO: Uncomment once SetVersionDebug is removed from the tests .wslconfig.
58555855 // VERIFY_ARE_EQUAL(err, L"");
58565856 }
5857+
5858+ // Validate that tars containing /etc, but not /bin/sh are accepted.
5859+ if (LxsstuVmMode ())
5860+ {
5861+ auto cleanup = wil::scope_exit_log (WI_DIAGNOSTICS_INFO, []() { LxsstuLaunchWsl (L" --unregister empty-distro" ); });
5862+
5863+ DistroFileChange conf (L" /etc/wsl.conf" , false );
5864+ conf.SetContent (L" " );
5865+
5866+ auto [out, err] = LxsstuLaunchWslAndCaptureOutput (
5867+ L" tar cf - /etc/wsl.conf | wsl.exe --install --from-file - --name empty-distro --no-launch "
5868+ L" --version 2" );
5869+ }
58575870 }
58585871
58595872 TEST_METHOD (ImportExportStdout)
You can’t perform that action at this time.
0 commit comments