[issue30400] Race condition in shutil.copyfile(): source file replaced file during copy

2018-08-13 Thread Preston Moore
Preston Moore added the comment: Hello everyone, I've just updated my pull request to include an additional test so everything should be in shape testing wise. Once I get confirmation that this strategy is acceptable and/or this PR is merged I will get to work addressing the other

[issue30400] Race condition in shutil.copyfile(): source file replaced file during copy

2018-07-23 Thread Preston Moore
Preston Moore added the comment: Hey everyone, I have updated the pull request to include a version of copyfile() that attempts to address the discussed race condition by open()’ing a file descriptor to the relevant files as early as possible and maintaining it throughout processing. In

[issue30400] Race condition in shutil.copyfile(): source file replaced file during copy

2018-07-15 Thread STINNER Victor
STINNER Victor added the comment: Python doesn't use FD of directories by default because it introduces issues of FD limit with deep directory tree, issue of managing FD lifetime, etc. That's why some API have one flavor for path and another for FD. --

[issue30400] Race condition in shutil.copyfile(): source file replaced file during copy

2018-07-14 Thread Giampaolo Rodola'
Giampaolo Rodola' added the comment: > For example, os.stat() accepts both a filename (string) or a file descriptor > (integer). Interesting. I never realized that. Other functions involved in file copy are: os.lchmod os.chmod os.listxattr os.getxattr I checked and it appears they all

[issue30400] Race condition in shutil.copyfile(): source file replaced file during copy

2018-07-13 Thread Preston Moore
Preston Moore added the comment: I like Victor's idea for updating public functions to support file descriptors. I could submit a patch for this instead if desired. In the meantime, I've updated the pull request for this issue so the patch I originally created that compares inode numbers

[issue30400] Race condition in shutil.copyfile(): source file replaced file during copy

2018-07-11 Thread STINNER Victor
STINNER Victor added the comment: > The definitive solution to this problem would theoretically be to have all > these interconnected functions pass fds instead of "paths" but of course that > is hardly possible. I agree that it's the way to go. Python makes little difference between a

[issue30400] Race condition in shutil.copyfile(): source file replaced file during copy

2018-07-11 Thread STINNER Victor
Change by STINNER Victor : -- title: Race condition in shutil.copyfile() -> Race condition in shutil.copyfile(): source file replaced file during copy ___ Python tracker ___

[issue30400] Race condition in shutil.copyfile()

2018-07-08 Thread Giampaolo Rodola'
Giampaolo Rodola' added the comment: All copy* functions and move() are subjects to race conditions (the only exception is rmtree()). You may solve the race condition in copyfile() but then you'd have the same problem in copystat() and copymode() which are used by copy() and copy2(). The

[issue30400] Race condition in shutil.copyfile()

2018-07-06 Thread Preston Moore
Preston Moore added the comment: Sure. I'll get everything up to date for 3.8 and create and required test. Thanks! -- ___ Python tracker ___

[issue30400] Race condition in shutil.copyfile()

2018-07-04 Thread Zachary Ware
Zachary Ware added the comment: This can only be accepted into 3.8 at this point due to the new exception type. The patch looks fairly straightforward; would it be possible to add a test that hits the new raise condition? -- nosy: +zach.ware stage: -> patch review versions: +Python

[issue30400] Race condition in shutil.copyfile()

2018-06-12 Thread Giampaolo Rodola'
Change by Giampaolo Rodola' : -- nosy: +giampaolo.rodola ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue30400] Race condition in shutil.copyfile()

2017-06-14 Thread Preston Moore
Preston Moore added the comment: Pull request is now passing with no conflicts. -- ___ Python tracker ___ ___

[issue30400] Race condition in shutil.copyfile()

2017-05-18 Thread Preston Moore
Preston Moore added the comment: It looks like the PR is not passing 3 tests. I think this might be a result of the mock file objects not having inode numbers? Any feedback on this front? -- ___ Python tracker

[issue30400] Race condition in shutil.copyfile()

2017-05-18 Thread Roundup Robot
Changes by Roundup Robot : -- pull_requests: +1753 ___ Python tracker ___

[issue30400] Race condition in shutil.copyfile()

2017-05-18 Thread Preston Moore
New submission from Preston Moore: A race condition exists in shutil.copyfile() that allows the file being copied to be replaced between the time it was initially checked with stat() in this function and when it is actually open()'d and copied. This issue can be triggered from shutil.move()