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.

classification
Title: shutil.move() does not preserve ownership
Type: enhancement Stage: test needed
Components: Library (Lib) Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: tarek Nosy List: aronacher, sprif, tarek
Priority: normal Keywords: easy

Created on 2005-11-13 10:14 by sprif, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg60836 - (view) Author: lightweight (sprif) Date: 2005-11-13 10:14
shutil.move() does not preserve file and directory
ownership when moving a whole directory tree to a
different filesystem. This does not happen when
shutil.move() is used to move a directory tree within
the same filesystem.
Version: python 2.4.2

I have had a look at the source code in shutil.py and
noticed that shutil.copystat() does not copy the
ownership information, whereas "stat" command does
output information about the ownership (on GNU/Linux at
least).
The only discussion I found refering to file /
directory ownership and possible security implications
(if any) can be found here:
http://mail.python.org/pipermail/python-bugs-list/2004-November/025985.html



msg83019 - (view) Author: Armin Ronacher (aronacher) * (Python committer) Date: 2009-03-02 13:27
While this is surprising, this is documented behavior:

"If the destination is on the current filesystem, then simply use
rename. Otherwise, copy src (with copy2()) to the dst and then remove src."

And copy2() uses copystat() and does not copy "contents, owner, and group".
msg103688 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2010-04-20 09:30
That's because there's no simple, portable way to copy all metadata.

If you need to copy all of them you will need to use OS-specific APIs
History
Date User Action Args
2022-04-11 14:56:14adminsetgithub: 42586
2010-04-20 09:30:19tareksetstatus: open -> closed

nosy: + tarek
messages: + msg103688

assignee: tarek
resolution: wont fix
2009-04-22 14:39:20ajaksu2setkeywords: + easy
stage: test needed
2009-03-20 23:31:23ajaksu2linkissue1368091 superseder
2009-03-02 13:27:26aronachersetnosy: + aronacher
messages: + msg83019
2009-03-01 05:32:38akitadasettype: enhancement
versions: + Python 2.6, Python 3.0, Python 3.1, Python 2.7, - Python 2.4
2005-11-13 10:14:17sprifcreate