Skip to content
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
9 changes: 9 additions & 0 deletions localization/strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1935,6 +1935,15 @@ Usage:
<value>Session termination failed: '{}'</value>
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
</data>
<data name="MessageWslcDefaultSessionNotFound" xml:space="preserve">
<value>Default session not found</value>
</data>
<data name="MessageWslcOpenDefaultSessionFailed" xml:space="preserve">
<value>Failed to open default session</value>
</data>
<data name="MessageWslcTerminateDefaultSessionFailed" xml:space="preserve">
<value>Default session termination failed</value>
</data>
<data name="MessageWslcShellExited" xml:space="preserve">
<value>{} exited with: {}</value>
<comment>{FixedPlaceholder="{}"}{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
Expand Down
11 changes: 10 additions & 1 deletion src/windows/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ set(SOURCES
WslTelemetry.cpp
wslutil.cpp
install.cpp
WSLCUserSettings.cpp
)

set(HEADERS
Expand Down Expand Up @@ -130,11 +131,19 @@ set(HEADERS
WslSecurity.h
WslTelemetry.h
wslutil.h
EnumVariantMap.h
WSLCUserSettings.h
WSLCSessionDefaults.h
)

add_library(common STATIC ${SOURCES} ${HEADERS})
add_dependencies(common wslserviceidl localization wslservicemc wslinstalleridl)
add_dependencies(common wslserviceidl localization wslservicemc wslinstalleridl yaml-cpp)

target_precompile_headers(common PRIVATE precomp.h)
set_target_properties(common PROPERTIES FOLDER windows)
target_include_directories(common PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/../service/mc/${TARGET_PLATFORM}/${CMAKE_BUILD_TYPE})

# WSLCUserSettings.cpp uses yaml-cpp headers.
set_source_files_properties(WSLCUserSettings.cpp PROPERTIES
INCLUDE_DIRECTORIES "${yaml-cpp_SOURCE_DIR}/include"
COMPILE_DEFINITIONS "YAML_CPP_STATIC_DEFINE")
25 changes: 25 additions & 0 deletions src/windows/common/WSLCSessionDefaults.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*++

Copyright (c) Microsoft. All rights reserved.

Module Name:

WSLCSessionDefaults.h

Abstract:

Shared constants for WSLc session naming and storage.

--*/
#pragma once

#include <cstdint>

namespace wsl::windows::wslc {

inline constexpr const wchar_t DefaultSessionName[] = L"wslc-cli";
inline constexpr const wchar_t DefaultAdminSessionName[] = L"wslc-cli-admin";
inline constexpr const wchar_t DefaultStorageSubPath[] = L"wslc\\sessions";
inline constexpr uint32_t DefaultBootTimeoutMs = 30000;

} // namespace wsl::windows::wslc
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ Copyright (c) Microsoft. All rights reserved.

Module Name:

UserSettings.cpp
WSLCUserSettings.cpp

Abstract:

Implementation of UserSettings — YAML loading and validation.

--*/
#include "UserSettings.h"
#include "precomp.h"
#include "WSLCUserSettings.h"
#include "filesystem.hpp"
#include "string.hpp"
#include "wslutil.h"

#pragma warning(push)
#pragma warning(disable : 4251 4275)
#include <yaml-cpp/yaml.h>
#pragma warning(pop)
#include <algorithm>
#include <format>
#include <fstream>
Expand All @@ -25,7 +30,6 @@ using namespace wsl::windows::common::string;

namespace wsl::windows::wslc::settings {

// Default settings file template — written on first run.
// All entries are commented out; the values shown are the built-in defaults.
// TODO: localization for comments needed?
static constexpr std::string_view s_DefaultSettingsTemplate =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Copyright (c) Microsoft. All rights reserved.

Module Name:

UserSettings.h
WSLCUserSettings.h

Abstract:

Expand Down Expand Up @@ -156,9 +156,7 @@ class UserSettings
// Overwrites the settings file with the commented-out defaults template.
void Reset() const;

protected:
// Loads settings from an explicit directory. Used by the singleton (via
// the private zero-arg constructor) and by test subclasses.
// Loads settings from an explicit directory.
explicit UserSettings(const std::filesystem::path& settingsDir);
~UserSettings() = default;

Expand Down
2 changes: 2 additions & 0 deletions src/windows/common/wslutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ static const std::map<HRESULT, LPCWSTR> g_commonErrors{
X(WSLC_E_VOLUME_NOT_FOUND),
X(WSLC_E_CONTAINER_NOT_RUNNING),
X(WSLC_E_CONTAINER_IS_RUNNING),
X(WSLC_E_SESSION_RESERVED),
X(WSLC_E_INVALID_SESSION_NAME),
X_WIN32(RPC_S_SERVER_UNAVAILABLE),
X_WIN32(ERROR_ELEVATION_REQUIRED)};

Expand Down
3 changes: 2 additions & 1 deletion src/windows/service/exe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ target_link_libraries(wslservice
legacy_stdio_definitions
VirtDisk.lib
Winhttp.lib
Synchronization.lib)
Synchronization.lib
yaml-cpp)

target_precompile_headers(wslservice REUSE_FROM common)
set_target_properties(wslservice PROPERTIES FOLDER windows)
Loading