Commit 51a8889
committed
mingw: special-case administrators even more
The check for dubious ownership has one particular quirk on Windows: if
running as an administrator, files owned by the Administrators _group_
are considered owned by the user.
The rationale for that is: When running in elevated mode, Git creates
files that aren't owned by the individual user but by the Administrators
group.
There is yet another quirk, though: The check I introduced to determine
whether the current user is an administrator uses the
`CheckTokenMembership()` function with the current process token. And
that check only succeeds when running in elevated mode!
Let's be a bit more lenient here and look harder whether the current
user is an administrator. We do this by looking for a so-called "linked
token". That token exists when administrators run in non-elevated mode,
and can be used to create a new process in elevated mode. And feeding
_that_ token to the `CheckTokenMembership()` function succeeds!
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>1 parent 58f679d commit 51a8889
1 file changed
+28
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3717 | 3717 | | |
3718 | 3718 | | |
3719 | 3719 | | |
3720 | | - | |
| 3720 | + | |
3721 | 3721 | | |
3722 | 3722 | | |
3723 | 3723 | | |
3724 | | - | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
3725 | 3729 | | |
3726 | 3730 | | |
3727 | | - | |
| 3731 | + | |
3728 | 3732 | | |
3729 | 3733 | | |
3730 | 3734 | | |
3731 | 3735 | | |
3732 | 3736 | | |
3733 | | - | |
3734 | | - | |
| 3737 | + | |
| 3738 | + | |
3735 | 3739 | | |
3736 | 3740 | | |
3737 | | - | |
| 3741 | + | |
3738 | 3742 | | |
3739 | 3743 | | |
3740 | 3744 | | |
3741 | 3745 | | |
3742 | | - | |
3743 | 3746 | | |
3744 | | - | |
| 3747 | + | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
3745 | 3758 | | |
3746 | 3759 | | |
3747 | 3760 | | |
| |||
3820 | 3833 | | |
3821 | 3834 | | |
3822 | 3835 | | |
| 3836 | + | |
3823 | 3837 | | |
3824 | 3838 | | |
3825 | 3839 | | |
3826 | | - | |
| 3840 | + | |
3827 | 3841 | | |
3828 | 3842 | | |
3829 | 3843 | | |
3830 | 3844 | | |
3831 | 3845 | | |
3832 | 3846 | | |
3833 | | - | |
3834 | | - | |
| 3847 | + | |
| 3848 | + | |
| 3849 | + | |
| 3850 | + | |
| 3851 | + | |
3835 | 3852 | | |
3836 | 3853 | | |
3837 | 3854 | | |
| |||
0 commit comments