Request for review: 7190897 (fs) Files.isWritable method returns false when the path is writable (win). - ver. 1

Alan Bateman Alan.Bateman at oracle.com
Mon Mar 4 11:51:49 UTC 2013


On 04/03/2013 09:31, Alexey Utkin wrote:
> Alan,
> Do you agree with
>>     /**
>>      * Check the access right against the securityInfo in the current 
>> thread.
>>      */
>>     static boolean checkAccessMask(long securityInfo, int accessMask,
>>         int genericRead, int genericWrite, int genericExecute, int 
>> genericAll)
>>         throws WindowsException
>>     {
>>         int privilegies = TOKEN_QUERY;
>>         long hToken = OpenThreadToken(GetCurrentThread(), 
>> privilegies, false);
>>         if (hToken == 0L && processTokenWithDuplicateAccess != 0L)
>>             hToken = DuplicateTokenEx(processTokenWithDuplicateAccess,
>>                 privilegies);
>>
>>         boolean hasRight = false;
>>         if (hToken != 0L) {
>>             try {
>>                 hasRight = AccessCheck(hToken, securityInfo, accessMask,
>>                     genericRead, genericWrite, genericExecute, 
>> genericAll);
>>             } finally {
>>                 CloseHandle(hToken);
>>             }
>>         }
>>         return hasRight;
>>     }
> implementation approach?
Can the handle to the token (hToken) be 0? In my comment I was suggesting:

long hToken = OpenThreadToken(...);
try {
     ...
} finally {
     CloseHandle(hToken);
}

but that doesn't work if OpenThreadToken succeeds with a handle of 0. If 
0 is not possible then there are a few other clean-ups that we could do 
at a later time.

-Alan



More information about the core-libs-dev mailing list