Skip to content

[AI Generated] Ensure correct DSC export of admin settings#6109

Open
Trenly wants to merge 5 commits intomicrosoft:masterfrom
Trenly:copilot/ms-5881-fix-issue-5881
Open

[AI Generated] Ensure correct DSC export of admin settings#6109
Trenly wants to merge 5 commits intomicrosoft:masterfrom
Trenly:copilot/ms-5881-fix-issue-5881

Conversation

@Trenly
Copy link
Contributor

@Trenly Trenly commented Mar 26, 2026

Copilot Summary

winget dsc export --all exports all admin settings as false even when enabled. Root cause: SecureSettingsContainer doesn't verify that verification hash writes succeed, causing subsequent reads to throw unhandled exceptions.

Changes

AdminSettings.cpp

  • Added exception handling around m_settingStream.Get() to catch verification failures
  • Falls back to default values with error logging instead of crashing

Settings.cpp

  • Changed SetVerificationData() to return bool indicating write success
  • SecureSettingsContainer::Set() now checks verification write result
  • Reverts main write if verification write fails (atomic operation)
  • Added diagnostic logging for verification failures

Technical Detail

SecureSettingsContainer stores settings in one file and SHA256 hash in another. Write path was:

bool Set(value) {
    bool result = ExchangeSettingsContainer::Set(value);
    if (result) {
        SetVerificationData(hash);  // Return value ignored - bug
    }
    return result;
}

Now enforces atomicity:

bool Set(value) {
    bool result = ExchangeSettingsContainer::Set(value);
    if (result) {
        if (!SetVerificationData(hash)) {
            Remove();  // Revert
            return false;
        }
    }
    return result;
}

Read path now handles verification exceptions gracefully rather than leaving settings at default values.

Microsoft Reviewers: Open in CodeFlow

@Trenly Trenly requested a review from a team as a code owner March 26, 2026 04:28
@Trenly Trenly changed the title Copilot/ms 5881 fix issue 5881 [AI Generated] Ensure correct DSC export of admin settings Mar 26, 2026
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.

winget dsc export --all has wrong values for Admin Settings

2 participants