Skip to content

Commit 4e480c4

Browse files
committed
get delivery working
1 parent 3700cc5 commit 4e480c4

8 files changed

Lines changed: 29 additions & 17 deletions

File tree

chatmaild/src/chatmaild/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ def __init__(self, inipath, params):
9393
self.tls_key_path = f"/var/lib/acme/live/{self.mail_domain}/privkey"
9494

9595
# deprecated option
96-
mbdir = params.get("mailboxes_dir", f"/home/vmail/mail/{self.mail_domain}")
96+
mbdir = params.get(
97+
"mailboxes_dir", f"/home/vmail/mail/{self.mail_domain_deliverable}"
98+
)
9799
self.mailboxes_dir = Path(mbdir.strip())
98100

99101
# old unused option (except for first migration from sqlite to maildir store)

chatmaild/src/chatmaild/doveauth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ def handle_lookup(self, parts):
108108
if namespace == "shared":
109109
if type == "userdb":
110110
user = args[0]
111-
if user.endswith(f"@{config.mail_domain}"):
111+
if user.endswith(f"@{config.mail_domain_deliverable}"):
112112
res = self.lookup_userdb(user)
113113
if res:
114114
reply_command = "O"
115115
else:
116116
reply_command = "N"
117117
elif type == "passdb":
118118
user = args[1]
119-
if user.endswith(f"@{config.mail_domain}"):
119+
if user.endswith(f"@{config.mail_domain_deliverable}"):
120120
res = self.lookup_passdb(user, cleartext_password=args[0])
121121
if res:
122122
reply_command = "O"

chatmaild/src/chatmaild/tests/test_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def test_read_config_basic(example_config):
1313
example_config = read_config(inipath)
1414
assert example_config.max_user_send_per_minute == 37
1515
assert example_config.mail_domain == "chat.example.org"
16+
assert example_config.mail_domain_deliverable == "chat.example.org"
1617

1718

1819
def test_read_config_basic_using_defaults(tmp_path, maildomain):

chatmaild/src/chatmaild/tests/test_doveauth.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,20 @@ def test_invalid_username_length(example_config):
4444
config.username_min_length = 6
4545
config.username_max_length = 10
4646
password = create_newemail_dict(config)["password"]
47-
assert not is_allowed_to_create(config, f"a1234@{config.mail_domain}", password)
48-
assert is_allowed_to_create(config, f"012345@{config.mail_domain}", password)
49-
assert is_allowed_to_create(config, f"0123456@{config.mail_domain}", password)
50-
assert is_allowed_to_create(config, f"0123456789@{config.mail_domain}", password)
5147
assert not is_allowed_to_create(
52-
config, f"0123456789x@{config.mail_domain}", password
48+
config, f"a1234@{config.mail_domain_deliverable}", password
49+
)
50+
assert is_allowed_to_create(
51+
config, f"012345@{config.mail_domain_deliverable}", password
52+
)
53+
assert is_allowed_to_create(
54+
config, f"0123456@{config.mail_domain_deliverable}", password
55+
)
56+
assert is_allowed_to_create(
57+
config, f"0123456789@{config.mail_domain_deliverable}", password
58+
)
59+
assert not is_allowed_to_create(
60+
config, f"0123456789x@{config.mail_domain_deliverable}", password
5361
)
5462

5563

@@ -124,7 +132,7 @@ def test_invalid_localpart_characters(make_config):
124132
"""Test that is_allowed_to_create rejects localparts with invalid characters."""
125133
config = make_config("chat.example.org", {"username_min_length": "3"})
126134
password = "zequ0Aimuchoodaechik"
127-
domain = config.mail_domain
135+
domain = config.mail_domain_deliverable
128136

129137
# valid localparts
130138
assert is_allowed_to_create(config, f"abc123@{domain}", password)

chatmaild/src/chatmaild/tests/test_newmail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def test_print_new_account(capsys, monkeypatch, maildomain, tmpdir, example_conf
4949
assert lines[0] == "Content-Type: application/json"
5050
assert not lines[1]
5151
dic = json.loads(lines[2])
52-
assert dic["email"].endswith(f"@{example_config.mail_domain}")
52+
assert dic["email"].endswith(f"@{example_config.mail_domain_deliverable}")
5353
assert len(dic["password"]) >= 10
5454
# default tls_cert=acme should not include dclogin_url
5555
assert "dclogin_url" not in dic

cmdeploy/src/cmdeploy/deployers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ class ChatmailDeployer(Deployer):
460460

461461
def __init__(self, config):
462462
self.config = config
463-
self.mail_domain = config.mail_domain
463+
self.mail_domain_deliverable = config.mail_domain_deliverable
464464

465465
def install(self):
466466
files.put(
@@ -500,7 +500,7 @@ def configure(self):
500500
server.shell(
501501
name="Setup /etc/mailname",
502502
commands=[
503-
f"echo {self.mail_domain} >/etc/mailname; chmod 644 /etc/mailname"
503+
f"echo {self.mail_domain_deliverable} >/etc/mailname; chmod 644 /etc/mailname"
504504
],
505505
)
506506

@@ -563,6 +563,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool, website_only: bool) -
563563
config = read_config(config_path)
564564
check_config(config)
565565
mail_domain = config.mail_domain
566+
mail_domain_deliverable = config.mail_domain_deliverable
566567

567568
if website_only:
568569
Deployment().perform_stages([WebsiteDeployer(config)])
@@ -635,7 +636,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool, website_only: bool) -
635636
WebsiteDeployer(config),
636637
ChatmailVenvDeployer(config),
637638
MtastsDeployer(),
638-
OpendkimDeployer(mail_domain),
639+
OpendkimDeployer(mail_domain_deliverable),
639640
# Dovecot should be started before Postfix
640641
# because it creates authentication socket
641642
# required by Postfix.

cmdeploy/src/cmdeploy/dovecot/dovecot.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ service imap {
4040
process_limit = 50000
4141
}
4242

43-
mail_server_admin = mailto:root@{{ config.mail_domain }}
43+
mail_server_admin = mailto:root@{{ config.mail_domain_deliverable }}
4444
mail_server_comment = Chatmail server
4545

4646
# `zlib` enables compressing messages stored in the maildir.

cmdeploy/src/cmdeploy/opendkim/deployer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
class OpendkimDeployer(Deployer):
1313
required_users = [("opendkim", None, ["opendkim"])]
1414

15-
def __init__(self, mail_domain):
16-
self.mail_domain = mail_domain
15+
def __init__(self, mail_domain_deliverable):
16+
self.mail_domain_deliverable = mail_domain_deliverable
1717

1818
def install(self):
1919
apt.packages(
@@ -22,7 +22,7 @@ def install(self):
2222
)
2323

2424
def configure(self):
25-
domain = self.mail_domain
25+
domain = self.mail_domain_deliverable
2626
dkim_selector = "opendkim"
2727
"""Configures OpenDKIM"""
2828
need_restart = False

0 commit comments

Comments
 (0)