-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clearly differentiate running elevated vs. drag/drop breaking #14946
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
99c9ab6
Clearly differentiate between running elevated and being able to drag…
zadjii-msft a3964a2
Ah so apparently only BODGY is allowed. If it's only a wee bit bodgy …
zadjii-msft b0dc3f1
Merge remote-tracking branch 'origin/main' into dev/migrie/b/13928-ca…
zadjii-msft 6443ed1
notes from review - this really makes the code a lot more legible
zadjii-msft 0fbb7b3
Merge remote-tracking branch 'origin/main' into dev/migrie/b/13928-ca…
zadjii-msft 8f77f7d
sure fine whatever
zadjii-msft 1495151
Merge remote-tracking branch 'origin/main' into dev/migrie/b/13928-ca…
zadjii-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -653,9 +653,18 @@ GUID Utils::CreateV5Uuid(const GUID& namespaceGuid, const std::span<const std::b | |
return EndianSwap(newGuid); | ||
} | ||
|
||
bool Utils::IsElevated() | ||
// * Elevated users cannot use the modern drag drop experience. This is | ||
// specifically normal users running the Terminal as admin | ||
// * The Default Administrator, who does not have a split token, CAN drag drop | ||
// perfectly fine. So in that case, we want to return false. | ||
// * This has to be kept separate from IsRunningElevated, which is exclusively | ||
// used for "is this instance running as admin". | ||
bool Utils::CanUwpDragDrop() | ||
{ | ||
static auto isElevated = []() { | ||
// There's a lot of wacky double negatives here so that the logic is | ||
// basically the same as IsRunningElevated, but the end result semantically | ||
// makes sense as "CanDragDrop". | ||
static auto isDragDropBroken = []() { | ||
try | ||
{ | ||
wil::unique_handle processToken{ GetCurrentProcessToken() }; | ||
|
@@ -670,8 +679,30 @@ bool Utils::IsElevated() | |
// | ||
// See GH#7754, GH#11096 | ||
return false; | ||
// drag drop is _not_ broken -> they _can_ drag drop | ||
} | ||
|
||
// If they are running admin, they cannot drag drop. | ||
return wil::test_token_membership(nullptr, SECURITY_NT_AUTHORITY, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS); | ||
} | ||
catch (...) | ||
{ | ||
LOG_CAUGHT_EXCEPTION(); | ||
// This failed? That's very peculiar indeed. Let's err on the side | ||
// of "drag drop is broken", just in case. | ||
return true; | ||
} | ||
}(); | ||
|
||
return !isDragDropBroken; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, you did the hard part of writing the logic. Why not remove the double negative by...
(pipe the |
||
} | ||
|
||
// See CanUwpDragDrop, GH#13928 for why this is different. | ||
bool Utils::IsRunningElevated() | ||
{ | ||
static auto isElevated = []() { | ||
try | ||
{ | ||
return wil::test_token_membership(nullptr, SECURITY_NT_AUTHORITY, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS); | ||
} | ||
catch (...) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this kinda isn't relevant to this PR but why do these two members exist? We're using magic statics in Utils, so what's the point in caching these values?