Message388534
With increasing use of os.access() in shutil and tempfile, it would be nice to have a real implementation of os.access() for Windows.
Instead of manually evaluating the security of the file/directory, as issue2528.2.patch attempts to do, I'd rather just open the file with the desired access (e.g. GENERIC_READ, GENERIC_WRITE, GENERIC_EXECUTE). An open-based check supports checking for sharing violations, filesystem policy (e.g. FILE_READ_ATTRIBUTES granted by the parent directory), non-filesystem devices, and access policy implemented by filter drivers in the device stack.
The code to open the file/directory can be factored out and generalized from the stat() implementation. The common open function can implement the flags AT_SYMLINK_NOFOLLOW and AT_EACCESS (without which it should temporarily revert to the process access token). Also, when a directory is opened with GENERIC_WRITE access, it can re-try the open with FILE_DELETE_CHILD access, which POSIX includes in write access for a directory.
An S_OK flag could also be supported to ignore a sharing violation in Windows. [MS-FSA] section 2.1.5.1.2 (Open of an Existing File) specifies that access sharing is checked after the readonly attribute and file security access check. So if an open fails with a sharing violation, the caller knows that access was otherwise granted. |
|
Date |
User |
Action |
Args |
2021-03-12 02:11:01 | eryksun | set | recipients:
+ eryksun, paul.moore, amaury.forgeotdarc, christian.heimes, tim.golden, piotr.dobrogost, serhiy.storchaka |
2021-03-12 02:11:01 | eryksun | set | messageid: <1615515061.68.0.389377640512.issue2528@roundup.psfhosted.org> |
2021-03-12 02:11:01 | eryksun | link | issue2528 messages |
2021-03-12 02:11:01 | eryksun | create | |
|