-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
ftplib cannot connect to server which has banner / welcome message configured #123911
Comments
The server is expected to reply using standard reply codes as defined by RFC 959 and should format its message accordingly. The welcome/banner message must in particular send first the reply code and the whatever is after (see §4.2 of the RFC and §6 for the state automaton). |
I see your point and tend to accept, but I still curious, what code should be used in the welcome message? |
Ah sorry §6. I thought it had more details. Actually, the RFC is poorly documented so my bad for this. I think the server should send something like TLS/SSL1
This should do the trick. If it doesn't, I think we have a doc issue. EDIT: The RFC mentions in §5.4:
Footnotes
|
Good news, the code is needed only in the first and last line, so between them can be anything (except any code in the first 3 position). |
AFAIU, 220 is used for greeting as well (emphasis mine):
I can't find a specific reply code to use for the welcome message only (one that is not 220). |
I'll close this ticket as no issue, and I'll suggest to the server's owners to format their welcome message accordingly.
Thanks @picnixz for your time and help! |
I incorrectly assumed that this one would only be used as a reply of the help command actually. But if it can be used as the initial greeting message, that should be fine. |
I've tried with a test client-server, and it also accepts two 220 messages. First is the welcome message, while the second is the default "220 Service ready for new user", that I couldn't modify. |
Bug report
Bug description:
Scenario:
Setup: There is a running FTP server configured to send welcome message to user, like:
Hello, this is my FTP server, please login
Test: Connect to this FTP server and validate the login banner.
Unexpected result:
Based on code https://github.com/python/cpython/blame/main/Lib/ftplib.py#L162 the welcome message is handled the same way as any FTP response, but there is no restriction I could find related to banner.
It means if it's not starting with number 1-3 then error is raised. Moreover if the 4th character is not a '-', then only 1 line is read.
My suggestion is to simply read out the buffer in connect() like:
CPython versions tested on:
3.9, 3.12
Operating systems tested on:
Linux, Windows
The text was updated successfully, but these errors were encountered: