1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-12 10:45:38 +02:00
2756: POP3 is broken r=mergify[bot] a=nextgens

## What type of PR?

bug-fix

## What does this PR do?

Add a test to show it's broken, then fix it.

### Related issue(s)
- close #2754
- close #2757

## Prerequisites
Before we can consider review and merge, please make sure the following list is done and checked.
If an entry in not applicable, you can check it or remove it from the list.

- [ ] In case of feature or enhancement: documentation updated accordingly
- [ ] Unless it's docs or a minor change: add [changelog](https://mailu.io/master/contributors/workflow.html#changelog) entry file.


Co-authored-by: Florent Daigniere <nextgens@freenetproject.org>
This commit is contained in:
bors[bot] 2023-04-08 11:33:34 +00:00 committed by GitHub
commit 1b7de128c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 123 additions and 2 deletions

View File

@ -576,7 +576,9 @@ jobs:
issue: "${{ steps.changelog.outputs.issue }}" issue: "${{ steps.changelog.outputs.issue }}"
changelog: "${{ steps.changelog.outputs.content }}" changelog: "${{ steps.changelog.outputs.content }}"
run: | run: |
message="Changelog :mailbox: EOT=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
cat << "${EOT}" >> release_note.md
Changelog :mailbox:
--------- ---------
+ ${{ env.changelog }} + ${{ env.changelog }}
@ -589,7 +591,7 @@ jobs:
The main version X.Y (e.g. 1.9) will always reflect the latest version of the branch. To update your Mailu installation simply pull the latest images \`docker compose pull && docker compose up -d\`. The main version X.Y (e.g. 1.9) will always reflect the latest version of the branch. To update your Mailu installation simply pull the latest images \`docker compose pull && docker compose up -d\`.
The pinned version X.Y.Z (e.g. 1.9.1) is not updated. It is pinned to the commit that was used for creating this release. You can use a pinned version to make sure your Mailu installation is not suddenly updated when recreating containers. The pinned version allows the user to manually update. It also allows to go back to a previous pinned version. The pinned version X.Y.Z (e.g. 1.9.1) is not updated. It is pinned to the commit that was used for creating this release. You can use a pinned version to make sure your Mailu installation is not suddenly updated when recreating containers. The pinned version allows the user to manually update. It also allows to go back to a previous pinned version.
" && echo "$message" >> release_note.md ${EOT}
- name: Show release note - name: Show release note
shell: bash shell: bash
run: | run: |

View File

@ -122,6 +122,13 @@ service imap-login {
} }
} }
service pop3-login {
inet_listener pop3 {
port = 110
haproxy = yes
}
}
############### ###############
# Delivery # Delivery
############### ###############

View File

@ -53,3 +53,6 @@ lmtp unix - - n - - lmtp
anvil unix - - n - 1 anvil anvil unix - - n - 1 anvil
scache unix - - n - 1 scache scache unix - - n - 1 scache
postlog unix-dgram n - n - 1 postlogd postlog unix-dgram n - n - 1 postlogd
{# Ensure that the rendered file ends with a newline #}
{{- "\n" }}

View File

@ -0,0 +1,108 @@
#!/usr/bin/env python3
import imaplib
import poplib
import smtplib
import os
SERVER='localhost'
USERNAME='user@mailu.io'
PASSWORD='password'
def test_imap(server, username, password):
print(f'Authenticating to imaps://{username}:{password}@{server}:993/')
with imaplib.IMAP4_SSL(server) as conn:
conn.login(username, password)
conn.noop()
print('OK')
print(f'Authenticating to imaps://{username}:{password}@{server}:143/')
with imaplib.IMAP4(server) as conn:
conn.starttls()
conn.login(username, password)
conn.noop()
print('OK')
print(f'Authenticating to imap://{username}:{password}@{server}:143/')
try:
with imaplib.IMAP4(server) as conn:
conn.login(username, password)
print(f'Authenticating to imap://{username}:{password}@{server}:143/ worked without STARTTLS!')
os.exit(102)
except imaplib.IMAP4.error:
print('NOK - expected')
def test_pop3(server, username, password):
print(f'Authenticating to pop3s://{username}:{password}@{server}:995/')
conn = poplib.POP3_SSL(server)
conn.capa()
conn.user(username)
conn.pass_(password)
conn.close()
print('OK')
print(f'Authenticating to pop3s://{username}:{password}@{server}:110/')
conn = poplib.POP3(server)
conn.stls()
conn.capa()
conn.user(username)
conn.pass_(password)
conn.close()
print('OK')
print(f'Authenticating to pop3://{username}:{password}@{server}:110/')
try:
conn = poplib.POP3(server)
conn.capa()
conn.user(username)
conn.pass_(password)
conn.close()
print(f'Authenticating to pop3://{username}:{password}@{server}:110/ worked without STARTTLS!')
os.exit(103)
except poplib.error_proto:
print('NOK - expected')
def test_SMTP(server, username, password):
print(f'Authenticating to smtps://{username}:{password}@{server}:465/')
with smtplib.SMTP_SSL(server) as conn:
conn.ehlo()
conn.login(username, password)
print('OK')
print(f'Authenticating to smtps://{username}:{password}@{server}:587/')
with smtplib.SMTP(server, 587) as conn:
conn.ehlo()
conn.starttls()
conn.ehlo()
conn.login(username, password)
print('OK')
try:
print(f'Authenticating to smtp://{username}:{password}@{server}:587/')
with smtplib.SMTP(server, 587) as conn:
conn.ehlo()
conn.login(username, password)
print(f'Authenticating to smtp://{username}:{password}@{server}:587/ worked!')
os.exit(104)
except smtplib.SMTPNotSupportedError:
print('NOK - expected')
#port 25 should fail
try:
print(f'Authenticating to smtps://{username}:{password}@{server}:25/')
with smtplib.SMTP(server) as conn:
conn.ehlo()
conn.starttls()
conn.ehlo()
conn.login(username, password)
print(f'Authenticating to smtps://{username}:{password}@{server}:25/ worked!')
os.exit(105)
except smtplib.SMTPNotSupportedError:
print('NOK - expected')
try:
print(f'Authenticating to smtp://{username}:{password}@{server}:25/')
with smtplib.SMTP(server) as conn:
conn.ehlo()
conn.login(username, password)
print(f'Authenticating to smtp://{username}:{password}@{server}:25/ worked without STARTTLS!')
os.exit(106)
except smtplib.SMTPNotSupportedError:
print('NOK - expected')
if __name__ == '__main__':
test_imap(SERVER, USERNAME, PASSWORD)
test_pop3(SERVER, USERNAME, PASSWORD)
test_SMTP(SERVER, USERNAME, PASSWORD)

View File

@ -0,0 +1 @@
Fix a bug preventing POP3 from being usable