classification
Title: shutil.chown on Windows
Type: behavior Stage: needs patch
Components: IO, Library (Lib), Windows Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2018-03-25 22:55 by eryksun, last changed 2018-03-25 23:00 by eryksun.

Messages (2)
msg314436 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2018-03-25 22:55
shutil.chown is defined in Windows even though it's only written for Unix and only documented as available in Unix. Defining it should be skipped on Windows.

Possibly in 3.8 shutil.chown could be implemented on Windows by calling a new os.set_owner function that supports user/group names and SID strings. It could copy how icacls.exe allows using SDDL aliases and string SIDs that begin with an asterisk (e.g. "*BA" and "*S-1-32-544" for BUILTIN\Administrators). If the string starts with an asterisk, get the SID via ConvertStringSidToSid. Otherwise get the SID via LookupAccountName. Then to modify the file's user and group, try to enable SeRestorePrivilege for the current thread and call Set[Named]SecurityInfo.
msg314437 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2018-03-25 23:00
Oops, the SID for BUILTIN\Administrators is S-1-5-32-544. I left out the authority ID (5).
History
Date User Action Args
2018-03-25 23:00:21eryksunsetmessages: + msg314437
2018-03-25 22:55:36eryksuncreate