Commit c3e21fa
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 | |
|---|---|---|---|
| |||
3810 | 3810 | | |
3811 | 3811 | | |
3812 | 3812 | | |
3813 | | - | |
| 3813 | + | |
3814 | 3814 | | |
3815 | 3815 | | |
3816 | 3816 | | |
3817 | | - | |
| 3817 | + | |
| 3818 | + | |
| 3819 | + | |
| 3820 | + | |
| 3821 | + | |
3818 | 3822 | | |
3819 | 3823 | | |
3820 | | - | |
| 3824 | + | |
3821 | 3825 | | |
3822 | 3826 | | |
3823 | 3827 | | |
3824 | 3828 | | |
3825 | 3829 | | |
3826 | | - | |
3827 | | - | |
| 3830 | + | |
| 3831 | + | |
3828 | 3832 | | |
3829 | 3833 | | |
3830 | | - | |
| 3834 | + | |
3831 | 3835 | | |
3832 | 3836 | | |
3833 | 3837 | | |
3834 | 3838 | | |
3835 | | - | |
3836 | 3839 | | |
3837 | | - | |
| 3840 | + | |
| 3841 | + | |
| 3842 | + | |
| 3843 | + | |
| 3844 | + | |
| 3845 | + | |
| 3846 | + | |
| 3847 | + | |
| 3848 | + | |
| 3849 | + | |
| 3850 | + | |
3838 | 3851 | | |
3839 | 3852 | | |
3840 | 3853 | | |
| |||
3913 | 3926 | | |
3914 | 3927 | | |
3915 | 3928 | | |
| 3929 | + | |
3916 | 3930 | | |
3917 | 3931 | | |
3918 | 3932 | | |
3919 | | - | |
| 3933 | + | |
3920 | 3934 | | |
3921 | 3935 | | |
3922 | 3936 | | |
3923 | 3937 | | |
3924 | 3938 | | |
3925 | 3939 | | |
3926 | | - | |
3927 | | - | |
| 3940 | + | |
| 3941 | + | |
| 3942 | + | |
| 3943 | + | |
| 3944 | + | |
3928 | 3945 | | |
3929 | 3946 | | |
3930 | 3947 | | |
| |||
| 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