Skip to content

Add DCAT registration remediation#14450

Open
florelis wants to merge 4 commits intomicrosoft:feature/wsl-for-appsfrom
florelis:dcat-remediation
Open

Add DCAT registration remediation#14450
florelis wants to merge 4 commits intomicrosoft:feature/wsl-for-appsfrom
florelis:dcat-remediation

Conversation

@florelis
Copy link
Member

@florelis florelis commented Mar 16, 2026

Summary of the Pull Request

To remediate the case where the registration key gets deleted, we re-set the key on every launch.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

I added the remediation to wslservice, near the end of the OnServiceStarting(). The registration function writes to the registry without checking, as we would want to update the version if it is wrong for some reason.
I added an option to set the registration version to 0.0.0.0, which can be used for the initial installation.

Validation Steps Performed

Copilot AI review requested due to automatic review settings March 16, 2026 23:27

This comment was marked as outdated.

Copilot AI review requested due to automatic review settings March 20, 2026 21:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a remediation path to ensure WSL’s DCAT registry registration is (re)written on service launch, covering scenarios where the registration key was deleted or becomes stale.

Changes:

  • Add wsl::windows::common::helpers::RegisterWithDcat() and invoke it during WslService::OnServiceStarting().
  • Introduce/propagate a DCAT_REGISTRATION_KEY compile-time definition from CMake.
  • Add installer/service tests validating DCAT registration creation and remediation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/windows/InstallerTests.cpp Adds tests validating DCAT registration exists after install and is remediated by service startup.
src/windows/service/exe/ServiceMain.cpp Calls DCAT registration remediation during service startup.
src/windows/common/helpers.hpp Declares RegisterWithDcat helper.
src/windows/common/helpers.cpp Implements DCAT registry key creation + version write.
CMakeLists.txt Adds DCAT_REGISTRATION_KEY compile definition used by remediation + tests.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 20, 2026 21:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@florelis florelis marked this pull request as ready for review March 20, 2026 21:51
@florelis florelis requested a review from a team as a code owner March 20, 2026 21:51
@florelis
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Collaborator

@OneBlue OneBlue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One small comment

}
else
{
registeredVersion.assign(L"0.0.0.0");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this ? It's looking like this is always set to true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect to use this when doing an install via the SDK API.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To expand on what @JohnMcPMS said

My understanding is that the way to do an initial install via DCAT is to register a fake version 0.0 and then scan for updates, which would find an "update" to the latest version.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I see. Do we know what the "scan" API is going to look like ?

This is probably OK for now, but I don't love the idea of the SDK writing that key, since that creates a race condition if an install is running in parallel

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that we want to go to the extents required to prevent a race between (un)installs and an SDK API install. I don't see a race here resulting in a negative outcome other than the expected arbitrary state at the end of the race which is unavoidable.

If you mean the existing scan API in the OS, it is https://learn.microsoft.com/en-us/windows/win32/api/wuapi/nf-wuapi-iupdatesearcher-search

If you mean the SDK "scan" API, that exists (CanRun), but I'm not sure of the implementation details. And it won't be performing the OS scan. It may end up reading from this value though.

Copy link
Collaborator

@OneBlue OneBlue Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that we want to go to the extents required to prevent a race between (un)installs and an SDK API install. I don't see a race here resulting in a negative outcome other than the expected arbitrary state at the end of the race which is unavoidable.

Well MSI installs happen under a global lock, so no packages can be installed / uninstalled at the same time, but if this code runs after an MSI installation, it could put us into a broken state where the package is installed, but its version number is incorrect.

Let's check back once we have a better view of what the DCAT acquisition API looks like

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants