Repository navigation
bpo-9949: Enable symlink traversal for ntpath.realpath - #15287
Conversation
|
This is ready to merge once CI passes. I'll do it and then rebase #15231 before merging that one. |
|
Thanks @zooba for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8. |
(cherry picked from commit 75e0649) Co-authored-by: Steve Dower <steve.dower@python.org>
|
GH-15367 is a backport of this pull request to the 3.8 branch. |
|
|
|
|
|
| while normcase(path) not in seen: | ||
| seen.add(normcase(path)) | ||
| try: | ||
| path = _nt_readlink(path) |
There was a problem hiding this comment.
If you're allowing reading junction targets, you must fail a remote path here if path is a junction, per os.lstat. A junction target in a UNC path is meaningless to us. A junction has to target local devices on a system, i.e. its local DOS drive and volume GUID names. At best these aren't defined for us, and at worst they map to an unrelated drive on our side. If for some reason junction "spam" fails to resolve on the server, we cannot go any further. We leave it as "spam" in the UNC path, and we're done.
There was a problem hiding this comment.
If path is a relative symlink, it must be evaluated relative to its parent directory, not out current directory.
The test_shutil and test_discovery hunks of upstream 75e0649 (bpo-9949, pythonGH-15287), which the ntpath.realpath port left out: - test_shutil.TestMove.test_move_dangling_symlink compares realpath() on both sides; with a resolving realpath the Windows-only readlink() comparison can differ (for example 8.3 short names in the temp dir). - test_discovery.test_detect_module_clash substitutes abspath() for realpath() on Windows, since realpath() may add path prefixes when it cannot resolve the test's fake files. The test_os hunk is not included: it relies on 3.8's bytes support in os.readlink() on Windows, which 3.7 does not have. (cherry picked from commit 75e0649) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
https://bugs.python.org/issue9949