[Python-ideas] Add shutil.chown(..., recursive=False)
Steven D'Aprano
steve at pearwood.info
Tue May 29 03:15:37 EDT 2018
On Tue, May 29, 2018 at 06:29:50PM +1200, Greg Ewing wrote:
> Steven D'Aprano wrote:
> >But it doesn't matter: regular users can call chown -R:
>
> Only if you're not actually telling it to change anything.
That's not correct. Look closely at my example: the file ownership
recursively changed from steve.steve to steve.users.
> % ls -l foo.txt
> -rw-r--r-- 1 greg users 1 29 May 18:19 foo.txt
> % chown greg foo.txt
> % chown fred foo.txt
> chown: foo.txt: Operation not permitted
And yet Python provides a chown function despite this alleged
uselessness. Maybe it's not quite so useless as you think?
Here's a thought... maybe sometimes people actually do run Python
scripts as root?
And as the comments to this Stackoverflow post explain:
https://unix.stackexchange.com/questions/119229/can-not-chown-a-file-from-my-user-to-another-user
the ability for unprivileged users to change ownership to another user
is configurable under POSIX.
> So you have to be root in order to do anything *useful*
> with it.
Fortunately that is not correct, but even if it were, that's no reason
to not allow chown to apply recursively.
--
Steve
More information about the Python-ideas
mailing list