Compare commits

..

1 Commits

Author SHA1 Message Date
link2xt
abd7e42a34 Require that passwords are at least 10 characters long 2023-10-27 17:58:09 +00:00
4 changed files with 27 additions and 89 deletions

View File

@@ -1,61 +1,26 @@
# Chatmail instances optimized for Delta Chat apps # Chat Mail server configuration
This repository helps to setup a ready-to-use chatmail instance This repository setups a ready-to-go chatmail instance
comprised of a minimal setup of the battle-tested comprised of a minimal setup of the battle-tested
[postfix smtp](https://www.postfix.org) and [dovecot imap](https://www.dovecot.org) services. [postfix smtp server](https://www.postfix.org) and [dovecot imap server](https://www.dovecot.org).
The setup is designed and optimized for providing chatmail accounts ## Getting started
for use by [Delta Chat apps](https://delta.chat).
Chatmail accounts are automatically created by a first login, 1. prepare your local system:
after which the initially specified password is required for using them.
## Getting Started deploying your own chatmail instance
1. Prepare your local (presumably Linux) system:
scripts/init.sh scripts/init.sh
2. Setup a domain with `A` and `AAAA` records for your chatmail server. 2. setup a domain with `A` and `AAAA` records for your chatmail server
3. Set environment variable to the chatmail domain you want to setup: 3. set environment variable to the chatmail domain you want to setup:
export CHATMAIL_DOMAIN=c1.testrun.org # replace with your host export CHATMAIL_DOMAIN=c1.testrun.org # replace with your host
4. Deploy the chat mail instance to your chatmail server: 4. run the deploy of the chat mail instance:
scripts/deploy.sh scripts/deploy.sh
This script uses `pyinfra` and `ssh` to setup packages and configure 5. run `scripts/generate-dns-zone.sh` and create the generated DNS records at your DNS provider
the chatmail instance on your remote server.
5. Run `scripts/generate-dns-zone.sh` and
transfer the generated DNS records at your DNS provider
6. Start a Delta Chat app and create a new account
by typing an e-mail address with an arbitrary username
and `@<your-chatmail-domain>` appended.
Use an at least 10-character random password.
### Ports
Postfix listens on ports 25 (smtp) and 587 (submission) and 465 (submissions).
Dovecot listens on ports 143(imap) and 993 (imaps).
Delta Chat will, however, discover all ports and configurations
automatically by reading the `autoconfig.xml` file from the chatmail instance.
## Emergency Commands to disable automatic account creation
If you need to stop account creation,
e.g. because some script is wildly creating accounts, run:
touch /etc/chatmail-nocreate
While this file is present, account creation will be blocked.
## Running tests and benchmarks (offline and online) ## Running tests and benchmarks (offline and online)
@@ -70,26 +35,28 @@ While this file is present, account creation will be blocked.
scripts/bench.sh scripts/bench.sh
## Running tests (offline and online)
## Development Background for chatmail instances ```
## Dovecot/Postfix configuration
This repository drives the development of "chatmail instances", ### Ports
comprised of minimal setups of
- [postfix smtp server](https://www.postfix.org) Postfix listens on ports 25 (smtp) and 587 (submission) and 465 (submissions).
- [dovecot imap server](https://www.dovecot.org) Dovecot listens on ports 143(imap) and 993 (imaps).
as well as two custom services that are integrated with these two: ## DNS
- `chatmaild/src/chatmaild/dictproxy.py` implements For DKIM you must add a DNS entry as found in /etc/opendkim/selector.txt on your chatmail instance.
create-on-login account creation semantics and is used The above `scripts/deploy.sh` prints out the DKIM selector and DNS entry you
by Dovecot during login authentication and by Postfix need to setup with your DNS provider.
which in turn uses Dovecot SASL to authenticate users
to send mails for them.
- `chatmaild/src/chatmaild/filtermail.py` prevents
unencrypted e-mail from leaving the chatmail instance
and is integrated into postfix's outbound mail pipelines.
## Emergency Commands
If you need to stop account creation,
e.g. because some script is wildly creating accounts,
just run `touch /tmp/nocreate`.
You can remove the file
as soon as the attacker was banned
by different means.

View File

@@ -183,17 +183,6 @@ def _configure_dovecot(mail_server: str, debug: bool = False) -> bool:
mode="644", mode="644",
) )
# as per https://doc.dovecot.org/configuration_manual/os/
# it is recommended to set the following inotify limits
for name in ("max_user_instances", "max_user_watches"):
key = f"fs.inotify.{name}"
server.sysctl(
name=f"Change {key}",
key=key,
value=65535,
persist=True,
)
return need_restart return need_restart

View File

@@ -118,24 +118,6 @@ service auth-worker {
user = vmail user = vmail
} }
service imap-login {
# High-security mode.
# Each process serves a single connection and exits afterwards.
# This is the default, but we set it explicitly to be sure.
# See <https://doc.dovecot.org/admin_manual/login_processes/#high-security-mode> for details.
service_count = 1
# Inrease the number of simultaneous connections.
#
# As of Dovecot 2.3.19.1 the default is 100 processes.
# Combined with `service_count = 1` it means only 100 connections
# can be handled simultaneously.
process_limit = 10000
# Avoid startup latency for new connections.
process_min_avail = 10
}
ssl = required ssl = required
ssl_cert = </var/lib/acme/live/{{ config.hostname }}/fullchain ssl_cert = </var/lib/acme/live/{{ config.hostname }}/fullchain
ssl_key = </var/lib/acme/live/{{ config.hostname }}/privkey ssl_key = </var/lib/acme/live/{{ config.hostname }}/privkey

View File

@@ -1,4 +1,4 @@
#!/bin/bash #!/bin/bash
set -e set -e
venv/bin/pytest online-tests/benchmark.py -vrx online-tests/venv/bin/pytest online-tests/benchmark.py -vrx