Commit 90aec07
committed
mingw: special-case administrators even more
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!
Signed-off-by: Johannes Schindelin <[email protected]>1 parent 683c54c commit 90aec07
1 file changed
+28
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2826 | 2826 | | |
2827 | 2827 | | |
2828 | 2828 | | |
2829 | | - | |
| 2829 | + | |
2830 | 2830 | | |
2831 | 2831 | | |
2832 | 2832 | | |
2833 | | - | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
2834 | 2838 | | |
2835 | 2839 | | |
2836 | | - | |
| 2840 | + | |
2837 | 2841 | | |
2838 | 2842 | | |
2839 | 2843 | | |
2840 | 2844 | | |
2841 | 2845 | | |
2842 | | - | |
2843 | | - | |
| 2846 | + | |
| 2847 | + | |
2844 | 2848 | | |
2845 | 2849 | | |
2846 | | - | |
| 2850 | + | |
2847 | 2851 | | |
2848 | 2852 | | |
2849 | 2853 | | |
2850 | 2854 | | |
2851 | | - | |
2852 | 2855 | | |
2853 | | - | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
| 2861 | + | |
| 2862 | + | |
| 2863 | + | |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
2854 | 2867 | | |
2855 | 2868 | | |
2856 | 2869 | | |
| |||
2931 | 2944 | | |
2932 | 2945 | | |
2933 | 2946 | | |
| 2947 | + | |
2934 | 2948 | | |
2935 | 2949 | | |
2936 | 2950 | | |
2937 | | - | |
| 2951 | + | |
2938 | 2952 | | |
2939 | 2953 | | |
2940 | 2954 | | |
2941 | 2955 | | |
2942 | 2956 | | |
2943 | 2957 | | |
2944 | | - | |
2945 | | - | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
2946 | 2963 | | |
2947 | 2964 | | |
2948 | 2965 | | |
| |||
0 commit comments