The _access function in MSVCRT appears to be flawed: it doesn't check
the NT access rights, it only looks at the directory entries.
This means that if a user has read-only access to a network share, but
file "foo" there is not marked read-only, then
will return 0, indicating that write access is available. However,
attempts to open the file to write to it will fail.
Google has shown me that other people have seen this problem, e.g.
this on groups.google.com: <http://tinyurl.com/5ua9u>. However, I
haven't been able to find an implementation of access() that works
Does anyone have one?
I think the proper way to write one would be to use
GetNamedSecurityInfo to retrieve a "DACL", then
GetEffectiveRightsFromACL to find what rights the current process has.
However, these functions aren't available before NT version 4, or any
Win9X, and DACL's only exist on NTFS, not on FAT drives, so With
those restrictions, it looks non-trivial to do it, and I'd rather not
spend the time if someone else already has.
I may just try opening the file and see if I succeed, but this is an
ugly solution: it probably changes the last-mod date, for one thing.