Skip to content

Handle access denied error when setting owner if already owner - #5282

Merged
JohnMcPMS merged 2 commits into
microsoft:masterfrom
JohnMcPMS:temp-fix
Mar 12, 2025
Merged

Handle access denied error when setting owner if already owner#5282
JohnMcPMS merged 2 commits into
microsoft:masterfrom
JohnMcPMS:temp-fix

Conversation

@JohnMcPMS

@JohnMcPMS JohnMcPMS commented Mar 7, 2025

Copy link
Copy Markdown
Member

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
@github-actions

This comment was marked as outdated.

@yao-msft

yao-msft commented Mar 8, 2025

Copy link
Copy Markdown
Contributor

/azp run

1 similar comment
@JohnMcPMS

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@JohnMcPMS
JohnMcPMS merged commit 9171097 into microsoft:master Mar 12, 2025
@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