Commit 573386f
committed
mingw: special-case administrators even more (#712)
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!2 files changed
Lines changed: 47 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3718 | 3718 | | |
3719 | 3719 | | |
3720 | 3720 | | |
3721 | | - | |
| 3721 | + | |
3722 | 3722 | | |
3723 | 3723 | | |
3724 | 3724 | | |
3725 | | - | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
3726 | 3730 | | |
3727 | 3731 | | |
3728 | | - | |
| 3732 | + | |
3729 | 3733 | | |
3730 | 3734 | | |
3731 | 3735 | | |
3732 | 3736 | | |
3733 | 3737 | | |
3734 | | - | |
3735 | | - | |
| 3738 | + | |
| 3739 | + | |
3736 | 3740 | | |
3737 | 3741 | | |
3738 | | - | |
| 3742 | + | |
3739 | 3743 | | |
3740 | 3744 | | |
3741 | 3745 | | |
3742 | 3746 | | |
3743 | | - | |
3744 | 3747 | | |
3745 | | - | |
| 3748 | + | |
| 3749 | + | |
| 3750 | + | |
| 3751 | + | |
| 3752 | + | |
| 3753 | + | |
| 3754 | + | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + | |
| 3758 | + | |
3746 | 3759 | | |
3747 | 3760 | | |
3748 | 3761 | | |
| |||
3821 | 3834 | | |
3822 | 3835 | | |
3823 | 3836 | | |
| 3837 | + | |
3824 | 3838 | | |
3825 | 3839 | | |
3826 | 3840 | | |
3827 | | - | |
| 3841 | + | |
3828 | 3842 | | |
3829 | 3843 | | |
3830 | 3844 | | |
3831 | 3845 | | |
3832 | 3846 | | |
3833 | 3847 | | |
3834 | | - | |
3835 | | - | |
| 3848 | + | |
| 3849 | + | |
| 3850 | + | |
| 3851 | + | |
| 3852 | + | |
3836 | 3853 | | |
3837 | 3854 | | |
3838 | 3855 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
507 | 526 | | |
508 | 527 | | |
509 | 528 | | |
| |||
0 commit comments