1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00
Commit Graph

409 Commits

Author SHA1 Message Date
Alberto Bertogli
7fa564f822 smtpsrv: Add comment on BuildNameToCertificate being deprecated
tls.Config.BuildNameToCertificate was deprecated in Go 1.14, and is no
longer necessary.

However, we support down to 1.11, so we will keep it for now.

This patch adds a TODO to remove it in the future once the minimum
supported version is 1.14; and adjust the CI linter accordingly.
2020-05-13 23:42:37 +01:00
Alberto Bertogli
70387207f2 man: Update generated versions
This patch just re-runs the pod generator using a newer version of it,
going from 4.09 to 4.11.

There are no content changes.
2020-05-13 20:42:09 +01:00
Alberto Bertogli
13ee3ba482 courier: Use the hostname in SMTP HELO
The SMTP courier, which handles outgoing connections, uses the domain of
the envelope's from as the domain in the HELO/EHLO greeting.

This works fine in practice, but ideally the domain used in the greeting
should match the reverse DNS record. This used to be more relevant but
nowadays it is not really enforced; however, it sometimes comes up in
self checks, and might cause some confusion when troubleshooting.

So this patch makes it use the configured hostname instead, which is
under the users' control and more likely to be compliant. It also
simplifies the code.

The documentation of the hostname configuration option is also updated
to mention this behaviour.

Thanks to Jonas Seydel (thor77) for bringing this up.
2020-05-13 20:27:17 +01:00
Alberto Bertogli
7b0703eaa0 queue: Check that we can create the queue directory
When creating a new Queue instance, we os.MkdirAll the queue directory.

Currently we don't check if it fails, which will cause us to find out
about problems when the queue is first used, where it is more annoying
to troubleshoot.

This patch adjusts the code so that we check and propagate the error.
That way, problems with the queue directory will be more evident and
easier to handle.
2020-04-14 12:01:01 +01:00
Alberto Bertogli
25ebc4f2e2 Avoid unnecessary calls to fmt.Sprintf
The linter caught some unnecessary calls to fmt.Sprintf. This patch
removes them.

There are no functional changes.
2020-04-14 12:01:01 +01:00
Alberto Bertogli
d6b512166b Make it explicit when we are intentionally not checking errors
The linter complains that we're not checking for errors, but on some
cases it's on code paths were it is reasonable to do so (e.g. we're
closing the connection and it's a best-effort write).

This patch adjusts the code to make those cases explicit.
2020-04-14 12:01:01 +01:00
Alberto Bertogli
aed0156579 chasquid: Check result of initial os.Chdir
The daemon attempts to change to the config directory on startup, for
security and convenience.

We currently don't check if this works, which is not a big deal since it
will just fail later on when it can't find the files. However, it makes
things more awkward to debug, so this patch adds an explicit check.
2020-04-14 12:01:01 +01:00
Alberto Bertogli
4802e2f3e4 smtpsrv: Check TLS Handshake result
When receiving a message on a TLS socket, we currently don't check the
Handshake result, so connections often fail in a way that is not easy to
troubleshoot.

This patch fixes that by checking the result and emitting a nicer error
message before closing the connection.
2020-04-14 12:01:01 +01:00
Alberto Bertogli
0fd3941cf0 courier: Don't call testing.T.Fatalf from a goroutine
Calling testing.T.Fatalf from a new goroutine is not supported; since
this should be quite exceptional, we just panic instead.
2020-04-14 12:01:01 +01:00
Alberto Bertogli
15b79d9de9 chasquid-util: Check that we can create the database directory
When creating a database directory, we were missing the check to see if
it had succeeded, which would make issues more difficult to troubleshoot.

This patch adds the missing check.
2020-04-14 12:01:01 +01:00
Alberto Bertogli
929a9947bf chasquid-util: Use docopt.ParseDoc
docopt.Parse is deprecated. This patch updates the code to the newer
variant, ParseDoc, since the default options are what we want.

There are no functional changes.
2020-04-14 12:01:01 +01:00
Alberto Bertogli
d60c03f4d2 tests: Add Cirrus CI integration
This patch adds a configuration for https://cirrus-ci.org/, which
includes running the Go tests on FreeBSD.
2020-04-14 12:01:01 +01:00
Alberto Bertogli
2e1e188387 travis: Enable Go modules in 1.11
Currently the modules are ignored in the Go 1.11 build, because the
files are within $GOPATH.

This causes problems when some dependencies are updated in
backwards-incompatible ways, and assuming that Go modules are being
used. In particular, the new protobuf release caused this problem which
was caught by the automated builds:
https://travis-ci.org/github/albertito/chasquid/jobs/674701956.

This patch enables Go modules in 1.11 builds.

Thanks to Jonas Seydel (thor77) for the help investigating and finding a
fix for this problem.
2020-04-14 12:00:57 +01:00
Alberto Bertogli
2b9c2df9d3 docs: v1.3 release notes v1.3 2020-04-12 11:42:00 +01:00
Alberto Bertogli
9fbd1fe786 tlsconst: Update list of ciphers
This patch updates the list of ciphers in tlsconst, using the latest
list from IANA.
2020-04-12 11:25:27 +01:00
Alberto Bertogli
6815cf1d5c docs: Add Arch installation instructions
There is an AUR package for chasquid, so this patch adds references to
it in the documentation.

Thanks to Max Mazurov (fox.cpp@disroot.org) for adding the package.
2020-03-28 17:59:46 +00:00
Alberto Bertogli
4357379737 test: Implement retries on the load generator
If the load generator is sending emails too fast, chasquid queue might
hit the maximum size and fail the test.

This patch makes it sleep and retry, to give the server some time to
catch up.

Thanks to Max Mazurov (fox.cpp@disroot.org) for reporting this problem.
2020-03-28 16:42:04 +00:00
Alberto Bertogli
35c2d1d485 modules: Update go module versions
This patch updates the Go module versions to the latest available.
2020-03-27 08:55:34 +00:00
Alberto Bertogli
18716c25bb docker: Add dockerhub to the docs, and soften the warning
This patch adds a link to the dockerhub image mirror, as well as
softening the warning against the image, since by now it is reasonably
functional.
2020-03-23 01:39:39 +00:00
Alberto Bertogli
7814c64cfb gitlab: Upload images to dockerhub
It can be convenient to upload images to dockerhub for redundancy and
visibility, so this patch updates the gitlab CI configuration to do
that.

While at it, rename the stages for readability.
2020-03-23 01:28:46 +00:00
Alberto Bertogli
29512f7e4f testlib: Add tests for testlib.WaitFor 2020-03-21 23:56:31 +00:00
Alberto Bertogli
fdae72f275 testlib: Add comments and unexport unnecessary structs
This patch contains some readability improvements to testlib: it
adds/reformats some comments for exported functions for consistency, and
unexports some structs that are not used outside the library.
2020-03-21 23:32:28 +00:00
Alberto Bertogli
44140220b9 test: Improve DATA handling in the smtpsrv fuzzer
The smtpsrv fuzzer doesn't handle DATA commands particularly well:
it will continue to read but will skip lines that have STARTTLS as
content, and only really care for the first line due to a bug.

This patch fixes the handling, and moves the logic to a separate
function for readability.
2020-03-21 23:27:19 +00:00
Alberto Bertogli
c8fbf2ecc9 smtpsrv: Don't consider client EOF an error
When the client closes the connection, which is very common, chasquid
logs it as an error ("exiting with error: EOF").

That can be confusing and mislead users, and also makes a lot of
traces be marked as errored, when nothing wrong occurred.

So this patch changes the log to not treat it as an error.
2020-03-21 16:58:56 +00:00
Alberto Bertogli
fcbd20cd74 docs: Add a section on dovecot auth troubleshooting
This patch adds a section on dovecot authentication troubleshooting,
with common suggestions that can help identify what is going on when
the chasquid-dovecot interaction isn't working as expected.
2020-03-21 16:54:39 +00:00
Alberto Bertogli
65afb02cd5 docs: Document the use of SRS when doing alias forwarding
When an alias has a remote destination, chasquid uses sender rewriting
(also known as SRS [1]) to forward the email without risking being in
violation of SPF policies.

See https://en.wikipedia.org/wiki/Sender_Rewriting_Scheme for more
details.

This, however, wasn't documented anywhere, as noted in
https://github.com/albertito/chasquid/issues/6.

This patch adds a paragraph to the alias documentation explaining this
behaviour.
2020-03-21 14:15:47 +00:00
Alberto Bertogli
8fab350b59 courier: DNS temporary errors should cause temporary delivery failures
In the SMTP courier, when the MX lookup fails with a DNS temporary
error, we should propagate that up and cause delivery to fail with a
temporary error too.

That way the delivery can be attempted later by the queue.

However, the code today doesn't make the distinction and will treat any
temporary DNS error as a permanent delivery failure, which is a bug.

The bug was found by ludusrusso and reported in
https://github.com/albertito/chasquid/issues/4

This patch fixes the bug by propagating the error properly.
2020-03-12 22:07:22 +00:00
Alberto Bertogli
6641d858ad courier: Extend TODO for DNS error handling on Go >= 1.13
In https://github.com/albertito/chasquid/issues/4, ludusrusso comments
that the DNS lookup error handling in the SMTP courier could be improved
by using DNSError.IsNotFound.

That is true, but unfortunately it was only added in Go 1.13, and we are
currently trying to support Go 1.11 since that's what in Debian stable.

So this patch updates the TODO to note this, so that when we can use a
newer Go version, we improve this code.
2020-03-12 22:07:11 +00:00
Alberto Bertogli
150976b905 test: Use a pretty table for the coverage html
This patch improves the readability and usability of the generated
coverage HTML by making the list of files be a table.
2020-03-04 00:59:37 +00:00
Alberto Bertogli
a1ca50ab57 hooks: Add mising quote in the example post-data hook
The example post-data hook was missing a quote around a sub-shell
execution.

This is harmless because the content itself is admin-provided and not
related to user input, but this commit fixes the quote for defense in
depth and consistency.
2020-02-02 02:07:38 +00:00
Alberto Bertogli
0df2e325ed docs: v1.2 release notes v1.2 2019-12-06 15:33:07 +00:00
Alberto Bertogli
8f2eba5795 docs: Add release notes, replacing the upgrading notes
This patch replaces the upgrading notes, which focused only on
backwards-incompatible changes, with more detailed release notes.
2019-12-06 15:19:50 +00:00
Alberto Bertogli
4edcd79a25 smtpsrv: Keep reading DATA input even if it's too large
When the DATA input is too large, we should keep on reading through it
until we reach the end marker, otherwise there is a security problem:
the remaining data will be interpreted as SMTP commands, so for example
a forwarded message that is too long might end up executing SMTP
commands under an authenticated user.

This patch implements this behaviour, while being careful not to consume
extra memory to avoid opening up the possibility of a DoS.

Note the equivalent logic for single long lines is already implemented.
2019-12-04 01:46:54 +00:00
Alberto Bertogli
28cb9169cc test: Add SPF integration test
This patch adds a new integration test to cover SPF checks. The main
goal is not to cover the SPF parsing, since that's handled by the
library already, but the higher level aspects: that the mails are indeed
rejected, that the DSN looks reasonable, etc.
2019-12-01 22:13:31 +00:00
Alberto Bertogli
6000d07ad0 test: Test multiline headers in hook output
Hook output is checked to see if it looks like a header, which includes
the possibility of multi-line headers.

This patch extends the tests to include a multi-line header, to prevent
accidental regressions.
2019-12-01 20:38:50 +00:00
Alberto Bertogli
45a294403d test: Test permanent hook failure
This patch adds a test to make sure we handle correctly the case where a
hook exits with a permanent failure.
2019-12-01 20:31:59 +00:00
Alberto Bertogli
a12875162f smtpsrv: Test too many recipients
This patch adds a test to make sure we don't allow too many recipients.
2019-12-01 19:37:47 +00:00
Alberto Bertogli
99c4ad5ef7 smtpsrv: Disable reloads during tests
Reloading during tests will cause the testing aliases to be removed,
which makes test runs that extend beyond 30s to be flaky.

This patch fixes the bug by disabling reloads during these tests.
2019-12-01 19:09:58 +00:00
Alberto Bertogli
e8a6bf6188 smtpsrv: Make tests log maillog to stdout 2019-12-01 19:09:57 +00:00
Alberto Bertogli
a6a964ac3e test: Move testing couriers to testlib
The testing couriers are currently only used in the queue tests, but we
also want to use them in smtpsrv tests so we can make them more robusts
by checking the emails got delivered.

This patch moves the testing couriers to testlib, and makes both queue
and smtpsrv use them.
2019-12-01 19:09:12 +00:00
Alberto Bertogli
99df5e7b57 smtpsrv: Limit incoming line length and improve large message handling
Currently, there is no limit to incoming line length, so an evil client
could cause a memory exhaustion DoS by issuing very long lines.

This patch fixes the bug by limiting the size of the lines.

To do that, we replace the textproto.Conn with a pair of buffered reader
and writer, which simplify the code and allow for better and cleaner
control.

Thanks to Max Mazurov (fox.cpp@disroot.org) for finding and reporting
this issue.
2019-12-01 19:07:58 +00:00
Alberto Bertogli
d7006d0e16 smtp: Limit incoming line length
On the smtp client package, there is no limit to the length of the
server's replies, so an evil server could cause a memory exhaustion DoS
by issuing very long lines.

This patch fixes the bug by limiting the total size of received data.
Ideally this would be done per-line instead, but gets much more complex,
so this is a compromise.

The limit chosen is 2 MiB, which should be plenty for any the total size
of server-side replies, considering we only send a single message per
connection anyway.

This is similar to 06d808c (smtpsrv: Limit incoming line length), which
was found and reported by Max Mazurov (fox.cpp@disroot.org).
2019-12-01 17:25:25 +00:00
Alberto Bertogli
bf01fab893 travis: Increase minimum supported version to 1.11
We want Travis CI to check against the Go version shipped in the latest
Debian stable, to make sure chasquid can be built and run there.

There was a new Debian release which has Go 1.11, so raise the CI config
version accordingly.
2019-12-01 17:25:25 +00:00
Alberto Bertogli
34339c4572 smtpsrv: Add fuzz testing
This patch adds a fuzz test for the smtpsrv package.

It brings up a server for test, and then fuzz the data sent over the
network.
2019-11-30 11:38:46 +00:00
Alberto Bertogli
933b979220 smtpsrv: Don't hard-code ports in tests
The smtpsrv tests hard-code ports, but this patch fixes that by making it
use the new testlib.GetFreePort function.
2019-11-30 11:38:46 +00:00
Alberto Bertogli
d0f65881c9 smtpsrv: Allow manual override of submission+TLS port in tests
The smtpsrv server tests allow manual override of testing ports via
flags, but the submission+TLS port was missing (accidental oversight).
2019-11-30 11:38:46 +00:00
Alberto Bertogli
ac2c5ab4db test: Add testlib.GetFreePort function
Some tests require picking ports, and today resort to hard-coding,
which is brittle.

This patch adds a testlib.GetFreePort function to help pick free ports.

It is not totally race-free, but is much better than hard-coding.
2019-11-30 11:38:46 +00:00
Alberto Bertogli
87e5acde59 docs: Add missing reference to upgrading.md in the index 2019-10-31 21:40:15 +00:00
Alberto Bertogli
0c92fb4937 docs: Add section about monitoring with Prometheus
This patch adds a section to the monitoring docs with an example of how
to use the prometheus-expvar-exporter to monitor chasquid with
Prometheus.
2019-10-31 21:38:34 +00:00
Alberto Bertogli
8b80e9fc2e docs: Add missing monitoring expvar, correct minor wording 2019-10-31 21:36:58 +00:00