Commit 3b930bf
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
+47
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3750 | 3750 | | |
3751 | 3751 | | |
3752 | 3752 | | |
3753 | | - | |
| 3753 | + | |
3754 | 3754 | | |
3755 | 3755 | | |
3756 | 3756 | | |
3757 | | - | |
| 3757 | + | |
| 3758 | + | |
| 3759 | + | |
| 3760 | + | |
| 3761 | + | |
3758 | 3762 | | |
3759 | 3763 | | |
3760 | | - | |
| 3764 | + | |
3761 | 3765 | | |
3762 | 3766 | | |
3763 | 3767 | | |
3764 | 3768 | | |
3765 | 3769 | | |
3766 | | - | |
3767 | | - | |
| 3770 | + | |
| 3771 | + | |
3768 | 3772 | | |
3769 | 3773 | | |
3770 | | - | |
| 3774 | + | |
3771 | 3775 | | |
3772 | 3776 | | |
3773 | 3777 | | |
3774 | 3778 | | |
3775 | | - | |
3776 | 3779 | | |
3777 | | - | |
| 3780 | + | |
| 3781 | + | |
| 3782 | + | |
| 3783 | + | |
| 3784 | + | |
| 3785 | + | |
| 3786 | + | |
| 3787 | + | |
| 3788 | + | |
| 3789 | + | |
| 3790 | + | |
3778 | 3791 | | |
3779 | 3792 | | |
3780 | 3793 | | |
| |||
3853 | 3866 | | |
3854 | 3867 | | |
3855 | 3868 | | |
| 3869 | + | |
3856 | 3870 | | |
3857 | 3871 | | |
3858 | 3872 | | |
3859 | | - | |
| 3873 | + | |
3860 | 3874 | | |
3861 | 3875 | | |
3862 | 3876 | | |
3863 | 3877 | | |
3864 | 3878 | | |
3865 | 3879 | | |
3866 | | - | |
3867 | | - | |
| 3880 | + | |
| 3881 | + | |
| 3882 | + | |
| 3883 | + | |
| 3884 | + | |
3868 | 3885 | | |
3869 | 3886 | | |
3870 | 3887 | | |
| |||
| 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