Skip to content

gh-157190: Follow symlinks when extracting tarfile hard links - #157191

Merged
encukou merged 4 commits into
python:mainfrom
StanFromIreland:sneaky_hardlink_relocation
Sep 10, 2026
Merged

gh-157190: Follow symlinks when extracting tarfile hard links#157191
encukou merged 4 commits into
python:mainfrom
StanFromIreland:sneaky_hardlink_relocation

Conversation

@StanFromIreland

@StanFromIreland StanFromIreland commented Sep 8, 2026

Copy link
Copy Markdown
Member

@StanFromIreland StanFromIreland added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 8, 2026
@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @StanFromIreland for commit 027cfba 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F157191%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Sep 8, 2026

@encukou encukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM; let's merge if the buildbots or the 3.13 backport don't fail in tarfile.
When merging: the commit message should mention that the fixed bug only exists in 3.13 and below.

Comment thread Lib/tarfile.py Outdated
Comment thread Lib/test/test_tarfile.py

@symlink_test
@os_helper.skip_unless_hardlink
def test_sneaky_hardlink_relocation(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to test also a symlink pointing to a directory?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure what that would be testing, a hard link to a directory isn't possible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I meant a hard link to the symlink, where the symlink points to a directory.

Something like that:

2026-09-09T17:26:21.505759000+0200 maurycy@gimel /tmp/tarararara  % tar tvf evil.tar
drw-r--r--  0 0      0           0 Jan  1  1970 a/d/
-rw-r--r--  0 0      0           5 Jan  1  1970 a/d/f
lrw-r--r--  0 0      0           0 Jan  1  1970 a/b/s -> ../d
hrw-r--r--  0 0      0           0 Jan  1  1970 s link to a/b/s

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

os.link() raises on a directory, so it falls through to the fallback branch, which is the path test_sneaky_hardlink_fallback_deep covers.

Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
@encukou
encukou merged commit b38be2e into python:main Sep 10, 2026
51 checks passed
@encukou encukou added needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 10, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @StanFromIreland for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @StanFromIreland for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Sep 10, 2026

Copy link
Copy Markdown

GH-157261 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 10, 2026
@bedevere-app

bedevere-app Bot commented Sep 10, 2026

Copy link
Copy Markdown

GH-157262 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 10, 2026
encukou pushed a commit that referenced this pull request Sep 10, 2026
…k to a symlink (GH-157191)  (GH-157192)

(cherry picked from commit 480ea4a)
The backport to 3.13 and below includes a NEWS entry.

Co-authored-by: Stan Ulbrych <stan@python.org>
@bedevere-bot

Copy link
Copy Markdown

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

Hi! The buildbot PPC64LE Fedora Stable LTO + PGO 3.13 (tier-2) has failed when building commit b8f23e3.

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/#/builders/1494/builds/1358) and take a look at the build logs.
  4. Check if the failure is related to this commit (b8f23e3) 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/#/builders/1494/builds/1358

Failed tests:

  • test_smtpnet

Failed subtests:

  • test_explicit_connect_host_port_starttls - test.test_smtpnet.SmtpTest.test_explicit_connect_host_port_starttls
  • test_connect_host_port_starttls - test.test_smtpnet.SmtpTest.test_connect_host_port_starttls

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

==

Click to see traceback logs
Traceback (most recent call last):
  File "/var/lib/buildbot/worker/cstratak-fedora-stable-ppc64le/3.13.cstratak-fedora-stable-ppc64le.lto-pgo/build/Lib/test/test_smtpnet.py", line 54, in test_connect_host_port_starttls
    server = smtplib.SMTP(f'{self.testServer}:{self.remotePort}')
  File "/var/lib/buildbot/worker/cstratak-fedora-stable-ppc64le/3.13.cstratak-fedora-stable-ppc64le.lto-pgo/build/Lib/smtplib.py", line 266, in __init__
    raise SMTPConnectError(code, msg)
smtplib.SMTPConnectError: (421, b'4.4.5 Server busy, try again later. (smtp.gmail.com)\n4.4.5  For more information, go to\n4.4.5  https://support.google.com/a/answer/3221692 5b1f17b1804b1-49d1fb058c9sm1436945e9.0 - gsmtp')


Traceback (most recent call last):
  File "/var/lib/buildbot/worker/cstratak-fedora-stable-ppc64le/3.13.cstratak-fedora-stable-ppc64le.lto-pgo/build/Lib/test/test_smtpnet.py", line 92, in test_explicit_connect_host_port_starttls
    server.starttls(context=context)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/var/lib/buildbot/worker/cstratak-fedora-stable-ppc64le/3.13.cstratak-fedora-stable-ppc64le.lto-pgo/build/Lib/smtplib.py", line 783, in starttls
    self.ehlo_or_helo_if_needed()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/var/lib/buildbot/worker/cstratak-fedora-stable-ppc64le/3.13.cstratak-fedora-stable-ppc64le.lto-pgo/build/Lib/smtplib.py", line 620, in ehlo_or_helo_if_needed
    if not (200 <= self.ehlo()[0] <= 299):
                   ~~~~~~~~~^^
  File "/var/lib/buildbot/worker/cstratak-fedora-stable-ppc64le/3.13.cstratak-fedora-stable-ppc64le.lto-pgo/build/Lib/smtplib.py", line 461, in ehlo
    (code, msg) = self.getreply()
                  ~~~~~~~~~~~~~^^
  File "/var/lib/buildbot/worker/cstratak-fedora-stable-ppc64le/3.13.cstratak-fedora-stable-ppc64le.lto-pgo/build/Lib/smtplib.py", line 414, in getreply
    raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed

@StanFromIreland
StanFromIreland deleted the sneaky_hardlink_relocation branch September 10, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants