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: fix for bug #857297 (tarfile and hardlinks)
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: nnorwitz Nosy List: lars.gustaebel, nnorwitz
Priority: normal Keywords: patch

Created on 2004-03-15 20:51 by lars.gustaebel, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
patch-857297 lars.gustaebel, 2004-03-15 20:51 bugfix and a test
Messages (3)
msg45575 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2004-03-15 20:51
Included is a patch that fixes the extraction of
hardlinks in tarfile.py (bug #857297) and a testcase.

Until now tarfile.py extracted hardlinks the same way
as symlinks which worked under certain circumstances:
if the hardlink source is accessible from the current
working directory everything is fine, but if you choose
to extract it to a different location it won't work.  
    That particular code in tarfile.py dates back to my
good old windoze days where my understanding of unix
filesystem basics was not as profound as it is today :-)

The testcase probably needs some attention regarding
portability. (On platforms that do not have os.link()
it is skipped completely.)
Trying to extract a hardlink and testing for its
existence afterwards is no option here, because it
doesn't necessarily need to be tarfile.py's fault if
this doesn't work. There are many different conditions
involved, especially the filesystem the test is made on.

My current solution is that the testcase tries to
create a link and if it gets an ENOENT (which means the
link's source file cannot be found) it fails. All other
EnvironmentErrors are ignored.
Interestingly this testcase even works on a FAT32
filesystem (on my Linux box) - if the link's source
cannot be found there is an ENOENT (and the test fails
as it should), and if it can be found there is an EPERM
which is ignored.

IMO all this is a bit too much black magic and maybe
the testcase introduces more problems than it actually
solves, so feel free to throw it away.
msg45576 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2004-03-16 02:57
Logged In: YES 
user_id=33168

Lars, I just wanted to say thanks for this patch and the
other.  I hope to get around to them soon.  But it may have
to wait until after pycon.
msg45577 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2004-07-20 22:10
Logged In: YES 
user_id=33168

Thanks!

Checked in as:
 * Lib/tarfile.py; 1.13
 * Lib/test/test_tarfile.py; 1.13
 * Misc/NEWS; 1.1048

Perhaps this should be backported to 2.3?
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40034
2004-03-15 20:51:46lars.gustaebelcreate