Commit 87d48fc
authored
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 | |
|---|---|---|---|
| |||
3575 | 3575 | | |
3576 | 3576 | | |
3577 | 3577 | | |
3578 | | - | |
| 3578 | + | |
3579 | 3579 | | |
3580 | 3580 | | |
3581 | 3581 | | |
3582 | | - | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
3583 | 3587 | | |
3584 | 3588 | | |
3585 | | - | |
| 3589 | + | |
3586 | 3590 | | |
3587 | 3591 | | |
3588 | 3592 | | |
3589 | 3593 | | |
3590 | 3594 | | |
3591 | | - | |
3592 | | - | |
| 3595 | + | |
| 3596 | + | |
3593 | 3597 | | |
3594 | 3598 | | |
3595 | | - | |
| 3599 | + | |
3596 | 3600 | | |
3597 | 3601 | | |
3598 | 3602 | | |
3599 | 3603 | | |
3600 | | - | |
3601 | 3604 | | |
3602 | | - | |
| 3605 | + | |
| 3606 | + | |
| 3607 | + | |
| 3608 | + | |
| 3609 | + | |
| 3610 | + | |
| 3611 | + | |
| 3612 | + | |
| 3613 | + | |
| 3614 | + | |
| 3615 | + | |
3603 | 3616 | | |
3604 | 3617 | | |
3605 | 3618 | | |
| |||
3678 | 3691 | | |
3679 | 3692 | | |
3680 | 3693 | | |
| 3694 | + | |
3681 | 3695 | | |
3682 | 3696 | | |
3683 | 3697 | | |
3684 | | - | |
| 3698 | + | |
3685 | 3699 | | |
3686 | 3700 | | |
3687 | 3701 | | |
3688 | 3702 | | |
3689 | 3703 | | |
3690 | 3704 | | |
3691 | | - | |
3692 | | - | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
3693 | 3710 | | |
3694 | 3711 | | |
3695 | 3712 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
503 | 503 | | |
504 | 504 | | |
505 | 505 | | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
506 | 525 | | |
507 | 526 | | |
508 | 527 | | |
| |||
0 commit comments