[issue36656] Add race-free os.link and os.symlink wrapper / helper

2020-12-29 Thread Tom Hale
Tom Hale added the comment: Related issue found in testing: bpo-42778 Add follow_symlinks=True parameter to both os.path.samefile() and Path.samefile() -- ___ Python tracker <https://bugs.python.org/issue36

[issue42778] Add follow_symlinks=True parameter to both os.path.samefile() and Path.samefile()

2020-12-28 Thread Tom Hale
Tom Hale added the comment: In summary: The underlying os.stat() takes a follow_symlinks=True parameter but it can't be set to False when trying to samefile() two symbolic links. -- title: Add follow_symlinks=True to {os.path,Path}.samefile -> Add follow_symlinks=True parame

[issue42778] Add follow_symlinks=True to {os.path,Path}.samefile

2020-12-28 Thread Tom Hale
New submission from Tom Hale : The os.path and Path implementations of samefile() do not allow comparisons of symbolic links: % mkdir empty && chdir empty % ln -s non-existant broken % ln broken lnbroken % ls -i # Show inode numbers 19325632 broken@ 19325632 lnbroke

[issue41134] distutils.dir_util.copy_tree FileExistsError when updating symlinks

2020-07-16 Thread Tom Hale
Change by Tom Hale : -- keywords: +patch pull_requests: +20651 stage: -> patch review pull_request: https://github.com/python/cpython/pull/14464 ___ Python tracker <https://bugs.python.org/issu

[issue36656] Add race-free os.link and os.symlink wrapper / helper

2020-06-26 Thread Tom Hale
Tom Hale added the comment: Related: bpo-41134 distutils.dir_util.copy_tree FileExistsError when updating symlinks WIP update: I am just about to ask for feedback on my proposed solution at core-mentors...@python.org -- title: Please add race-free os.link and os.symlink wrapper

[issue41134] distutils.dir_util.copy_tree FileExistsError when updating symlinks

2020-06-26 Thread Tom Hale
New submission from Tom Hale : Here is a minimal test case: == #!/bin/bash cd /tmp || exit 1 dir=test-copy_tree src=$dir/src dst=$dir/dst mkdir -p "$src" touch "$src"/file ln -s file "$src/symlink" pyth

[issue36656] Please add race-free os.link and os.symlink wrapper / helper

2019-06-29 Thread Tom Hale
Tom Hale added the comment: I've created a PR here: https://github.com/python/cpython/pull/14464 Only shutil.symlink is currently implemented. Feedback sought from Windows users. @Michael.Felt please note that `overwrite=False` is the default. @taleinat I hope that the new implementation

[issue36656] Race conditions due to os.link and os.symlink POSIX specification

2019-06-03 Thread Tom Hale
Tom Hale added the comment: Serhiy wrote > Detected problem is better than non-detected problem. I agree. I also assert that no problem (via a shutil wrapper) is better than a detected problem which may not be handled. While it's up to the programmer to handle exceptions, it's only syst

[issue36656] Race conditions due to os.link and os.symlink POSIX specification

2019-06-03 Thread Tom Hale
Change by Tom Hale : -- title: Allow os.symlink(src, target, force=True) to prevent race conditions -> Race conditions due to os.link and os.symlink POSIX specification ___ Python tracker <https://bugs.python.org/issu

[issue36656] Allow os.symlink(src, target, force=True) to prevent race conditions

2019-05-14 Thread Tom Hale
Change by Tom Hale : -- type: security -> enhancement ___ Python tracker <https://bugs.python.org/issue36656> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue36656] Allow os.symlink(src, target, force=True) to prevent race conditions

2019-05-14 Thread Tom Hale
Tom Hale added the comment: Thanks Toshio Kuratomi, I raised it on the mailing list at: https://code.activestate.com/lists/python-ideas/55992/ -- ___ Python tracker <https://bugs.python.org/issue36

[issue36656] Allow os.symlink(src, target, force=True) to prevent race conditions

2019-05-03 Thread Tom Hale
Tom Hale added the comment: Yes, but by default (because of difficulty) people won't check for this case: 1. I delete existing symlink in order to recreate it 2. Attacker watching symlink finds it deleted and recreates it 3. I try to create symlink, and an unexpected exception is raised

[issue36656] Allow os.symlink(src, target, force=True) to prevent race conditions

2019-04-19 Thread Tom Hale
Tom Hale added the comment: The most correct work-around I believe exists is: (updates at: https://stackoverflow.com/a/55742015/5353461) def symlink_force(target, link_name): ''' Create a symbolic link pointing to target named link_name. Overwrite target

[issue36656] Allow os.symlink(src, target, force=True) to prevent race conditions

2019-04-18 Thread Tom Hale
New submission from Tom Hale : I cannot find a race-condition-free way to force overwrite an existing symlink. os.symlink() requires that the target does not exist, meaning that it could be created via race condition the two workaround solutions that I've seen: 1. Unlink existing symlink

[issue32001] @lru_cache needs to be called with ()

2017-11-10 Thread Tom Hale
New submission from Tom Hale <t...@hale.ee>: This comes from a question I raised on StackOverflow: https://stackoverflow.com/q/47218313/5353461 I've copied the text