Add DCAT registration remediation#14450
Add DCAT registration remediation#14450florelis wants to merge 4 commits intomicrosoft:feature/wsl-for-appsfrom
Conversation
baad3f9 to
035e789
Compare
There was a problem hiding this comment.
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 duringWslService::OnServiceStarting(). - Introduce/propagate a
DCAT_REGISTRATION_KEYcompile-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>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
OneBlue
left a comment
There was a problem hiding this comment.
LGTM. One small comment
| } | ||
| else | ||
| { | ||
| registeredVersion.assign(L"0.0.0.0"); |
There was a problem hiding this comment.
Should we remove this ? It's looking like this is always set to true
There was a problem hiding this comment.
I expect to use this when doing an install via the SDK API.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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
Detailed Description of the Pull Request / Additional comments
I added the remediation to
wslservice, near the end of theOnServiceStarting(). 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