mirror of
https://github.com/chatmail/relay.git
synced 2026-05-12 00:54:37 +00:00
Compare commits
1 Commits
migration-
...
link2xt/do
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
569a043065 |
33
.github/workflows/docs-preview.yaml
vendored
33
.github/workflows/docs-preview.yaml
vendored
@@ -11,9 +11,6 @@ jobs:
|
|||||||
scripts:
|
scripts:
|
||||||
name: build
|
name: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment:
|
|
||||||
name: 'staging.chatmail.at/doc/relay/'
|
|
||||||
url: https://staging.chatmail.at/doc/relay/${{ steps.prepare.outputs.prid }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
@@ -47,6 +44,36 @@ jobs:
|
|||||||
chmod 600 "$HOME/.ssh/key"
|
chmod 600 "$HOME/.ssh/key"
|
||||||
rsync -rILvh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/doc/build/ "${{ secrets.USERNAME }}@chatmail.at:/var/www/html/staging.chatmail.at/doc/relay/${{ steps.prepare.outputs.prid }}/"
|
rsync -rILvh -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" $GITHUB_WORKSPACE/doc/build/ "${{ secrets.USERNAME }}@chatmail.at:/var/www/html/staging.chatmail.at/doc/relay/${{ steps.prepare.outputs.prid }}/"
|
||||||
|
|
||||||
|
- name: "Post links to details"
|
||||||
|
id: details
|
||||||
|
if: steps.prepare.outputs.uploadtoserver
|
||||||
|
run: |
|
||||||
|
# URLs for API connection and uploads
|
||||||
|
export GITHUB_API_URL="https://api.github.com/repos/chatmail/relay/statuses/${{ github.event.after }}"
|
||||||
|
export PREVIEW_LINK="https://staging.chatmail.at/doc/relay/${{ steps.prepare.outputs.prid }}/"
|
||||||
|
export STATUS_DATA="{\"state\": \"success\", \
|
||||||
|
\"description\": \"Preview the changed documentation here:\", \
|
||||||
|
\"context\": \"Documentation Preview\", \
|
||||||
|
\"target_url\": \"${PREVIEW_LINK}\"}"
|
||||||
|
curl -X POST --header "Accept: application/vnd.github+json" --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --url "$GITHUB_API_URL" --header "content-type: application/json" --data "$STATUS_DATA"
|
||||||
|
|
||||||
|
#check if comment already exists, if not post it
|
||||||
|
export GITHUB_API_URL="https://api.github.com/repos/chatmail/relay/issues/${{ steps.prepare.outputs.prid }}/comments"
|
||||||
|
export RESPONSE=$(curl -L --header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" --url "$GITHUB_API_URL" --header "content-type: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28")
|
||||||
|
echo $RESPONSE > response
|
||||||
|
grep -v '"Check out the page preview at https://staging.chatmail.at/doc/relay' response && echo "comment=true" >> $GITHUB_OUTPUT || true
|
||||||
|
- name: "Post link to comments"
|
||||||
|
if: steps.details.outputs.comment
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
github.rest.issues.createComment({
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
body: "Check out the page preview at https://staging.chatmail.at/doc/relay/${{ steps.prepare.outputs.prid }}/"
|
||||||
|
})
|
||||||
|
|
||||||
- name: check links
|
- name: check links
|
||||||
working-directory: doc
|
working-directory: doc
|
||||||
run: sphinx-build --builder linkcheck source build
|
run: sphinx-build --builder linkcheck source build
|
||||||
|
|||||||
3
.github/workflows/docs.yaml
vendored
3
.github/workflows/docs.yaml
vendored
@@ -14,9 +14,6 @@ jobs:
|
|||||||
scripts:
|
scripts:
|
||||||
name: build
|
name: build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment:
|
|
||||||
name: 'chatmail.at/doc/relay/'
|
|
||||||
url: https://chatmail.at/doc/relay/
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ jobs:
|
|||||||
name: deploy on staging-ipv4.testrun.org, and run tests
|
name: deploy on staging-ipv4.testrun.org, and run tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
environment:
|
|
||||||
name: staging-ipv4.testrun.org
|
|
||||||
url: https://staging-ipv4.testrun.org/
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ci-ipv4-${{ github.workflow }}-${{ github.ref }}
|
group: ci-ipv4-${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: ${{ !contains(github.ref, '$GITHUB_REF') }}
|
cancel-in-progress: ${{ !contains(github.ref, '$GITHUB_REF') }}
|
||||||
|
|||||||
6
.github/workflows/test-and-deploy.yaml
vendored
6
.github/workflows/test-and-deploy.yaml
vendored
@@ -16,9 +16,6 @@ jobs:
|
|||||||
name: deploy on staging2.testrun.org, and run tests
|
name: deploy on staging2.testrun.org, and run tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
environment:
|
|
||||||
name: staging2.testrun.org
|
|
||||||
url: https://staging2.testrun.org/
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ci-${{ github.workflow }}-${{ github.ref }}
|
group: ci-${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: ${{ !contains(github.ref, '$GITHUB_REF') }}
|
cancel-in-progress: ${{ !contains(github.ref, '$GITHUB_REF') }}
|
||||||
@@ -73,9 +70,6 @@ jobs:
|
|||||||
rsync -avz dkimkeys-restore/dkimkeys root@staging2.testrun.org:/etc/ || true
|
rsync -avz dkimkeys-restore/dkimkeys root@staging2.testrun.org:/etc/ || true
|
||||||
ssh -o StrictHostKeyChecking=accept-new -v root@staging2.testrun.org chown root:root -R /var/lib/acme || true
|
ssh -o StrictHostKeyChecking=accept-new -v root@staging2.testrun.org chown root:root -R /var/lib/acme || true
|
||||||
|
|
||||||
- name: add hpk42 key to staging server
|
|
||||||
run: ssh root@staging2.testrun.org 'curl -s https://github.com/hpk42.keys >> .ssh/authorized_keys'
|
|
||||||
|
|
||||||
- name: run deploy-chatmail offline tests
|
- name: run deploy-chatmail offline tests
|
||||||
run: pytest --pyargs cmdeploy
|
run: pytest --pyargs cmdeploy
|
||||||
|
|
||||||
|
|||||||
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,15 +1,6 @@
|
|||||||
# Changelog for chatmail deployment
|
# Changelog for chatmail deployment
|
||||||
|
|
||||||
## 1.8.0 2025-12-12
|
## untagged
|
||||||
|
|
||||||
- Add imap_compress option to chatmail.ini
|
|
||||||
([#760](https://github.com/chatmail/relay/pull/760))
|
|
||||||
|
|
||||||
- Remove echobot from relays
|
|
||||||
([#753](https://github.com/chatmail/relay/pull/753))
|
|
||||||
|
|
||||||
- Fix `cmdeploy webdev`
|
|
||||||
([#743](https://github.com/chatmail/relay/pull/743))
|
|
||||||
|
|
||||||
- Add robots.txt to exclude all web crawlers
|
- Add robots.txt to exclude all web crawlers
|
||||||
([#732](https://github.com/chatmail/relay/pull/732))
|
([#732](https://github.com/chatmail/relay/pull/732))
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
# Contributing to the chatmail relay
|
|
||||||
|
|
||||||
Commit messages follow the [Conventional Commits] notation.
|
|
||||||
We use [git-cliff] to generate the changelog from commit messages before the release.
|
|
||||||
|
|
||||||
[Conventional Commits]: https://www.conventionalcommits.org/
|
|
||||||
[git-cliff]: https://git-cliff.org/
|
|
||||||
15
RELEASE.md
15
RELEASE.md
@@ -1,15 +0,0 @@
|
|||||||
# Releasing a new version of chatmail relay
|
|
||||||
|
|
||||||
For example, to release version 1.9.0 of chatmail relay, do the following steps.
|
|
||||||
|
|
||||||
1. Update the changelog: `git cliff --unreleased --tag 1.9.0 --prepend CHANGELOG.md` or `git cliff -u -t 1.9.0 -p CHANGELOG.md`.
|
|
||||||
|
|
||||||
2. Open the changelog in the editor, edit it if required.
|
|
||||||
|
|
||||||
3. Commit the changes to the changelog with a commit message `chore(release): prepare for 1.9.0`.
|
|
||||||
|
|
||||||
3. Tag the release: `git tag --annotate 1.9.0`.
|
|
||||||
|
|
||||||
4. Push the release tag: `git push origin 1.9.0`.
|
|
||||||
|
|
||||||
5. Create a GitHub release: `gh release create 1.9.0`.
|
|
||||||
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "chatmaild"
|
name = "chatmaild"
|
||||||
version = "0.3"
|
version = "0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aiosmtpd",
|
"aiosmtpd",
|
||||||
"iniconfig",
|
"iniconfig",
|
||||||
@@ -25,6 +25,7 @@ where = ['src']
|
|||||||
doveauth = "chatmaild.doveauth:main"
|
doveauth = "chatmaild.doveauth:main"
|
||||||
chatmail-metadata = "chatmaild.metadata:main"
|
chatmail-metadata = "chatmaild.metadata:main"
|
||||||
filtermail = "chatmaild.filtermail:main"
|
filtermail = "chatmaild.filtermail:main"
|
||||||
|
echobot = "chatmaild.echo:main"
|
||||||
chatmail-metrics = "chatmaild.metrics:main"
|
chatmail-metrics = "chatmaild.metrics:main"
|
||||||
chatmail-expire = "chatmaild.expire:main"
|
chatmail-expire = "chatmaild.expire:main"
|
||||||
chatmail-fsreport = "chatmaild.fsreport:main"
|
chatmail-fsreport = "chatmaild.fsreport:main"
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import iniconfig
|
|||||||
|
|
||||||
from chatmaild.user import User
|
from chatmaild.user import User
|
||||||
|
|
||||||
|
echobot_password_path = Path("/run/echobot/password")
|
||||||
|
|
||||||
|
|
||||||
def read_config(inipath):
|
def read_config(inipath):
|
||||||
assert Path(inipath).exists(), inipath
|
assert Path(inipath).exists(), inipath
|
||||||
@@ -44,7 +46,6 @@ class Config:
|
|||||||
self.disable_ipv6 = params.get("disable_ipv6", "false").lower() == "true"
|
self.disable_ipv6 = params.get("disable_ipv6", "false").lower() == "true"
|
||||||
self.acme_email = params.get("acme_email", "")
|
self.acme_email = params.get("acme_email", "")
|
||||||
self.imap_rawlog = params.get("imap_rawlog", "false").lower() == "true"
|
self.imap_rawlog = params.get("imap_rawlog", "false").lower() == "true"
|
||||||
self.imap_compress = params.get("imap_compress", "false").lower() == "true"
|
|
||||||
if "iroh_relay" not in params:
|
if "iroh_relay" not in params:
|
||||||
self.iroh_relay = "https://" + params["mail_domain"]
|
self.iroh_relay = "https://" + params["mail_domain"]
|
||||||
self.enable_iroh_relay = True
|
self.enable_iroh_relay = True
|
||||||
@@ -71,7 +72,10 @@ class Config:
|
|||||||
raise ValueError(f"invalid address {addr!r}")
|
raise ValueError(f"invalid address {addr!r}")
|
||||||
|
|
||||||
maildir = self.mailboxes_dir.joinpath(addr)
|
maildir = self.mailboxes_dir.joinpath(addr)
|
||||||
password_path = maildir.joinpath("password")
|
if addr.startswith("echo@"):
|
||||||
|
password_path = echobot_password_path
|
||||||
|
else:
|
||||||
|
password_path = maildir.joinpath("password")
|
||||||
|
|
||||||
return User(maildir, addr, password_path, uid="vmail", gid="vmail")
|
return User(maildir, addr, password_path, uid="vmail", gid="vmail")
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,10 @@ def is_allowed_to_create(config: Config, user, cleartext_password) -> bool:
|
|||||||
return False
|
return False
|
||||||
localpart, domain = parts
|
localpart, domain = parts
|
||||||
|
|
||||||
|
if localpart == "echo":
|
||||||
|
# echobot account should not be created in the database
|
||||||
|
return False
|
||||||
|
|
||||||
if (
|
if (
|
||||||
len(localpart) > config.username_max_length
|
len(localpart) > config.username_max_length
|
||||||
or len(localpart) < config.username_min_length
|
or len(localpart) < config.username_min_length
|
||||||
|
|||||||
109
chatmaild/src/chatmaild/echo.py
Normal file
109
chatmaild/src/chatmaild/echo.py
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Advanced echo bot example.
|
||||||
|
|
||||||
|
it will echo back any message that has non-empty text and also supports the /help command.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from deltachat_rpc_client import Bot, DeltaChat, EventType, Rpc, events
|
||||||
|
|
||||||
|
from chatmaild.config import echobot_password_path, read_config
|
||||||
|
from chatmaild.doveauth import encrypt_password
|
||||||
|
from chatmaild.newemail import create_newemail_dict
|
||||||
|
|
||||||
|
hooks = events.HookCollection()
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.on(events.RawEvent)
|
||||||
|
def log_event(event):
|
||||||
|
if event.kind == EventType.INFO:
|
||||||
|
logging.info(event.msg)
|
||||||
|
elif event.kind == EventType.WARNING:
|
||||||
|
logging.warning(event.msg)
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.on(events.RawEvent(EventType.ERROR))
|
||||||
|
def log_error(event):
|
||||||
|
logging.error("%s", event.msg)
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.on(events.MemberListChanged)
|
||||||
|
def on_memberlist_changed(event):
|
||||||
|
logging.info(
|
||||||
|
"member %s was %s", event.member, "added" if event.member_added else "removed"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.on(events.GroupImageChanged)
|
||||||
|
def on_group_image_changed(event):
|
||||||
|
logging.info("group image %s", "deleted" if event.image_deleted else "changed")
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.on(events.GroupNameChanged)
|
||||||
|
def on_group_name_changed(event):
|
||||||
|
logging.info(f"group name changed, old name: {event.old_name}")
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.on(events.NewMessage(func=lambda e: not e.command))
|
||||||
|
def echo(event):
|
||||||
|
snapshot = event.message_snapshot
|
||||||
|
if snapshot.is_info:
|
||||||
|
# Ignore info messages
|
||||||
|
return
|
||||||
|
if snapshot.text or snapshot.file:
|
||||||
|
snapshot.chat.send_message(text=snapshot.text, file=snapshot.file)
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.on(events.NewMessage(command="/help"))
|
||||||
|
def help_command(event):
|
||||||
|
snapshot = event.message_snapshot
|
||||||
|
snapshot.chat.send_text("Send me any message and I will echo it back")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
path = os.environ.get("PATH")
|
||||||
|
venv_path = sys.argv[0].strip("echobot")
|
||||||
|
os.environ["PATH"] = path + ":" + venv_path
|
||||||
|
with Rpc() as rpc:
|
||||||
|
deltachat = DeltaChat(rpc)
|
||||||
|
system_info = deltachat.get_system_info()
|
||||||
|
logging.info(f"Running deltachat core {system_info.deltachat_core_version}")
|
||||||
|
|
||||||
|
accounts = deltachat.get_all_accounts()
|
||||||
|
account = accounts[0] if accounts else deltachat.add_account()
|
||||||
|
|
||||||
|
bot = Bot(account, hooks)
|
||||||
|
|
||||||
|
config = read_config(sys.argv[1])
|
||||||
|
addr = "echo@" + config.mail_domain
|
||||||
|
|
||||||
|
# Create password file
|
||||||
|
if bot.is_configured():
|
||||||
|
password = bot.account.get_config("mail_pw")
|
||||||
|
else:
|
||||||
|
password = create_newemail_dict(config)["password"]
|
||||||
|
|
||||||
|
echobot_password_path.write_text(encrypt_password(password))
|
||||||
|
# Give the user which doveauth runs as access to the password file.
|
||||||
|
subprocess.check_call(
|
||||||
|
["/usr/bin/setfacl", "-m", "user:vmail:r", echobot_password_path],
|
||||||
|
)
|
||||||
|
|
||||||
|
if not bot.is_configured():
|
||||||
|
bot.configure(addr, password)
|
||||||
|
|
||||||
|
# write invite link to working directory
|
||||||
|
invitelink = bot.account.get_qr_code()
|
||||||
|
Path("invite-link.txt").write_text(invitelink)
|
||||||
|
|
||||||
|
bot.run_forever()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -43,9 +43,9 @@ passthrough_senders =
|
|||||||
|
|
||||||
# list of e-mail recipients for which to accept outbound un-encrypted mails
|
# list of e-mail recipients for which to accept outbound un-encrypted mails
|
||||||
# (space-separated, item may start with "@" to whitelist whole recipient domains)
|
# (space-separated, item may start with "@" to whitelist whole recipient domains)
|
||||||
passthrough_recipients =
|
passthrough_recipients = echo@{mail_domain}
|
||||||
|
|
||||||
# path to www directory - documented here: https://chatmail.at/doc/relay/getting_started.html#custom-web-pages
|
# path to www directory - documented here: https://github.com/chatmail/relay/#custom-web-pages
|
||||||
#www_folder = www
|
#www_folder = www
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -99,12 +99,6 @@ acme_email =
|
|||||||
# so use this option with caution on production servers.
|
# so use this option with caution on production servers.
|
||||||
imap_rawlog = false
|
imap_rawlog = false
|
||||||
|
|
||||||
# set to true if you want to enable the IMAP COMPRESS Extension,
|
|
||||||
# which allows IMAP connections to be efficiently compressed.
|
|
||||||
# WARNING: Enabling this makes it impossible to hibernate IMAP
|
|
||||||
# processes which will result in much higher memory/RAM usage.
|
|
||||||
imap_compress = false
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Privacy Policy
|
# Privacy Policy
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ class LastLoginDictProxy(DictProxy):
|
|||||||
keyname = parts[1].split("/")
|
keyname = parts[1].split("/")
|
||||||
value = parts[2] if len(parts) > 2 else ""
|
value = parts[2] if len(parts) > 2 else ""
|
||||||
if keyname[0] == "shared" and keyname[1] == "last-login":
|
if keyname[0] == "shared" and keyname[1] == "last-login":
|
||||||
|
if addr.startswith("echo@"):
|
||||||
|
return True
|
||||||
addr = keyname[2]
|
addr = keyname[2]
|
||||||
timestamp = int(value)
|
timestamp = int(value)
|
||||||
user = self.config.get_user(addr)
|
user = self.config.get_user(addr)
|
||||||
|
|||||||
@@ -36,3 +36,29 @@ def test_handle_dovecot_request_last_login(testaddr, example_config):
|
|||||||
res = dictproxy.handle_dovecot_request(msg, dictproxy_transactions)
|
res = dictproxy.handle_dovecot_request(msg, dictproxy_transactions)
|
||||||
assert res == "O\n"
|
assert res == "O\n"
|
||||||
assert len(dictproxy_transactions) == 0
|
assert len(dictproxy_transactions) == 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_handle_dovecot_request_last_login_echobot(example_config):
|
||||||
|
dictproxy = LastLoginDictProxy(config=example_config)
|
||||||
|
|
||||||
|
authproxy = AuthDictProxy(config=example_config)
|
||||||
|
testaddr = f"echo@{example_config.mail_domain}"
|
||||||
|
authproxy.lookup_passdb(testaddr, "ignore")
|
||||||
|
user = dictproxy.config.get_user(testaddr)
|
||||||
|
|
||||||
|
transactions = {}
|
||||||
|
|
||||||
|
# set last-login info for user
|
||||||
|
tx = "1111"
|
||||||
|
msg = f"B{tx}\t{testaddr}"
|
||||||
|
res = dictproxy.handle_dovecot_request(msg, transactions)
|
||||||
|
assert not res
|
||||||
|
assert transactions == {tx: dict(addr=testaddr, res="O\n")}
|
||||||
|
|
||||||
|
timestamp = int(time.time())
|
||||||
|
msg = f"S{tx}\tshared/last-login/{testaddr}\t{timestamp}"
|
||||||
|
res = dictproxy.handle_dovecot_request(msg, transactions)
|
||||||
|
assert not res
|
||||||
|
assert len(transactions) == 1
|
||||||
|
read_timestamp = user.get_last_login_timestamp()
|
||||||
|
assert read_timestamp is None
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class User:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def can_track(self):
|
def can_track(self):
|
||||||
return "@" in self.addr
|
return "@" in self.addr and not self.addr.startswith("echo@")
|
||||||
|
|
||||||
def get_userdb_dict(self):
|
def get_userdb_dict(self):
|
||||||
"""Return a non-empty dovecot 'userdb' style dict
|
"""Return a non-empty dovecot 'userdb' style dict
|
||||||
@@ -55,9 +55,11 @@ class User:
|
|||||||
try:
|
try:
|
||||||
write_bytes_atomic(self.password_path, password)
|
write_bytes_atomic(self.password_path, password)
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
logging.error(f"could not write password for: {self.addr}")
|
if not self.addr.startswith("echo@"):
|
||||||
raise
|
logging.error(f"could not write password for: {self.addr}")
|
||||||
self.enforce_E2EE_path.touch()
|
raise
|
||||||
|
if not self.addr.startswith("echo@"):
|
||||||
|
self.enforce_E2EE_path.touch()
|
||||||
|
|
||||||
def set_last_login_timestamp(self, timestamp):
|
def set_last_login_timestamp(self, timestamp):
|
||||||
"""Track login time with daily granularity
|
"""Track login time with daily granularity
|
||||||
|
|||||||
94
cliff.toml
94
cliff.toml
@@ -1,94 +0,0 @@
|
|||||||
# git-cliff ~ configuration file
|
|
||||||
# https://git-cliff.org/docs/configuration
|
|
||||||
|
|
||||||
|
|
||||||
[changelog]
|
|
||||||
# A Tera template to be rendered for each release in the changelog.
|
|
||||||
# See https://keats.github.io/tera/docs/#introduction
|
|
||||||
body = """
|
|
||||||
{% if version %}\
|
|
||||||
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
|
|
||||||
{% else %}\
|
|
||||||
## [unreleased]
|
|
||||||
{% endif %}\
|
|
||||||
{% for group, commits in commits | group_by(attribute="group") %}
|
|
||||||
### {{ group | striptags | trim | upper_first }}
|
|
||||||
{% for commit in commits %}
|
|
||||||
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
|
|
||||||
{% if commit.breaking %}[**breaking**] {% endif %}\
|
|
||||||
{{ commit.message | upper_first }}\
|
|
||||||
{% endfor %}
|
|
||||||
{% endfor %}
|
|
||||||
"""
|
|
||||||
# Remove leading and trailing whitespaces from the changelog's body.
|
|
||||||
trim = true
|
|
||||||
# Render body even when there are no releases to process.
|
|
||||||
render_always = true
|
|
||||||
# An array of regex based postprocessors to modify the changelog.
|
|
||||||
postprocessors = [
|
|
||||||
# Replace the placeholder <REPO> with a URL.
|
|
||||||
#{ pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" },
|
|
||||||
]
|
|
||||||
# render body even when there are no releases to process
|
|
||||||
# render_always = true
|
|
||||||
# output file path
|
|
||||||
# output = "test.md"
|
|
||||||
|
|
||||||
[git]
|
|
||||||
# Parse commits according to the conventional commits specification.
|
|
||||||
# See https://www.conventionalcommits.org
|
|
||||||
conventional_commits = true
|
|
||||||
# Exclude commits that do not match the conventional commits specification.
|
|
||||||
filter_unconventional = true
|
|
||||||
# Require all commits to be conventional.
|
|
||||||
# Takes precedence over filter_unconventional.
|
|
||||||
require_conventional = false
|
|
||||||
# Split commits on newlines, treating each line as an individual commit.
|
|
||||||
split_commits = false
|
|
||||||
# An array of regex based parsers to modify commit messages prior to further processing.
|
|
||||||
commit_preprocessors = [
|
|
||||||
# Replace issue numbers with link templates to be updated in `changelog.postprocessors`.
|
|
||||||
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
|
|
||||||
# Check spelling of the commit message using https://github.com/crate-ci/typos.
|
|
||||||
# If the spelling is incorrect, it will be fixed automatically.
|
|
||||||
#{ pattern = '.*', replace_command = 'typos --write-changes -' },
|
|
||||||
]
|
|
||||||
# Prevent commits that are breaking from being excluded by commit parsers.
|
|
||||||
protect_breaking_commits = false
|
|
||||||
# An array of regex based parsers for extracting data from the commit message.
|
|
||||||
# Assigns commits to groups.
|
|
||||||
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
|
|
||||||
commit_parsers = [
|
|
||||||
{ message = "^feat", group = "Features" },
|
|
||||||
{ message = "^fix", group = "Bug Fixes" },
|
|
||||||
{ message = "^docs", group = "Documentation" },
|
|
||||||
{ message = "^perf", group = "Performance" },
|
|
||||||
{ message = "^refactor", group = "Refactor" },
|
|
||||||
{ message = "^style", group = "Styling" },
|
|
||||||
{ message = "^test", group = "Testing" },
|
|
||||||
{ message = "^chore\\(release\\): prepare for", skip = true },
|
|
||||||
{ message = "^chore\\(deps.*\\)", skip = true },
|
|
||||||
{ message = "^chore\\(pr\\)", skip = true },
|
|
||||||
{ message = "^chore\\(pull\\)", skip = true },
|
|
||||||
{ message = "^chore|^ci", group = "Miscellaneous Tasks" },
|
|
||||||
{ body = ".*security", group = "Security" },
|
|
||||||
{ message = "^revert", group = "Revert" },
|
|
||||||
{ message = ".*", group = "Other" },
|
|
||||||
]
|
|
||||||
# Exclude commits that are not matched by any commit parser.
|
|
||||||
filter_commits = false
|
|
||||||
# Fail on a commit that is not matched by any commit parser.
|
|
||||||
fail_on_unmatched_commit = false
|
|
||||||
# An array of link parsers for extracting external references, and turning them into URLs, using regex.
|
|
||||||
link_parsers = []
|
|
||||||
# Include only the tags that belong to the current branch.
|
|
||||||
use_branch_tags = false
|
|
||||||
# Order releases topologically instead of chronologically.
|
|
||||||
topo_order = false
|
|
||||||
# Order commits topologically instead of chronologically.
|
|
||||||
topo_order_commits = true
|
|
||||||
# Order of commits in each group/release within the changelog.
|
|
||||||
# Allowed values: newest, oldest
|
|
||||||
sort_commits = "oldest"
|
|
||||||
# Process submodules commits
|
|
||||||
recurse_submodules = false
|
|
||||||
@@ -61,19 +61,6 @@ class AcmetoolDeployer(Deployer):
|
|||||||
mode="644",
|
mode="644",
|
||||||
)
|
)
|
||||||
|
|
||||||
server.shell(
|
|
||||||
name=f"Remove old acmetool desired files for {self.domains[0]}",
|
|
||||||
commands=[f"rm -f /var/lib/acme/desired/{self.domains[0]}-*"],
|
|
||||||
)
|
|
||||||
files.template(
|
|
||||||
src=importlib.resources.files(__package__).joinpath("desired.yaml.j2"),
|
|
||||||
dest=f"/var/lib/acme/desired/{self.domains[0]}", # 0 is mailhost TLD
|
|
||||||
user="root",
|
|
||||||
group="root",
|
|
||||||
mode="644",
|
|
||||||
domains=self.domains,
|
|
||||||
)
|
|
||||||
|
|
||||||
service_file = files.put(
|
service_file = files.put(
|
||||||
src=importlib.resources.files(__package__).joinpath(
|
src=importlib.resources.files(__package__).joinpath(
|
||||||
"acmetool-redirector.service"
|
"acmetool-redirector.service"
|
||||||
@@ -136,6 +123,6 @@ class AcmetoolDeployer(Deployer):
|
|||||||
self.need_restart_reconcile_timer = False
|
self.need_restart_reconcile_timer = False
|
||||||
|
|
||||||
server.shell(
|
server.shell(
|
||||||
name=f"Reconcile certificates for: {', '.join(self.domains)}",
|
name=f"Request certificate for: {', '.join(self.domains)}",
|
||||||
commands=["acmetool --batch --xlog.severity=debug reconcile"],
|
commands=[f"acmetool want --xlog.severity=debug {' '.join(self.domains)}"],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
satisfy:
|
|
||||||
names:
|
|
||||||
{%- for domain in domains %}
|
|
||||||
- {{ domain }}
|
|
||||||
{%- endfor %}
|
|
||||||
|
|
||||||
@@ -109,6 +109,15 @@ def run_cmd(args, out):
|
|||||||
try:
|
try:
|
||||||
retcode = out.check_call(cmd, env=env)
|
retcode = out.check_call(cmd, env=env)
|
||||||
if retcode == 0:
|
if retcode == 0:
|
||||||
|
if not args.disable_mail:
|
||||||
|
print("\nYou can try out the relay by talking to this echo bot: ")
|
||||||
|
sshexec = SSHExec(args.config.mail_domain, verbose=args.verbose)
|
||||||
|
print(
|
||||||
|
sshexec(
|
||||||
|
call=remote.rshell.shell,
|
||||||
|
kwargs=dict(command="cat /var/lib/echobot/invite-link.txt"),
|
||||||
|
)
|
||||||
|
)
|
||||||
out.green("Deploy completed, call `cmdeploy dns` next.")
|
out.green("Deploy completed, call `cmdeploy dns` next.")
|
||||||
elif not remote_data["acme_account_url"]:
|
elif not remote_data["acme_account_url"]:
|
||||||
out.red("Deploy completed but letsencrypt not configured")
|
out.red("Deploy completed but letsencrypt not configured")
|
||||||
|
|||||||
@@ -270,14 +270,6 @@ class LegacyRemoveDeployer(Deployer):
|
|||||||
path="/var/log/journal/",
|
path="/var/log/journal/",
|
||||||
present=False,
|
present=False,
|
||||||
)
|
)
|
||||||
# remove echobot if it is still running
|
|
||||||
if host.get_fact(SystemdEnabled).get("echobot.service"):
|
|
||||||
systemd.service(
|
|
||||||
name="Disable echobot.service",
|
|
||||||
service="echobot.service",
|
|
||||||
running=False,
|
|
||||||
enabled=False,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def check_config(config):
|
def check_config(config):
|
||||||
@@ -412,6 +404,30 @@ class JournaldDeployer(Deployer):
|
|||||||
self.need_restart = False
|
self.need_restart = False
|
||||||
|
|
||||||
|
|
||||||
|
class EchobotDeployer(Deployer):
|
||||||
|
#
|
||||||
|
# This deployer depends on the dovecot and postfix deployers because
|
||||||
|
# it needs to base its decision of whether to restart the service on
|
||||||
|
# whether those two services were restarted.
|
||||||
|
#
|
||||||
|
def __init__(self, mail_domain):
|
||||||
|
self.mail_domain = mail_domain
|
||||||
|
self.units = ["echobot"]
|
||||||
|
|
||||||
|
def install(self):
|
||||||
|
apt.packages(
|
||||||
|
# required for setfacl for echobot
|
||||||
|
name="Install acl",
|
||||||
|
packages="acl",
|
||||||
|
)
|
||||||
|
|
||||||
|
def configure(self):
|
||||||
|
configure_remote_units(self.mail_domain, self.units)
|
||||||
|
|
||||||
|
def activate(self):
|
||||||
|
activate_remote_units(self.units)
|
||||||
|
|
||||||
|
|
||||||
class ChatmailVenvDeployer(Deployer):
|
class ChatmailVenvDeployer(Deployer):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
self.config = config
|
self.config = config
|
||||||
@@ -440,6 +456,7 @@ class ChatmailVenvDeployer(Deployer):
|
|||||||
class ChatmailDeployer(Deployer):
|
class ChatmailDeployer(Deployer):
|
||||||
required_users = [
|
required_users = [
|
||||||
("vmail", "vmail", None),
|
("vmail", "vmail", None),
|
||||||
|
("echobot", None, None),
|
||||||
("iroh", None, None),
|
("iroh", None, None),
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -573,6 +590,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
|
|||||||
PostfixDeployer(config, disable_mail),
|
PostfixDeployer(config, disable_mail),
|
||||||
FcgiwrapDeployer(),
|
FcgiwrapDeployer(),
|
||||||
NginxDeployer(config),
|
NginxDeployer(config),
|
||||||
|
EchobotDeployer(mail_domain),
|
||||||
MtailDeployer(config.mtail_address),
|
MtailDeployer(config.mtail_address),
|
||||||
GithashDeployer(),
|
GithashDeployer(),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ from cmdeploy.basedeploy import (
|
|||||||
|
|
||||||
|
|
||||||
class DovecotDeployer(Deployer):
|
class DovecotDeployer(Deployer):
|
||||||
daemon_reload = False
|
|
||||||
|
|
||||||
def __init__(self, config, disable_mail):
|
def __init__(self, config, disable_mail):
|
||||||
self.config = config
|
self.config = config
|
||||||
self.disable_mail = disable_mail
|
self.disable_mail = disable_mail
|
||||||
@@ -29,7 +27,7 @@ class DovecotDeployer(Deployer):
|
|||||||
|
|
||||||
def configure(self):
|
def configure(self):
|
||||||
configure_remote_units(self.config.mail_domain, self.units)
|
configure_remote_units(self.config.mail_domain, self.units)
|
||||||
self.need_restart, self.daemon_reload = _configure_dovecot(self.config)
|
self.need_restart = _configure_dovecot(self.config)
|
||||||
|
|
||||||
def activate(self):
|
def activate(self):
|
||||||
activate_remote_units(self.units)
|
activate_remote_units(self.units)
|
||||||
@@ -44,7 +42,6 @@ class DovecotDeployer(Deployer):
|
|||||||
running=False if self.disable_mail else True,
|
running=False if self.disable_mail else True,
|
||||||
enabled=False if self.disable_mail else True,
|
enabled=False if self.disable_mail else True,
|
||||||
restarted=restart,
|
restarted=restart,
|
||||||
daemon_reload=self.daemon_reload,
|
|
||||||
)
|
)
|
||||||
self.need_restart = False
|
self.need_restart = False
|
||||||
|
|
||||||
@@ -83,10 +80,9 @@ def _install_dovecot_package(package: str, arch: str):
|
|||||||
apt.deb(name=f"Install dovecot-{package}", src=deb_filename)
|
apt.deb(name=f"Install dovecot-{package}", src=deb_filename)
|
||||||
|
|
||||||
|
|
||||||
def _configure_dovecot(config: Config, debug: bool = False) -> (bool, bool):
|
def _configure_dovecot(config: Config, debug: bool = False) -> bool:
|
||||||
"""Configures Dovecot IMAP server."""
|
"""Configures Dovecot IMAP server."""
|
||||||
need_restart = False
|
need_restart = False
|
||||||
daemon_reload = False
|
|
||||||
|
|
||||||
main_config = files.template(
|
main_config = files.template(
|
||||||
src=get_resource("dovecot/dovecot.conf.j2"),
|
src=get_resource("dovecot/dovecot.conf.j2"),
|
||||||
@@ -138,11 +134,4 @@ def _configure_dovecot(config: Config, debug: bool = False) -> (bool, bool):
|
|||||||
)
|
)
|
||||||
need_restart |= timezone_env.changed
|
need_restart |= timezone_env.changed
|
||||||
|
|
||||||
restart_conf = files.put(
|
return need_restart
|
||||||
name="dovecot: restart automatically on failure",
|
|
||||||
src=get_resource("service/10_restart.conf"),
|
|
||||||
dest="/etc/systemd/system/dovecot.service.d/10_restart.conf",
|
|
||||||
)
|
|
||||||
daemon_reload |= restart_conf.changed
|
|
||||||
|
|
||||||
return need_restart, daemon_reload
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ mail_attribute_dict = proxy:/run/chatmail-metadata/metadata.socket:metadata
|
|||||||
# `imap_zlib` enables IMAP COMPRESS (RFC 4978).
|
# `imap_zlib` enables IMAP COMPRESS (RFC 4978).
|
||||||
# <https://datatracker.ietf.org/doc/html/rfc4978.html>
|
# <https://datatracker.ietf.org/doc/html/rfc4978.html>
|
||||||
protocol imap {
|
protocol imap {
|
||||||
mail_plugins = $mail_plugins imap_quota last_login {% if config.imap_compress %}imap_zlib{% endif %}
|
mail_plugins = $mail_plugins imap_zlib imap_quota last_login
|
||||||
imap_metadata = yes
|
imap_metadata = yes
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,28 +252,3 @@ protocol imap {
|
|||||||
rawlog_dir = %h
|
rawlog_dir = %h
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if not config.imap_compress %}
|
|
||||||
# Hibernate IDLE users to save memory and CPU resources
|
|
||||||
# NOTE: this will have no effect if imap_zlib plugin is used
|
|
||||||
imap_hibernate_timeout = 30s
|
|
||||||
service imap {
|
|
||||||
# Note that this change will allow any process running as
|
|
||||||
# $default_internal_user (dovecot) to access mails as any other user.
|
|
||||||
# This may be insecure in some installations, which is why this isn't
|
|
||||||
# done by default.
|
|
||||||
unix_listener imap-master {
|
|
||||||
user = $default_internal_user
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# The following is the default already in v2.3.1+:
|
|
||||||
service imap {
|
|
||||||
extra_groups = $default_internal_group
|
|
||||||
}
|
|
||||||
service imap-hibernate {
|
|
||||||
unix_listener imap-hibernate {
|
|
||||||
mode = 0660
|
|
||||||
group = $default_internal_group
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{% endif %}
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ if nsigs == nil then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local valid = false
|
local valid = false
|
||||||
local error_msg = "No valid DKIM signature found."
|
|
||||||
for i = 1, nsigs do
|
for i = 1, nsigs do
|
||||||
sig = odkim.get_sighandle(ctx, i - 1)
|
sig = odkim.get_sighandle(ctx, i - 1)
|
||||||
sigres = odkim.sig_result(sig)
|
sigres = odkim.sig_result(sig)
|
||||||
@@ -22,8 +21,6 @@ for i = 1, nsigs do
|
|||||||
-- means the message is acceptable.
|
-- means the message is acceptable.
|
||||||
if sigres == 0 then
|
if sigres == 0 then
|
||||||
valid = true
|
valid = true
|
||||||
else
|
|
||||||
error_msg = "DKIM signature is invalid, error code " .. tostring(sigres) .. ", search https://github.com/trusteddomainproject/OpenDKIM/blob/master/libopendkim/dkim.h#L108"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -34,7 +31,7 @@ if valid then
|
|||||||
odkim.del_header(ctx, "DKIM-Signature", i)
|
odkim.del_header(ctx, "DKIM-Signature", i)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
odkim.set_reply(ctx, "554", "5.7.1", error_msg)
|
odkim.set_reply(ctx, "554", "5.7.1", "No valid DKIM signature found")
|
||||||
odkim.set_result(ctx, SMFIS_REJECT)
|
odkim.set_result(ctx, SMFIS_REJECT)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ from cmdeploy.basedeploy import Deployer, get_resource
|
|||||||
|
|
||||||
class PostfixDeployer(Deployer):
|
class PostfixDeployer(Deployer):
|
||||||
required_users = [("postfix", None, ["opendkim"])]
|
required_users = [("postfix", None, ["opendkim"])]
|
||||||
daemon_reload = False
|
|
||||||
|
|
||||||
def __init__(self, config, disable_mail):
|
def __init__(self, config, disable_mail):
|
||||||
self.config = config
|
self.config = config
|
||||||
@@ -61,13 +60,6 @@ class PostfixDeployer(Deployer):
|
|||||||
mode="644",
|
mode="644",
|
||||||
)
|
)
|
||||||
need_restart |= login_map.changed
|
need_restart |= login_map.changed
|
||||||
|
|
||||||
restart_conf = files.put(
|
|
||||||
name="postfix: restart automatically on failure",
|
|
||||||
src=get_resource("service/10_restart.conf"),
|
|
||||||
dest="/etc/systemd/system/dovecot.service.d/10_restart.conf",
|
|
||||||
)
|
|
||||||
self.daemon_reload = restart_conf.changed
|
|
||||||
self.need_restart = need_restart
|
self.need_restart = need_restart
|
||||||
|
|
||||||
def activate(self):
|
def activate(self):
|
||||||
@@ -81,6 +73,5 @@ class PostfixDeployer(Deployer):
|
|||||||
running=False if self.disable_mail else True,
|
running=False if self.disable_mail else True,
|
||||||
enabled=False if self.disable_mail else True,
|
enabled=False if self.disable_mail else True,
|
||||||
restarted=restart,
|
restarted=restart,
|
||||||
daemon_reload=self.daemon_reload,
|
|
||||||
)
|
)
|
||||||
self.need_restart = False
|
self.need_restart = False
|
||||||
|
|||||||
@@ -37,10 +37,7 @@ def perform_initial_checks(mail_domain, pre_command=""):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
# parse out sts-id if exists, example: "v=STSv1; id=2090123"
|
# parse out sts-id if exists, example: "v=STSv1; id=2090123"
|
||||||
mta_sts_txt = query_dns("TXT", f"_mta-sts.{mail_domain}")
|
parts = query_dns("TXT", f"_mta-sts.{mail_domain}").split("id=")
|
||||||
if not mta_sts_txt:
|
|
||||||
return res
|
|
||||||
parts = mta_sts_txt.split("id=")
|
|
||||||
res["sts_id"] = parts[1].rstrip('"') if len(parts) == 2 else ""
|
res["sts_id"] = parts[1].rstrip('"') if len(parts) == 2 else ""
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
[Service]
|
|
||||||
Restart=always
|
|
||||||
RestartSec=30
|
|
||||||
67
cmdeploy/src/cmdeploy/service/echobot.service.f
Normal file
67
cmdeploy/src/cmdeploy/service/echobot.service.f
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Chatmail echo bot for testing it works
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart={execpath} {config_path}
|
||||||
|
Environment="PATH={remote_venv_dir}:$PATH"
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
|
||||||
|
User=echobot
|
||||||
|
Group=echobot
|
||||||
|
|
||||||
|
# Create /var/lib/echobot
|
||||||
|
StateDirectory=echobot
|
||||||
|
|
||||||
|
# Create /run/echobot
|
||||||
|
#
|
||||||
|
# echobot stores /run/echobot/password
|
||||||
|
# with a password there, which doveauth then reads.
|
||||||
|
RuntimeDirectory=echobot
|
||||||
|
|
||||||
|
WorkingDirectory=/var/lib/echobot
|
||||||
|
|
||||||
|
# Apply security restrictions suggested by
|
||||||
|
# systemd-analyze security echobot.service
|
||||||
|
CapabilityBoundingSet=
|
||||||
|
LockPersonality=true
|
||||||
|
MemoryDenyWriteExecute=true
|
||||||
|
NoNewPrivileges=true
|
||||||
|
PrivateDevices=true
|
||||||
|
PrivateMounts=true
|
||||||
|
PrivateTmp=true
|
||||||
|
|
||||||
|
# We need to know about doveauth user to give it access to /run/echobot/password
|
||||||
|
PrivateUsers=false
|
||||||
|
|
||||||
|
ProtectClock=true
|
||||||
|
ProtectControlGroups=true
|
||||||
|
ProtectHostname=true
|
||||||
|
ProtectKernelLogs=true
|
||||||
|
ProtectKernelModules=true
|
||||||
|
ProtectKernelTunables=true
|
||||||
|
ProtectProc=noaccess
|
||||||
|
|
||||||
|
# Should be "strict", but we currently write /accounts folder in a protected path
|
||||||
|
ProtectSystem=full
|
||||||
|
|
||||||
|
RemoveIPC=true
|
||||||
|
RestrictAddressFamilies=AF_INET AF_INET6
|
||||||
|
RestrictNamespaces=true
|
||||||
|
RestrictRealtime=true
|
||||||
|
RestrictSUIDSGID=true
|
||||||
|
SystemCallArchitectures=native
|
||||||
|
SystemCallFilter=~@clock
|
||||||
|
SystemCallFilter=~@cpu-emulation
|
||||||
|
SystemCallFilter=~@debug
|
||||||
|
SystemCallFilter=~@module
|
||||||
|
SystemCallFilter=~@mount
|
||||||
|
SystemCallFilter=~@obsolete
|
||||||
|
SystemCallFilter=~@raw-io
|
||||||
|
SystemCallFilter=~@reboot
|
||||||
|
SystemCallFilter=~@resources
|
||||||
|
SystemCallFilter=~@swap
|
||||||
|
UMask=0077
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
import os
|
||||||
import smtplib
|
import smtplib
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -7,6 +8,7 @@ import time
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from cmdeploy import remote
|
from cmdeploy import remote
|
||||||
|
from cmdeploy.cmdeploy import main
|
||||||
from cmdeploy.sshexec import SSHExec
|
from cmdeploy.sshexec import SSHExec
|
||||||
|
|
||||||
|
|
||||||
@@ -68,6 +70,47 @@ class TestSSHExecutor:
|
|||||||
assert (now - since_date).total_seconds() < 60 * 60 * 51
|
assert (now - since_date).total_seconds() < 60 * 60 * 51
|
||||||
|
|
||||||
|
|
||||||
|
def test_status_cmd(chatmail_config, capsys, request):
|
||||||
|
os.chdir(request.config.invocation_params.dir)
|
||||||
|
assert main(["status"]) == 0
|
||||||
|
status_out = capsys.readouterr()
|
||||||
|
print(status_out.out)
|
||||||
|
|
||||||
|
services = [
|
||||||
|
"acmetool-redirector",
|
||||||
|
"chatmail-metadata",
|
||||||
|
"doveauth",
|
||||||
|
"dovecot",
|
||||||
|
"echobot",
|
||||||
|
"fcgiwrap",
|
||||||
|
"filtermail-incoming",
|
||||||
|
"filtermail",
|
||||||
|
"lastlogin",
|
||||||
|
"nginx",
|
||||||
|
"opendkim",
|
||||||
|
"postfix@-",
|
||||||
|
"systemd-journald",
|
||||||
|
"turnserver",
|
||||||
|
"unbound",
|
||||||
|
]
|
||||||
|
not_running = []
|
||||||
|
for service in services:
|
||||||
|
active = False
|
||||||
|
for line in status_out:
|
||||||
|
if service in line:
|
||||||
|
active = True
|
||||||
|
if not "loaded" in line:
|
||||||
|
active = False
|
||||||
|
if not "active" in line:
|
||||||
|
active = False
|
||||||
|
if not "running" in line:
|
||||||
|
active = False
|
||||||
|
break
|
||||||
|
if not active:
|
||||||
|
not_running.append(service)
|
||||||
|
assert not_running == []
|
||||||
|
|
||||||
|
|
||||||
def test_timezone_env(remote):
|
def test_timezone_env(remote):
|
||||||
for line in remote.iter_output("env"):
|
for line in remote.iter_output("env"):
|
||||||
print(line)
|
print(line)
|
||||||
|
|||||||
@@ -160,3 +160,22 @@ def test_hide_senders_ip_address(cmfactory):
|
|||||||
user2.direct_imap.select_folder("Inbox")
|
user2.direct_imap.select_folder("Inbox")
|
||||||
msg = user2.direct_imap.get_all_messages()[0]
|
msg = user2.direct_imap.get_all_messages()[0]
|
||||||
assert public_ip not in msg.obj.as_string()
|
assert public_ip not in msg.obj.as_string()
|
||||||
|
|
||||||
|
|
||||||
|
def test_echobot(cmfactory, chatmail_config, lp, sshdomain):
|
||||||
|
ac = cmfactory.get_online_accounts(1)[0]
|
||||||
|
|
||||||
|
# establish contact with echobot
|
||||||
|
sshexec = SSHExec(sshdomain)
|
||||||
|
command = "cat /var/lib/echobot/invite-link.txt"
|
||||||
|
echo_invite_link = sshexec(call=rshell.shell, kwargs=dict(command=command))
|
||||||
|
chat = ac.qr_setup_contact(echo_invite_link)
|
||||||
|
ac._evtracker.wait_securejoin_joiner_progress(1000)
|
||||||
|
|
||||||
|
# send message and check it gets replied back
|
||||||
|
lp.sec("Send message to echobot")
|
||||||
|
text = "hi, I hope you text me back"
|
||||||
|
chat.send_text(text)
|
||||||
|
lp.sec("Wait for reply from echobot")
|
||||||
|
reply = ac._evtracker.wait_next_incoming_message()
|
||||||
|
assert reply.text == text
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
import os
|
|
||||||
|
|
||||||
from cmdeploy.cmdeploy import main
|
|
||||||
|
|
||||||
|
|
||||||
def test_status_cmd(chatmail_config, capsys, request):
|
|
||||||
os.chdir(request.config.invocation_params.dir)
|
|
||||||
assert main(["status"]) == 0
|
|
||||||
status_out = capsys.readouterr()
|
|
||||||
print(status_out.out)
|
|
||||||
|
|
||||||
assert len(status_out.out.splitlines()) > 5
|
|
||||||
|
|
||||||
"""
|
|
||||||
don't test actual server state:
|
|
||||||
|
|
||||||
services = [
|
|
||||||
"acmetool-redirector",
|
|
||||||
"chatmail-metadata",
|
|
||||||
"doveauth",
|
|
||||||
"dovecot",
|
|
||||||
"fcgiwrap",
|
|
||||||
"filtermail-incoming",
|
|
||||||
"filtermail",
|
|
||||||
"lastlogin",
|
|
||||||
"nginx",
|
|
||||||
"opendkim",
|
|
||||||
"postfix@-",
|
|
||||||
"systemd-journald",
|
|
||||||
"turnserver",
|
|
||||||
"unbound",
|
|
||||||
]
|
|
||||||
not_running = []
|
|
||||||
for service in services:
|
|
||||||
active = False
|
|
||||||
for line in status_out:
|
|
||||||
if service in line:
|
|
||||||
active = True
|
|
||||||
if not "loaded" in line:
|
|
||||||
active = False
|
|
||||||
if not "active" in line:
|
|
||||||
active = False
|
|
||||||
if not "running" in line:
|
|
||||||
active = False
|
|
||||||
break
|
|
||||||
if not active:
|
|
||||||
not_running.append(service)
|
|
||||||
assert not_running == []
|
|
||||||
"""
|
|
||||||
@@ -166,7 +166,7 @@ def main():
|
|||||||
build_webpages(src_path, build_dir, config)
|
build_webpages(src_path, build_dir, config)
|
||||||
print(f"[{changenum}] regenerated web pages at: {index_path}")
|
print(f"[{changenum}] regenerated web pages at: {index_path}")
|
||||||
print(f"URL: file://{index_path.resolve()}\n\n")
|
print(f"URL: file://{index_path.resolve()}\n\n")
|
||||||
|
|
||||||
time.sleep(debounce_time) # simple debounce
|
time.sleep(debounce_time) # simple debounce
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ You can use the `make` command and `make html` to build web pages.
|
|||||||
|
|
||||||
You need a Python environment where the following install was excuted:
|
You need a Python environment where the following install was excuted:
|
||||||
|
|
||||||
pip install furo sphinx-autobuild
|
pip install sphinx-build furo sphinx-autobuild
|
||||||
|
|
||||||
To develop/change documentation, you can then do:
|
To develop/change documentation, you can then do:
|
||||||
|
|
||||||
|
|||||||
@@ -7,88 +7,67 @@ machine, you can use these steps. They were tested with a Linux laptop;
|
|||||||
you might need to adjust some of the steps to your environment.
|
you might need to adjust some of the steps to your environment.
|
||||||
|
|
||||||
Let’s assume that your ``mail_domain`` is ``mail.example.org``, all
|
Let’s assume that your ``mail_domain`` is ``mail.example.org``, all
|
||||||
involved machines run Debian 12, your old site’s IP version 4 address is
|
involved machines run Debian 12, your old site’s IP address is
|
||||||
``$OLD_IP4``, and your new site’s IP4 address is ``$NEW_IP4``.
|
``13.37.13.37``, and your new site’s IP address is ``13.12.23.42``.
|
||||||
|
|
||||||
First of all, you should lower the Time To Live (TTL) of your DNS records
|
Note, you should lower the TTLs of your DNS records to a value such as
|
||||||
to a value such as 300 (5 minutes).
|
300 (5 minutes) so the migration happens as smoothly as possible.
|
||||||
Short TTL values allow to change DNS records during the migration more timely.
|
|
||||||
|
|
||||||
During the guide you might get a warning about changed SSH Host keys; in
|
During the guide you might get a warning about changed SSH Host keys; in
|
||||||
this case, just run ``ssh-keygen -R "mail.example.org"`` as recommended.
|
this case, just run ``ssh-keygen -R "mail.example.org"`` as recommended.
|
||||||
|
|
||||||
1. First, to make the downtime during the migration shorter,
|
1. First, disable mail services on the old site.
|
||||||
let's transfer the current state of the mailboxes.
|
|
||||||
Login to your old machine (while forwarding your ssh-agent with ``ssh -A``)
|
::
|
||||||
|
|
||||||
|
cmdeploy run --disable-mail --ssh-host 13.37.13.37
|
||||||
|
|
||||||
|
Now your users will notice the migration and will not be able to send
|
||||||
|
or receive messages until the migration is completed.
|
||||||
|
|
||||||
|
2. Now we want to copy ``/home/vmail``, ``/var/lib/acme``,
|
||||||
|
``/etc/dkimkeys``, ``/run/echobot``, and ``/var/spool/postfix`` to
|
||||||
|
the new site. Login to the old site while forwarding your SSH agent
|
||||||
so you can copy directly from the old to the new site with your SSH
|
so you can copy directly from the old to the new site with your SSH
|
||||||
key:
|
key:
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
ssh -A root@$OLD_IP4
|
ssh -A root@13.37.13.37
|
||||||
tar c /home/vmail/mail | ssh root@$NEW_IP4 "tar x -C /"
|
tar c - /home/vmail/mail /var/lib/acme /etc/dkimkeys /run/echobot /var/spool/postfix | ssh root@13.12.23.42 "tar x -C /"
|
||||||
|
|
||||||
This saves us time during the downtime,
|
This transfers all addresses, the TLS certificate, DKIM keys (so DKIM
|
||||||
at least the mailboxes are there already.
|
DNS record remains valid), and the echobot’s password so it continues
|
||||||
They contain user passwords, encrypted push notification tokens,
|
to function. It also preserves the Postfix mail spool so any messages
|
||||||
messages which might not have been fetched by all devices of the user yet,
|
|
||||||
and dovecot indexes which track the state of the mailbox.
|
|
||||||
|
|
||||||
2. Then, from your local machine, install chatmail on the new machine, but don't activate it yet:
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
CMDEPLOY_STAGES=install,configure cmdeploy run --ssh-host $NEW_IP4
|
|
||||||
|
|
||||||
The services are disabled for now; we will enable them later.
|
|
||||||
We first need to make the new site fully operational.
|
|
||||||
|
|
||||||
3. Now it's getting serious: disable the mail services on the old site.
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
cmdeploy run --disable-mail --ssh-host $OLD_IP4
|
|
||||||
|
|
||||||
Your users will start to notice the migration and will not be able to send
|
|
||||||
or receive messages until the migration is completed.
|
|
||||||
Other relays and mail servers will wait with delivering messages
|
|
||||||
until your relay is reachable again.
|
|
||||||
|
|
||||||
4. Now we want to copy ``/home/vmail``, ``/var/lib/acme``,
|
|
||||||
``/etc/dkimkeys``, and ``/var/spool/postfix`` to
|
|
||||||
the new site. Let's forward the SSH agent again to copy the files directly.
|
|
||||||
This time, we copy ``/home/vmail/mail`` with rsync to only copy the recent changes:
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
ssh -A root@$OLD_IP4
|
|
||||||
tar c /var/lib/acme /etc/dkimkeys /var/spool/postfix | ssh root@$NEW_IP4 "tar x -C /"
|
|
||||||
rsync -azH /home/vmail/mail root@$NEW_IP4:/home/vmail/
|
|
||||||
|
|
||||||
This transfers all messages which have not been fetched yet, the TLS certificate,
|
|
||||||
and DKIM keys (so DKIM DNS record remains valid).
|
|
||||||
It also preserves the Postfix mail spool so any messages
|
|
||||||
pending delivery will still be delivered.
|
pending delivery will still be delivered.
|
||||||
|
|
||||||
5. Now login to the new site and run the following to ensure the ownership is correct
|
3. Install chatmail on the new machine:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
cmdeploy run --disable-mail --ssh-host 13.12.23.42
|
||||||
|
|
||||||
|
Postfix and Dovecot are disabled for now; we will enable them later.
|
||||||
|
We first need to make the new site fully operational.
|
||||||
|
|
||||||
|
4. On the new site, run the following to ensure the ownership is correct
|
||||||
in case UIDs/GIDs changed:
|
in case UIDs/GIDs changed:
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
ssh root@$NEW_IP4
|
|
||||||
chown root: -R /var/lib/acme
|
chown root: -R /var/lib/acme
|
||||||
chown opendkim: -R /etc/dkimkeys
|
chown opendkim: -R /etc/dkimkeys
|
||||||
chown vmail: -R /home/vmail/mail
|
chown vmail: -R /home/vmail/mail
|
||||||
|
chown echobot: -R /run/echobot
|
||||||
|
|
||||||
6. Now, update the DNS entries.
|
5. Now, update DNS entries.
|
||||||
You only need to change the ``A`` and ``AAAA`` records, for example:
|
|
||||||
|
|
||||||
::
|
If other MTAs try to deliver messages to your chatmail domain they
|
||||||
|
may fail intermittently, as DNS catches up with the new site settings
|
||||||
|
but normally will retry delivering messages for at least a week, so
|
||||||
|
messages will not be lost.
|
||||||
|
|
||||||
mail.example.org. IN A $NEW_IP4
|
6. Finally, you can execute ``cmdeploy run --ssh-host 13.12.23.42`` to
|
||||||
mail.example.org. IN AAAA $NEW_IP6
|
|
||||||
|
|
||||||
7. Finally, you can execute ``CMDEPLOY_STAGES=activate cmdeploy run --ssh-host $NEW_IP4`` to
|
|
||||||
turn on chatmail on the new relay. Your users will be able to use the
|
turn on chatmail on the new relay. Your users will be able to use the
|
||||||
chatmail relay as soon as the DNS changes have propagated. Voilà!
|
chatmail relay as soon as the DNS changes have propagated. Voilà!
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,10 @@ short overview of ``chatmaild`` services:
|
|||||||
is contacted by Dovecot when a user logs in and stores the date of
|
is contacted by Dovecot when a user logs in and stores the date of
|
||||||
the login.
|
the login.
|
||||||
|
|
||||||
|
- `echobot <https://github.com/chatmail/relay/blob/main/chatmaild/src/chatmaild/echo.py>`_
|
||||||
|
is a small bot for test purposes. It simply echoes back messages from
|
||||||
|
users.
|
||||||
|
|
||||||
- `metrics <https://github.com/chatmail/relay/blob/main/chatmaild/src/chatmaild/metrics.py>`_
|
- `metrics <https://github.com/chatmail/relay/blob/main/chatmaild/src/chatmaild/metrics.py>`_
|
||||||
collects some metrics and displays them at
|
collects some metrics and displays them at
|
||||||
``https://example.org/metrics``.
|
``https://example.org/metrics``.
|
||||||
@@ -272,8 +276,8 @@ by OpenDKIM screen policy script before validating the signatures. This
|
|||||||
corresponds to strict :rfc:`DMARC <7489>` alignment (``adkim=s``).
|
corresponds to strict :rfc:`DMARC <7489>` alignment (``adkim=s``).
|
||||||
If there is no valid DKIM signature on the incoming email, the
|
If there is no valid DKIM signature on the incoming email, the
|
||||||
sender receives a “5.7.1 No valid DKIM signature found” error.
|
sender receives a “5.7.1 No valid DKIM signature found” error.
|
||||||
After validating the DKIM signature,
|
After validating the DKIM signature,
|
||||||
the `final.lua` script strips all ``OpenDKIM:`` headers to reduce message size on disc.
|
the `final.lua` script strips all ``OpenDKIM:`` headers to reduce message size on disc.
|
||||||
|
|
||||||
Note that chatmail relays
|
Note that chatmail relays
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Active development takes place in the `chatmail/relay github repository <https:/
|
|||||||
You can check out the `'chatmail' tag in the support.delta.chat forum <https://support.delta.chat/tag/chatmail>`_
|
You can check out the `'chatmail' tag in the support.delta.chat forum <https://support.delta.chat/tag/chatmail>`_
|
||||||
and ask to get added to a non-public support chat for debugging issues.
|
and ask to get added to a non-public support chat for debugging issues.
|
||||||
|
|
||||||
We know of three work-in-progress alternative implementation efforts:
|
We know of two work-in-progress alternative implementation efforts:
|
||||||
|
|
||||||
- `Mox <https://github.com/mjl-/mox>`_: A Golang email server. `Work
|
- `Mox <https://github.com/mjl-/mox>`_: A Golang email server. `Work
|
||||||
is in progress <https://github.com/mjl-/mox/issues/251>`_ to modify
|
is in progress <https://github.com/mjl-/mox/issues/251>`_ to modify
|
||||||
@@ -18,10 +18,3 @@ We know of three work-in-progress alternative implementation efforts:
|
|||||||
plugin for the `Maddy email server <https://maddy.email/>`_ which
|
plugin for the `Maddy email server <https://maddy.email/>`_ which
|
||||||
aims to implement the chatmail relay features and configuration
|
aims to implement the chatmail relay features and configuration
|
||||||
options.
|
options.
|
||||||
|
|
||||||
- `Chatmail Cookbook <https://github.com/feld/chatmail-cookbook>`_:
|
|
||||||
A Chef Cookbook implementing a relay server. The project follows the
|
|
||||||
official relay server software and configurations converted to a Chef
|
|
||||||
Cookbook with only minor differences. The cookbook uses DNS-01 for
|
|
||||||
certificate validation and additionally supports FreeBSD. It does not
|
|
||||||
require a Chef server to use.
|
|
||||||
|
|||||||
@@ -23,3 +23,7 @@ you can also **scan this QR code** with Delta Chat:
|
|||||||
🐣 **Choose** your Avatar and Name
|
🐣 **Choose** your Avatar and Name
|
||||||
|
|
||||||
💬 **Start** chatting with any Delta Chat contacts using [QR invite codes](https://delta.chat/en/help#howtoe2ee)
|
💬 **Start** chatting with any Delta Chat contacts using [QR invite codes](https://delta.chat/en/help#howtoe2ee)
|
||||||
|
|
||||||
|
{% if config.mail_domain != "nine.testrun.org" %}
|
||||||
|
<div class="experimental">Note: this is only a temporary development chatmail service</div>
|
||||||
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user