GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GH-118447: Fix handling of unreadable symlinks in `os.path.realpath()` by barneygale · Pull Request #118489 · python/cpython

Conversation

@barneygale

@barneygale barneygale commented May 1, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Issue: posixpath.realpath('secretlink') raises #118447

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@barneygale
pythonGH-118447: Handle unreadable symlinks in os.path.realpath()
1619428
@bedevere-app bedevere-app Bot added the tests Tests in the Lib/test dir label May 1, 2024
@bedevere-app bedevere-app Bot mentioned this pull request May 1, 2024
posixpath.realpath('secretlink') raises #118447
Closed
barneygale added 2 commits May 1, 2024 21:45
@barneygale
DRY
fc5e670
@barneygale
Fix + NEWS
8d3fbff
@barneygale barneygale changed the title GH-118447: Handle unreadable symlinks in os.path.realpath() GH-118447: Fix handling of unreadable symlinks in os.path.realpath() May 1, 2024
@barneygale barneygale removed the tests Tests in the Lib/test dir label May 1, 2024
@barneygale
barneygale marked this pull request as ready for review May 1, 2024 22:06
@bedevere-app bedevere-app Bot added the awaiting core review label May 1, 2024
nineteendo

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@barneygale

barneygale commented May 6, 2024

Copy link
Copy Markdown
Contributor Author

If not resolving unreadable symlinks is acceptable, you still need to raise an error for link/...

realpath() shouldn't raise OSError in non-strict mode.

nineteendo reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka
serhiy-storchaka reviewed May 7, 2024
View reviewed changes
Comment thread Lib/posixpath.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_posixpath.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_posixpath.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

nineteendo
nineteendo reviewed May 9, 2024
View reviewed changes

@nineteendo nineteendo left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, you're right, it shouldn't raise an error. That's what strict is for.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka

serhiy-storchaka commented May 9, 2024

Copy link
Copy Markdown
Member

I think that it is reasonable to expect that realpath('dir/badlink/rest') returns the same result when badlink does not exist, is a file, is in non-readable directory or is non-readable itself, for any rest. It's error prone, but that's how it was defined.

nineteendo reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

nineteendo
nineteendo approved these changes May 18, 2024
View reviewed changes

@nineteendo nineteendo left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Barney, would you like to continue working on this? You have my approval if it means anything.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

barneygale reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
barneygale and others added 5 commits May 18, 2024 23:07
@barneygale @nineteendo
Update Lib/test/test_posixpath.py
90a4fe3
Co-authored-by: Nice Zombies <[email protected]>
@barneygale
Merge branch 'main' into secret-symlinks
8230c3c
@barneygale
Switch back to using os.stat() to raise ELOOP.
f13e494
@barneygale
Unused import
a29e836
@barneygale
Undo unnecessary changes
0af033d
@barneygale barneygale added needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes labels May 18, 2024
@barneygale
barneygale enabled auto-merge (squash) May 18, 2024 22:26
@barneygale

barneygale commented May 18, 2024

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews and suggestions, both!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@barneygale
barneygale merged commit caf6064 into python:main May 18, 2024
@miss-islington-app

miss-islington-app Bot commented May 18, 2024

Copy link
Copy Markdown

Thanks @barneygale for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting core review label May 18, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 18, 2024
@barneygale @nineteendo @miss-islington
pythonGH-118447: Fix handling of unreadable symlinks in `os.path.real…
57a36a8
…path()` (pythonGH-118489)

(cherry picked from commit caf6064)

Co-authored-by: Barney Gale <[email protected]>
Co-authored-by: Nice Zombies <[email protected]>
@miss-islington-app

miss-islington-app Bot commented May 18, 2024

Copy link
Copy Markdown

Sorry, @barneygale, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker caf6064a1bc15ac344afd78b780188e60b9c628e 3.12
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington-app miss-islington-app Bot assigned barneygale May 18, 2024
@bedevere-app

bedevere-app Bot commented May 18, 2024

Copy link
Copy Markdown

GH-119163 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label May 18, 2024
barneygale added a commit to barneygale/cpython that referenced this pull request May 18, 2024
@barneygale @nineteendo
pythonGH-118447: Fix handling of unreadable symlinks in `os.path.real…
b2cc8c2
…path()` (python#118489)

Co-authored-by: Nice Zombies <[email protected]>
(cherry picked from commit caf6064)
barneygale added a commit to barneygale/cpython that referenced this pull request May 18, 2024
@barneygale
[3.12] pythonGH-118447: Fix handling of unreadable symlinks in `os.pa…
bbabcfd
…th.realpath()` (pythonGH-118489)

Co-authored-by: Nice Zombies <[email protected]>.
(cherry picked from commit caf6064)

Co-authored-by: Barney Gale <[email protected]>
@barneygale

barneygale commented May 18, 2024

Copy link
Copy Markdown
Contributor Author

If no one objects, I'll skip backporting to 3.12 as this is a fairly minor bug and I can't be bothered to fix the conflicts :)

hugovk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented May 18, 2024

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 FreeBSD 3.x has failed when building commit caf6064.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1223/builds/3134) and take a look at the build logs.
  4. Check if the failure is related to this commit (caf6064) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/1223/builds/3134

Failed tests:

  • test_posixpath

Failed subtests:

  • test_realpath_unreadable_symlink - test.test_posixpath.PosixPathTest.test_realpath_unreadable_symlink

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/buildbot/buildarea/3.x.ware-freebsd/build/Lib/test/test_posixpath.py", line 670, in test_realpath_unreadable_symlink
    self.assertEqual(realpath(ABSTFN), ABSTFN)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/bui[19 chars].ware-freebsd/build/build/test_python_57143æ/@test_57143_tmpæ1' != '/bui[19 chars].ware-freebsd/build/build/test_python_57143æ/@test_57143_tmpæ'
- /buildbot/buildarea/3.x.ware-freebsd/build/build/test_python_57143æ/@test_57143_tmpæ1
?                                                                                     -
+ /buildbot/buildarea/3.x.ware-freebsd/build/build/test_python_57143æ/@test_57143_tmpæ


Traceback (most recent call last):
  File "/buildbot/buildarea/3.x.ware-freebsd/build/Lib/test/test_posixpath.py", line 670, in test_realpath_unreadable_symlink
    self.assertEqual(realpath(ABSTFN), ABSTFN)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/bui[19 chars].ware-freebsd/build/build/test_python_66351æ/@test_66351_tmpæ1' != '/bui[19 chars].ware-freebsd/build/build/test_python_66351æ/@test_66351_tmpæ'
- /buildbot/buildarea/3.x.ware-freebsd/build/build/test_python_66351æ/@test_66351_tmpæ1
?                                                                                     -
+ /buildbot/buildarea/3.x.ware-freebsd/build/build/test_python_66351æ/@test_66351_tmpæ
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented May 18, 2024

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 FreeBSD14 3.x has failed when building commit caf6064.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1232/builds/2352) and take a look at the build logs.
  4. Check if the failure is related to this commit (caf6064) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/1232/builds/2352

Failed tests:

  • test_posixpath

Failed subtests:

  • test_realpath_unreadable_symlink - test.test_posixpath.PosixPathTest.test_realpath_unreadable_symlink

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/test/test_posixpath.py", line 670, in test_realpath_unreadable_symlink
    self.assertEqual(realpath(ABSTFN), ABSTFN)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/hom[24 chars].opsec-fbsd14/build/build/test_python_79925æ/@test_79925_tmpæ1' != '/hom[24 chars].opsec-fbsd14/build/build/test_python_79925æ/@test_79925_tmpæ'
- /home/buildbot/buildarea/3.x.opsec-fbsd14/build/build/test_python_79925æ/@test_79925_tmpæ1
?                                                                                          -
+ /home/buildbot/buildarea/3.x.opsec-fbsd14/build/build/test_python_79925æ/@test_79925_tmpæ


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.opsec-fbsd14/build/Lib/test/test_posixpath.py", line 670, in test_realpath_unreadable_symlink
    self.assertEqual(realpath(ABSTFN), ABSTFN)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/hom[24 chars].opsec-fbsd14/build/build/test_python_75684æ/@test_75684_tmpæ1' != '/hom[24 chars].opsec-fbsd14/build/build/test_python_75684æ/@test_75684_tmpæ'
- /home/buildbot/buildarea/3.x.opsec-fbsd14/build/build/test_python_75684æ/@test_75684_tmpæ1
?                                                                                          -
+ /home/buildbot/buildarea/3.x.opsec-fbsd14/build/build/test_python_75684æ/@test_75684_tmpæ
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

barneygale added a commit that referenced this pull request May 18, 2024
@miss-islington @barneygale @nineteendo
[3.13] GH-118447: Fix handling of unreadable symlinks in `os.path.rea…
7407267
…lpath()` (GH-118489) (#119163)

(cherry picked from commit caf6064)

Co-authored-by: Barney Gale <[email protected]>
Co-authored-by: Nice Zombies <[email protected]>
@bedevere-bot

bedevere-bot commented May 18, 2024

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 FreeBSD 3.13 has failed when building commit 7407267.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1491/builds/46) and take a look at the build logs.
  4. Check if the failure is related to this commit (7407267) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/1491/builds/46

Failed tests:

  • test_posixpath

Failed subtests:

  • test_realpath_unreadable_symlink - test.test_posixpath.PosixPathTest.test_realpath_unreadable_symlink

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/buildbot/buildarea/3.13.ware-freebsd/build/Lib/test/test_posixpath.py", line 670, in test_realpath_unreadable_symlink
    self.assertEqual(realpath(ABSTFN), ABSTFN)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/bui[20 chars].ware-freebsd/build/build/test_python_84680æ/@test_84680_tmpæ1' != '/bui[20 chars].ware-freebsd/build/build/test_python_84680æ/@test_84680_tmpæ'
- /buildbot/buildarea/3.13.ware-freebsd/build/build/test_python_84680æ/@test_84680_tmpæ1
?                                                                                      -
+ /buildbot/buildarea/3.13.ware-freebsd/build/build/test_python_84680æ/@test_84680_tmpæ


Traceback (most recent call last):
  File "/buildbot/buildarea/3.13.ware-freebsd/build/Lib/test/test_posixpath.py", line 670, in test_realpath_unreadable_symlink
    self.assertEqual(realpath(ABSTFN), ABSTFN)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/bui[20 chars].ware-freebsd/build/build/test_python_77930æ/@test_77930_tmpæ1' != '/bui[20 chars].ware-freebsd/build/build/test_python_77930æ/@test_77930_tmpæ'
- /buildbot/buildarea/3.13.ware-freebsd/build/build/test_python_77930æ/@test_77930_tmpæ1
?                                                                                      -
+ /buildbot/buildarea/3.13.ware-freebsd/build/build/test_python_77930æ/@test_77930_tmpæ
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot

bedevere-bot commented May 18, 2024

Copy link
Copy Markdown

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 FreeBSD14 3.13 has failed when building commit 7407267.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/1481/builds/45) and take a look at the build logs.
  4. Check if the failure is related to this commit (7407267) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/1481/builds/45

Failed tests:

  • test_posixpath

Failed subtests:

  • test_realpath_unreadable_symlink - test.test_posixpath.PosixPathTest.test_realpath_unreadable_symlink

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.13.opsec-fbsd14/build/Lib/test/test_posixpath.py", line 670, in test_realpath_unreadable_symlink
    self.assertEqual(realpath(ABSTFN), ABSTFN)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/hom[25 chars].opsec-fbsd14/build/build/test_python_95351æ/@test_95351_tmpæ1' != '/hom[25 chars].opsec-fbsd14/build/build/test_python_95351æ/@test_95351_tmpæ'
- /home/buildbot/buildarea/3.13.opsec-fbsd14/build/build/test_python_95351æ/@test_95351_tmpæ1
?                                                                                           -
+ /home/buildbot/buildarea/3.13.opsec-fbsd14/build/build/test_python_95351æ/@test_95351_tmpæ


Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.13.opsec-fbsd14/build/Lib/test/test_posixpath.py", line 670, in test_realpath_unreadable_symlink
    self.assertEqual(realpath(ABSTFN), ABSTFN)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/hom[25 chars].opsec-fbsd14/build/build/test_python_94029æ/@test_94029_tmpæ1' != '/hom[25 chars].opsec-fbsd14/build/build/test_python_94029æ/@test_94029_tmpæ'
- /home/buildbot/buildarea/3.13.opsec-fbsd14/build/build/test_python_94029æ/@test_94029_tmpæ1
?                                                                                           -
+ /home/buildbot/buildarea/3.13.opsec-fbsd14/build/build/test_python_94029æ/@test_94029_tmpæ
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@barneygale barneygale mentioned this pull request May 19, 2024
GH-118447: Fix FreeBSD test failures. #119170
Merged
@JelleZijlstra JelleZijlstra mentioned this pull request May 28, 2024
backport a9a74da 3.13 #119642
Closed
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
@barneygale @nineteendo @estyxx
pythonGH-118447: Fix handling of unreadable symlinks in `os.path.real…
2a55dab
…path()` (python#118489)

Co-authored-by: Nice Zombies <[email protected]>
@hugovk hugovk removed the needs backport to 3.12 only security fixes label Feb 19, 2025
@keysmashes keysmashes mentioned this pull request Jan 30, 2026
Fix new_os_window_with_cwd in presence of defunct processes kovidgoyal/kitty#9441
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka left review comments
+1 more reviewer
@nineteendo nineteendo nineteendo approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@barneygale barneygale

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@barneygale @serhiy-storchaka @bedevere-bot @nineteendo @hugovk
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.