~dricottone/huttese-apk

ref: 9c2c40422da91027c5de63b7fca82578d8945f1c huttese-apk/sr.ht/py3-aiosmtpd/0001-Make-LHLO-behave-like-EHLO.patch -rw-r--r-- 2.0 KiB
9c2c4042 — Drew DeVault Re-introduce packages from community 3 years ago
                                                                                
5212aa81 Drew DeVault
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 0efc8e3404050331c033cc4388a9855f5508dc7b Mon Sep 17 00:00:00 2001
From: Simon Ser <contact@emersion.fr>
Date: Mon, 16 Nov 2020 14:19:31 +0100
Subject: [PATCH] Make LHLO behave like EHLO

The current logic makes LHLO behave like the legacy HELO. However the
RFC says:

> The LHLO command has identical semantics to the EHLO command of ESMTP.

Clients connecting to the LMTP server expect extensions such as 8BITMIME
to be advertised. However aiosmtpd won't send any extension string.

Fix this by making LHLO an alias for EHLO instead of HELO.

[1]: https://tools.ietf.org/html/rfc2033#section-4.1
---
 aiosmtpd/lmtp.py            |  2 +-
 aiosmtpd/tests/test_lmtp.py | 10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/aiosmtpd/lmtp.py b/aiosmtpd/lmtp.py
index 53ed087364d2..61e7768f4474 100644
--- a/aiosmtpd/lmtp.py
+++ b/aiosmtpd/lmtp.py
@@ -7,7 +7,7 @@ class LMTP(SMTP):
     @syntax('LHLO hostname')
     async def smtp_LHLO(self, arg):
         """The LMTP greeting, used instead of HELO/EHLO."""
-        await super().smtp_HELO(arg)
+        await super().smtp_EHLO(arg)
         self.show_smtp_greeting = False
 
     async def smtp_HELO(self, arg):
diff --git a/aiosmtpd/tests/test_lmtp.py b/aiosmtpd/tests/test_lmtp.py
index a3855e45b2b0..d32a394e756b 100644
--- a/aiosmtpd/tests/test_lmtp.py
+++ b/aiosmtpd/tests/test_lmtp.py
@@ -25,7 +25,15 @@ class TestLMTP(unittest.TestCase):
         with SMTP(*self.address) as client:
             code, response = client.docmd('LHLO', 'example.com')
             self.assertEqual(code, 250)
-            self.assertEqual(response, bytes(socket.getfqdn(), 'utf-8'))
+            lines = response.splitlines()
+            expecteds = (
+                bytes(socket.getfqdn(), 'utf-8'),
+                b'SIZE 33554432',
+                b'8BITMIME',
+                b'HELP',
+            )
+            for actual, expected in zip(lines, expecteds):
+                self.assertEqual(actual, expected)
 
     def test_helo(self):
         # HELO and EHLO are not valid LMTP commands.
-- 
2.29.2