[issue43949] binascii.Error raised in smtplib when initial_response_ok=False

2021-05-06 Thread Pandu E POLUAN


Pandu E POLUAN  added the comment:

> I am using Magic Winmail Server2.4(build 0530) as a SMTP server, which 
> appears dont support initial_response, so I set initial_response_ok=False and 
> got this Error. currently I catch this error and ignore it to evade program 
> failed, it works fine. Is there better way to fix this problem?

I suggest either of:

(1) Contacting the makers of the software, to force Base64-encoding for "334 " 
replies, or

(2) If the text following "334 " is customizable, Base64-encode them yourself, 
then use the base64-encoded text as the customized "334 " response.

--

___
Python tracker 
<https://bugs.python.org/issue43949>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43949] binascii.Error raised in smtplib when initial_response_ok=False

2021-05-06 Thread Pandu E POLUAN


Pandu E POLUAN  added the comment:

A stronger case is the "Formal Syntax" on 
https://tools.ietf.org/html/rfc4954#page-13 :

>   continue-req= "334" SP [base64] CRLF
> ;; Intermediate response to the AUTH
> ;; command.
> ;; This non-terminal complies with
> ;; syntax defined by Reply-line [SMTP].

Nothing else besides base64 is allowed; after "334 " it MUST be either  
or .

--

___
Python tracker 
<https://bugs.python.org/issue43949>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43949] binascii.Error raised in smtplib when initial_response_ok=False

2021-05-06 Thread Pandu E POLUAN


Pandu E POLUAN  added the comment:

Technically, that is not the fault of smtplib.SMTP

The standard for SMTP AUTH specifies that characters following "334 " MUST be 
Base64 encoded.

See https://tools.ietf.org/html/rfc4954#page-4 , 3rd paragraph:

> A server challenge is sent as a 334 reply with the text part
> containing the [BASE64] encoded string supplied by the SASL
> mechanism.  This challenge MUST NOT contain any text other
> than the BASE64 encoded challenge.

Servers that send non-BASE64-encoded text after "334 " IMO is violating the 
standards.

--
nosy: +pepoluan

___
Python tracker 
<https://bugs.python.org/issue43949>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27820] Possible bug in smtplib when initial_response_ok=False

2021-03-09 Thread Pandu E POLUAN


Pandu E POLUAN  added the comment:

Hi Senthil,

You're right, it does need a guard. According to my knowledge there is no AUTH 
mechanism that will send more than 3 challenges; they should fail afterwards 
with 535 or similar. Servers that don't do that should be considered 
buggy/broken.

So I've pushed a commit to the GH PR that limits the challenge to 5 times, 
after which it will raise SMTPException. This will protect users of 
smtplib.SMTP from being trapped by a buggy/broken server.


Rgds,
--

--

___
Python tracker 
<https://bugs.python.org/issue27820>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27820] Possible bug in smtplib when initial_response_ok=False

2021-02-25 Thread Pandu E POLUAN


Pandu E POLUAN  added the comment:

PR available on GitHub and it's already more than one month since the PR was 
submitted, so I'm pinging this issue.

--

___
Python tracker 
<https://bugs.python.org/issue27820>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39232] asyncio crashes when tearing down the proactor event loop

2021-01-29 Thread Pandu E POLUAN


Change by Pandu E POLUAN :


--
nosy: +pepoluan

___
Python tracker 
<https://bugs.python.org/issue39232>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41868] SMTPLIB integrate or provide option to use "logging"

2021-01-11 Thread Pandu E POLUAN


Pandu E POLUAN  added the comment:

Will patching smtplib.SMTP._print_debug do?

You can subclass from smtplib.SMTP this way:

class MySMTPClient(smtplib.SMTP):
def __init__(self, *args, logger=None, **kwargs):
super().__init__(*args, **kwargs)
self.logger = logger
def _print_debug(self, *args):
if self.logger:
self.logger.debug(" ".join(args))
super()._print_debug(*args)

--
nosy: +pepoluan

___
Python tracker 
<https://bugs.python.org/issue41868>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27820] Possible bug in smtplib when initial_response_ok=False

2021-01-11 Thread Pandu E POLUAN


Change by Pandu E POLUAN :


--
components: +Tests

___
Python tracker 
<https://bugs.python.org/issue27820>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27820] Possible bug in smtplib when initial_response_ok=False

2021-01-05 Thread Pandu E POLUAN


Change by Pandu E POLUAN :


--
keywords: +patch
pull_requests: +22948
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24118

___
Python tracker 
<https://bugs.python.org/issue27820>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42498] smtplib is glitchy after receive server code 500

2021-01-05 Thread Pandu E POLUAN


Pandu E POLUAN  added the comment:

The "problem" is that smtplib.SMTP does the following, in essence:

1. Open connection to server
2. Send EHLO
3. Read server response

The PROXY injection causes a response from the server, but the response gets 
"cached" in the incoming TCP buffer. The injection script likely does not 
consume this buffer, resulting in Step 3 above reading this "cached" response. 

So from the point of view of smtplib.SMTP, the "503" message arrives _after_ 
EHLO is sent, while in actuality the "503" arrives before EHLO is sent.

I suggest rewriting the port forwarding script so that it consumes the response 
from the server first before transferring to smtplib.SMTP

--
nosy: +pepoluan

___
Python tracker 
<https://bugs.python.org/issue42498>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27820] Possible bug in smtplib when initial_response_ok=False

2021-01-04 Thread Pandu E POLUAN


Pandu E POLUAN  added the comment:

Okay, I finally figured out what's wrong.

This piece of code in `test_smtplib.py`:

if self.smtp_state == self.AUTH:
line = self._emptystring.join(self.received_lines)
print('Data:', repr(line), file=smtpd.DEBUGSTREAM)
self.received_lines = []
try:
self.auth_object(line)
except ResponseException as e:
self.smtp_state = self.COMMAND
self.push('%s %s' % (e.smtp_code, e.smtp_error))
return

The last "return" is over-indented.

--

___
Python tracker 
<https://bugs.python.org/issue27820>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27820] Possible bug in smtplib when initial_response_ok=False

2020-12-31 Thread Pandu E POLUAN


Pandu E POLUAN  added the comment:

I tried adding the code below to test_smtplib.py:

def testAUTH_LOGIN_initial_response_notok(self):
self.serv.add_feature("AUTH LOGIN")
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost',
timeout=support.LOOPBACK_TIMEOUT)
resp = smtp.login(sim_auth[0], sim_auth[1], initial_response_ok=False)
self.assertEqual(resp, (235, b'Authentication Succeeded'))
smtp.close()

and I ended up with:

==
ERROR: testAUTH_LOGIN_initial_response_notok (test.test_smtplib.SMTPSimTests)
--
Traceback (most recent call last):
  File "/home/pepoluan/projects/cpython/Lib/test/test_smtplib.py", line 1065, 
in testAUTH_LOGIN_initial_response_notok
resp = smtp.login(sim_auth[0], sim_auth[1], initial_response_ok=False)
  File "/home/pepoluan/projects/cpython/Lib/smtplib.py", line 738, in login
raise last_exception
  File "/home/pepoluan/projects/cpython/Lib/smtplib.py", line 727, in login
(code, resp) = self.auth(
  File "/home/pepoluan/projects/cpython/Lib/smtplib.py", line 650, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (451, b'Internal confusion')

--

--

___
Python tracker 
<https://bugs.python.org/issue27820>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27820] Possible bug in smtplib when initial_response_ok=False

2020-12-30 Thread Pandu E POLUAN


Pandu E POLUAN  added the comment:

I tried creating a PR, but for the life of me I couldn't wrap my head around 
how testAUTH_LOGIN is being performed (it's in Lib/test/test_smtplib.py)

All I know is, the test doesn't AT ALL test for situations where 
initial_response_ok=False. ALL tests are done with initial_response_ok=True.

There needs to be a whole set of additions to test_smtplib.py

--

___
Python tracker 
<https://bugs.python.org/issue27820>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27820] Possible bug in smtplib when initial_response_ok=False

2020-12-13 Thread Pandu E POLUAN


Pandu E POLUAN  added the comment:

This issue is still a bug for Python 3.6 and Python 3.8

I haven't checked on Python 3.7 and Python 3.9

--
versions: +Python 3.6, Python 3.8

___
Python tracker 
<https://bugs.python.org/issue27820>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27820] Possible bug in smtplib when initial_response_ok=False

2020-12-13 Thread Pandu E POLUAN


Pandu E POLUAN  added the comment:

Hi, I'm one of the maintainers of aio-libs/aiosmtpd.

This issue also bit me when trying to write unit tests for aio-libs/aiosmtpd 
AUTH implementation

But I partially disagree with Dario D'Amico's changes, specifically the 
suggested change in the auth_login() method.

According to draft-murchison-sasl-login-00.txt [1], the two challenges sent by 
the server SHOULD be ignored. The example in that document uses 
b"VXNlciBOYW1lAA==" and b"UGFzc3dvcmQA" (b64 of b"User Name\x00" and 
b"Password\x00", respectively), and this is what we have implemented in 
aio-libs/aiosmtpd.

Furthermore, the same document never indicated that username may be sent along 
with "AUTH LOGIN", so we haven't implemented that in aio-libs/aiosmtpd.

So rather than hardcoding the challenges to b"Username:" and b"Password:", a 
compliant SMTP client must instead _count_ the number of challenges it received.

I propose the following changes instead:

def auth(self, mechanism, authobject, *, initial_response_ok=True):
... snip ...
if initial_response is not None:
response = encode_base64(initial_response.encode('ascii'), eol='')
(code, resp) = self.docmd("AUTH", mechanism + " " + response)
self._challenge_count = 1
else:
(code, resp) = self.docmd("AUTH", mechanism)
self._challenge_count = 0
# If server responds with a challenge, send the response.
while code == 334:
self._challenge_count += 1
challenge = base64.decodebytes(resp)
... snip ...

... snip ...

def auth_login(self, challenge=None):
""" Authobject to use with LOGIN authentication. Requires self.user and
self.password to be set."""
if challenge is None or self._challenge_count < 2:
return self.user
else:
return self.password


[1] https://www.ietf.org/archive/id/draft-murchison-sasl-login-00.txt

--
nosy: +pepoluan

___
Python tracker 
<https://bugs.python.org/issue27820>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com