[Python-ideas] Add shutil.chown(..., recursive=False)

Wes Turner wes.turner at gmail.com
Wed May 30 12:19:34 EDT 2018


On Wednesday, May 30, 2018, Nick Coghlan <ncoghlan at gmail.com> wrote:

> On 30 May 2018 at 02:38, Guido van Rossum <guido at python.org> wrote:
>
>> Honestly, despite the occasional use case(1), I'm not sure that this is a
>> battery we need in the stdlib. Nobody seems too excited about writing the
>> code, and when the operation is needed, shelling out to the system chown is
>> not too onerous. (Ditto for chmod.)
>>
>> (1) Not even sure that a use case was shown -- it was just shown that the
>> operation is not necessarily useless.
>>
>
> My main use cases have been in installers and test suites, but those cases
> have also been for Linux-specific code where shelling out to "chown -R" and
> "chmod -R" was an entirely acceptable alternative.
>
> I think one of the other key points here is that "chown" and "chmod"
> inherently don't map at all well to the Windows filesystem access control
> model [1], so there's no new portability challenges arising from expecting
> the chown and chmod commands to be available.
>
> Cheers,
> Nick.
>
> [1] os.chown and shutil.chown don't exist at all there, and os.chmod only
> supports setting a file to read-only - there isn't any access to user or
> group permissions.
>

Notably, Ansible and Salt don't haven't even tried to abstract Linux/BSD
and Windows filesystem ACLs into a common API:

https://github.com/ansible/ansible/blob/devel/lib/ansible/
modules/files/acl.py
https://github.com/ansible/ansible/blob/devel/lib/ansible/
modules/windows/win_acl.py
https://github.com/ansible/ansible/blob/devel/lib/
ansible/modules/windows/win_acl.ps1


https://github.com/saltstack/salt/blob/develop/salt/states/file.py

https://github.com/saltstack/salt/blob/develop/salt/states/win_dacl.py
https://github.com/saltstack/salt/blob/develop/salt/modules/win_dacl.py
https://github.com/saltstack/salt/blob/develop/salt/utils/win_dacl.py

https://github.com/saltstack/salt/blob/develop/salt/states/linux_acl.py
https://github.com/saltstack/salt/blob/develop/salt/modules/linux_acl.py

... Looked these up and thought I'd share.

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180530/d419a603/attachment.html>


More information about the Python-ideas mailing list