Skip to content

gh-127478: Enhancement to support FTP connection with NAT scenario #127477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

yugandhar2587
Copy link

@yugandhar2587 yugandhar2587 commented Dec 1, 2024

Some of new FTP servers are responding with 229 Entering Extended passive mode response when PASV command is sent.. Because of this sendcmd('PASV') is sending error though it's a accepted response. Tested with filezilla manually where it's accepting the same. So we need to make changes in ftplib to accept & parse Extended mode with 'PASV' command. Please help to review and merge.

Accept 229 Extended passive mode error as acceptible ouput with PASV command
@bedevere-app
Copy link

bedevere-app bot commented Dec 1, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@yugandhar2587 yugandhar2587 changed the title Accept 229 Extended passive mode error as acceptible ouput with PASV command gh-127478: Accept 229 Extended passive mode error as acceptible ouput with PASV command Dec 1, 2024
Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

Thanks for contributing! Could you add a test to test_ftplib?

@@ -0,0 +1 @@
Accept 229 response as valid PASV command output
Copy link
Member

Choose a reason for hiding this comment

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

Let's be more clear; people reading the changelog don't have the context.

Suggested change
Accept 229 response as valid PASV command output
Support "229 Entering Extended Passive Mode" response in :meth:`ftplib.FTP.sendcmd`.

Lib/ftplib.py Outdated
host = self.sock.getpeername()[0]
except error_reply as resp:
resp = str(resp)
if resp[:3] == '229':
Copy link
Member

Choose a reason for hiding this comment

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

This is sort of breaking convention for the file, but it's also more correct. Let me know what you think.

Suggested change
if resp[:3] == '229':
if resp.startswith('229'):

Copy link
Author

Choose a reason for hiding this comment

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

We removed '229' check at all as per later suggestions. This is not applicable. Thanks.

@ZeroIntensity ZeroIntensity requested a review from picnixz December 1, 2024 14:28
@picnixz
Copy link
Member

picnixz commented Dec 1, 2024

As I said on the issue, I'd like to know whether the response code 229 is accepted by the corresponding RFC or not and if we want to strictly follow the RFC or not. I'll delay my review on that matter until then.

@yugandhar2587 yugandhar2587 changed the title gh-127478: Accept 229 Extended passive mode error as acceptible ouput with PASV command gh-127478: Enhancement to support FTP connection with NAT scenario Dec 1, 2024
@yugandhar2587 yugandhar2587 requested a review from picnixz December 1, 2024 18:48
@yugandhar2587 yugandhar2587 requested a review from picnixz December 2, 2024 01:31
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

LTGM modulo a better NEWS if needed (it's 2:42 AM now so I'm going to sleep).

@@ -0,0 +1 @@
Enhancement to support FTP connection with NAT scenario.
Copy link
Member

Choose a reason for hiding this comment

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

I'll try to come up with a better NEWS entry here for tomorrow but otherwise thank you.

@python-cla-bot
Copy link

python-cla-bot bot commented Apr 18, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

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.

3 participants