Commit 39b94fd
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 | |
|---|---|---|---|
| |||
3805 | 3805 | | |
3806 | 3806 | | |
3807 | 3807 | | |
3808 | | - | |
| 3808 | + | |
3809 | 3809 | | |
3810 | 3810 | | |
3811 | 3811 | | |
3812 | | - | |
| 3812 | + | |
| 3813 | + | |
| 3814 | + | |
| 3815 | + | |
| 3816 | + | |
3813 | 3817 | | |
3814 | 3818 | | |
3815 | | - | |
| 3819 | + | |
3816 | 3820 | | |
3817 | 3821 | | |
3818 | 3822 | | |
3819 | 3823 | | |
3820 | 3824 | | |
3821 | | - | |
3822 | | - | |
| 3825 | + | |
| 3826 | + | |
3823 | 3827 | | |
3824 | 3828 | | |
3825 | | - | |
| 3829 | + | |
3826 | 3830 | | |
3827 | 3831 | | |
3828 | 3832 | | |
3829 | 3833 | | |
3830 | | - | |
3831 | 3834 | | |
3832 | | - | |
| 3835 | + | |
| 3836 | + | |
| 3837 | + | |
| 3838 | + | |
| 3839 | + | |
| 3840 | + | |
| 3841 | + | |
| 3842 | + | |
| 3843 | + | |
| 3844 | + | |
| 3845 | + | |
3833 | 3846 | | |
3834 | 3847 | | |
3835 | 3848 | | |
| |||
3908 | 3921 | | |
3909 | 3922 | | |
3910 | 3923 | | |
| 3924 | + | |
3911 | 3925 | | |
3912 | 3926 | | |
3913 | 3927 | | |
3914 | | - | |
| 3928 | + | |
3915 | 3929 | | |
3916 | 3930 | | |
3917 | 3931 | | |
3918 | 3932 | | |
3919 | 3933 | | |
3920 | 3934 | | |
3921 | | - | |
3922 | | - | |
| 3935 | + | |
| 3936 | + | |
| 3937 | + | |
| 3938 | + | |
| 3939 | + | |
3923 | 3940 | | |
3924 | 3941 | | |
3925 | 3942 | | |
| |||
| 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