Skip to content

Conversation

JohnMcPMS
Copy link
Member

@JohnMcPMS JohnMcPMS commented Mar 7, 2025

Fixes #5276

Issue

Although I don't understand precisely why, we get access denied when attempting to open a directory with WRITE_OWNER even when we are already the owner. It may have to do with permissions to the parent directory, but the root cause isn't actually important here.

Our directory management code always attempts to set any directory to a known state, including the owner. It does so without any pre-check to see if the owner is already set to the desired value.

Change

If we get ERROR_ACCESS_DENIED when attempting to set the owner, check if the owner is already correct. If it is, attempt to set just the DACL.

Validation

Manual repro and validation that the fix works when the issue is exactly as described.

Microsoft Reviewers: Open in CodeFlow

@JohnMcPMS JohnMcPMS requested a review from a team as a code owner March 7, 2025 23:17
@microsoft-github-policy-service microsoft-github-policy-service bot added the Issue-Bug It either shouldn't be doing this or needs an investigation. label Mar 7, 2025

This comment was marked as outdated.

@yao-msft
Copy link
Contributor

yao-msft commented Mar 8, 2025

/azp run

1 similar comment
@JohnMcPMS
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JohnMcPMS JohnMcPMS merged commit 9171097 into microsoft:master Mar 12, 2025
9 checks passed
@JohnMcPMS JohnMcPMS deleted the temp-fix branch March 12, 2025 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Access Denied when %TEMP%\WinGet does not explicitly have the user with granted access
2 participants