Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shutil.move() does not preserve ownership #42586

Closed
sprif mannequin opened this issue Nov 13, 2005 · 3 comments
Closed

shutil.move() does not preserve ownership #42586

sprif mannequin opened this issue Nov 13, 2005 · 3 comments
Assignees
Labels
easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@sprif
Copy link
Mannequin

sprif mannequin commented Nov 13, 2005

BPO 1355826
Nosy @tarekziade, @mitsuhiko

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/tarekziade'
closed_at = <Date 2010-04-20.09:30:19.031>
created_at = <Date 2005-11-13.10:14:17.000>
labels = ['easy', 'type-feature', 'library']
title = 'shutil.move() does not preserve ownership'
updated_at = <Date 2010-04-20.09:30:19.029>
user = 'https://bugs.python.org/sprif'

bugs.python.org fields:

activity = <Date 2010-04-20.09:30:19.029>
actor = 'tarek'
assignee = 'tarek'
closed = True
closed_date = <Date 2010-04-20.09:30:19.031>
closer = 'tarek'
components = ['Library (Lib)']
creation = <Date 2005-11-13.10:14:17.000>
creator = 'sprif'
dependencies = []
files = []
hgrepos = []
issue_num = 1355826
keywords = ['easy']
message_count = 3.0
messages = ['60836', '83019', '103688']
nosy_count = 3.0
nosy_names = ['tarek', 'sprif', 'aronacher']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'test needed'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue1355826'
versions = ['Python 2.6', 'Python 3.0', 'Python 3.1', 'Python 2.7']

@sprif
Copy link
Mannequin Author

sprif mannequin commented Nov 13, 2005

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

@sprif sprif mannequin added stdlib Python modules in the Lib dir labels Nov 13, 2005
@akitada akitada mannequin added type-feature A feature request or enhancement labels Mar 1, 2009
@mitsuhiko
Copy link
Member

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".

@devdanzin devdanzin mannequin added easy labels Apr 22, 2009
@tarekziade
Copy link
Mannequin

tarekziade mannequin commented Apr 20, 2010

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

@tarekziade tarekziade mannequin closed this as completed Apr 20, 2010
@tarekziade tarekziade mannequin self-assigned this Apr 20, 2010
@tarekziade tarekziade mannequin closed this as completed Apr 20, 2010
@tarekziade tarekziade mannequin self-assigned this Apr 20, 2010
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant