This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients amaury.forgeotdarc, christian.heimes, eryksun, paul.moore, piotr.dobrogost, serhiy.storchaka, tim.golden
Date 2021-03-12.02:11:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1615515061.68.0.389377640512.issue2528@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-03-12 02:11:01eryksunsetrecipients: + eryksun, paul.moore, amaury.forgeotdarc, christian.heimes, tim.golden, piotr.dobrogost, serhiy.storchaka
2021-03-12 02:11:01eryksunsetmessageid: <1615515061.68.0.389377640512.issue2528@roundup.psfhosted.org>
2021-03-12 02:11:01eryksunlinkissue2528 messages
2021-03-12 02:11:01eryksuncreate