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

419 Commits

Author SHA1 Message Date
Alberto Bertogli
a92497aef0 travis: Increase minimum supported version to 1.9
As of a29dc8fd (2019-04-26), golang.org/x/crypto requires math/bits.
math/bits was introduced in Go 1.9, so we can no longer build from head
using 1.7.

Building using Debian's packaged dependencies should work just fine, but
since we want Travis to build from head, this commit updates the minimum
supported version to 1.9.
2019-05-05 13:04:04 +01:00
Alberto Bertogli
a5edd9053f queue: Make DSN tidier, especially in handling multi-line errors
This patch contains some changes to generate tidier DSNs, which should
make them slightly more readable.

In particular, it also makes it able to handle multi-line errors much
better than before.
2019-05-04 21:28:07 +01:00
Alberto Bertogli
cac1e161ac smtpsrv: Set connection deadline before the initial greeting
When handling a connection, today we only set a deadline after each
command received.

However, this does not cover our initial greeting, or the initial TLS
handshake (if the socket is TLS), so a connection can hang
indefininitely at that stage.

This patch fixes that by setting a deadline earlier, before we send or
receive anythong on the connection.
2019-03-31 12:13:09 +01:00
Alberto Bertogli
ec95131bb4 Miscellaneous style fixes
This patch has some miscellaneous style fixes to issues found by the
staticcheck tool.

There are no functional changes.
2019-02-10 12:46:15 +00:00
Alberto Bertogli
582da79eca UPGRADING: Add (no-op) note for the upcoming version v0.07 2019-01-19 00:28:16 +00:00
Alberto Bertogli
1ecc957aba queue: Internationalized Delivery Status Notifications (DSN)
Our non-delivery status notifications are quite simple today, but that
makes it much more difficult to support internationalization and
cross-language reporting.

There is a standard for internationalized DSNs, RFC 6533 (which builds
on top of the structured DSNs from RFC 3464).

This patch changes our DSN messages to be based on those standards, so
it is easier for MUAs to display reports according to the users'
languages preferences.

Note we still use message/rfc822 + 8bit to transmit the message, instead
of message/global, for compatibility reasons. This seems to be more
universally compatible, but the decision might be revisited in the
future. See RFC 5335 (section 4.6 in particular).
2019-01-18 23:27:10 +00:00
Alberto Bertogli
abf91eac8d test: Make mail_diff support comparing multipart messages
In upcoming patches we will want to compare mime-multipart messages, so
this patch extends the mail_diff test helper to support it.
2019-01-18 14:54:29 +00:00
Alberto Bertogli
e7309a2c7b smtpsrv: Send enhanced status codes
SMTP supports enhanced status codes, which help with
internationalization and accessibility in cases where protocol errors
make their way to the users.

This patch makes chasquid include these extended status codes in the
corresponding replies, as well as advertising support in the EHLO reply.

Main references:
- RFC 3463 (https://tools.ietf.org/html/rfc3463)
- RFC 2034 (https://tools.ietf.org/html/rfc2034)
- SMTP Enhanced Status Codes Registry
  (https://www.iana.org/assignments/smtp-enhanced-status-codes/smtp-enhanced-status-codes.xhtml)
2019-01-10 15:44:25 +00:00
Alberto Bertogli
78937aca93 travis.yml: Add IRC notifications 2018-12-02 01:23:49 +00:00
Alberto Bertogli
4db9ffec09 Code style improvements
This patch contains some minor code style improvements, to leave the
linter happier and generally follow best practices in some areas where
things snuck through.
2018-12-01 11:58:50 +00:00
Alberto Bertogli
4296e28074 test: Fix flaky courier test
In the upcoming Go release, logging from a finished testing.T triggers a
panic.  In the courier tests, this is possible because we don't wait for
completion of fakeServer before ending the test.

This patch makes the tests wait for fakeServer to finish before exiting,
removing the race.
2018-11-30 10:03:48 +00:00
Alberto Bertogli
f4b41b6725 gitlab-ci.yml: Add a configuration file for GitLab CI
This patch adds a configuration file for the GitLab CI environment, to
run the integration tests with docker.
2018-11-30 10:03:48 +00:00
Alberto Bertogli
dd7cfaebf2 test: Use minidns in the Docker tests
The integration tests depend on having a DNS server that resolves
"localhost", which is unfortunate but currently unavoidable given
glibc's limitations ($HOSTALIASES only works on DNS-level aliases, and
does not do lookups in /etc/hosts).

Even under docker, this makes the tests depend on the DNS server, and
whether it resolves localhost or not.

In order to make the docker tests more hermetic and isolated from the
environment, this patch introduces a docker entrypoint that, within the
container, will launch minidns and override /etc/resolv.conf to use it.

This guarantees that the tests will be able to resolve localhost, and
also avoid accidental reliance on external DNS zones.
2018-11-30 10:03:48 +00:00
Alberto Bertogli
57f5a09901 test: Replace dnsmasq with minidns
This commit replaces test/t-14-tls_tracking usage of dnsmasq (an
external test dependency) with our new minidns.
2018-11-30 10:03:48 +00:00
Alberto Bertogli
a0ae5fb41b test/util: Add mini DNS server for testing purposes
This is a mini-DNS server for testing purposes.

This can be used to set up hermetic tests in containers, and work around
glibc's limitation of being unable to create per-process host aliases.
2018-11-30 10:03:48 +00:00
Alberto Bertogli
661f759c0c test: Allow up to 2 loops in the loop integration test
In the loop integration test, we detect looping via checking the expvars
of chasquid, and waiting for the loop counter to be 1.

However, if chasquid is fast enough, it will go up to 2 before the
detection notices. This is because the DSN that gets generated also
loops (as expected).
2018-11-30 10:03:48 +00:00
Alberto Bertogli
29709a0d58 smtpsrv: Improve "Received" header standard compliance
Despite its loose appearance, the "Received" header has a reasonably
standarized format.

We were not following the standard format as closely as we should; this
rarely causes problems in this particular case, but there's no need to
deviate from it.

This patch changes the Received header generation as follows:

 - The "from" section now uses the remote address as canonical (for
   non-authenticated users) which provides more valuable information
   than the user-supplied EHLO address (which is also included).
 - The remote authenticated user is now hidden, for additional privacy.
 - Use the "with" optional clause.
 - Use the standard way of printing TLS cipher suite.
 - Use the standard way of printing address literals.
2018-11-30 10:03:48 +00:00
Alberto Bertogli
328008061d tlsconst: Update TLS cipher suites, and include TLS 1.3
This patch updates the list of known TLS cipher suites, and adds TLS 1.3
to the list of known versions (it will be included in Go 1.12).
2018-11-30 10:03:48 +00:00
Alberto Bertogli
d0c7c3d40a tests: Reorder Dockerfile statements to allow caching
Docker creates intermediate layers on each command (for most commands),
but the COPY was invalidating them too early, every time it runs it was
generating a different layer.

This patch moves the COPY down to the bottom, and adds a bit more
organization to the commands below.
2018-11-30 10:03:48 +00:00
Alberto Bertogli
4ecc5461d3 Add driusan/dkim integration example and tests
This patch adds DKIM signing using https://github.com/driusan/dkim tools
to the example hook.

It also adds an optional integration test to exercise signing and
verification, and corresponding documentation.
2018-11-30 10:03:48 +00:00
Alberto Bertogli
ebad590c31 README: Remove codefresh.io integration
codefresh.io now requires to be logged in to view the status, and very
extensive permissions to even log in.

So I've removed the hook from the repository.
2018-09-27 00:14:49 +01:00
Alberto Bertogli
2dfed059e4 MTA-STS is now RFC 8461
MTA-STS has been published as RFC 8461, with no major changes since the
last draft we updated (-18).

This patch updates the documentation accordingly (no code changes).
2018-09-26 21:42:50 +01:00
Alberto Bertogli
5878fc74f3 docs/man: Make chasquid.1 description match the README file v0.06 2018-07-22 11:15:40 +01:00
Alberto Bertogli
a2fa1d07d1 docs/man: Make generate script use git timestamps
When regenerating the manpages, the mtime of the pod files is used.
That mtime can change based on file and repository manipulations,
because git does not preserve mtimes.

This causes unnecessary regenerations which require manual cleanups in
order to avoid cluttering the history unnecessarily.

This patch makes the generate script set the mtime of the pod files to
the time of the last git commit that affected them, if they have not
changed since. This avoids unnecessary changes and makes the script
easier to use.

There's one file that needed adjustment to match its last commit time,
that is also included here.
2018-07-22 11:11:08 +01:00
Alberto Bertogli
910c6e9cc9 test: Add workarounds for dovecot 2.3
The current dovecot config for integration test t-11-dovecot is not
compatible with dovecot 2.3. There are some new services which want to
change the group owner for some files to the default, and that does not
work when run as non-root.

The errors look like:

  master: Error: service(stats): chown(/tmp/chasquid-dovecot-test/run/stats-writer, 4294967295, 127) failed: Operation not permitted
  master: Error: service(imap-hibernate): chown(/tmp/chasquid-dovecot-test/run/imap-hibernate, 4294967295, 127) failed: Operation not permitted
  master: Error: service(dict): chown(/tmp/chasquid-dovecot-test/run/dict, 4294967295, 127) failed: Operation not permitted
  master: Error: service(dict-async): chown(/tmp/chasquid-dovecot-test/run/dict-async, 4294967295, 127) failed: Operation not permitted
  master: Fatal: Failed to start listeners

(127 is the "dovecot" user)

So this patch adds some config settings to set the group manually for
these services, which is backwards compatible with 2.2.

Eventually we will stop supporting 2.2 for tests, at which point we can
change to just setting default_internal_group.
2018-07-15 13:15:10 +01:00
Alberto Bertogli
554d97f5f2 UPGRADING: Add "no-op" messages for all versions
It's better to be explicit about version upgrades where no changes were
needed, so this patch updates the UPGRADING.md file to include them.

Note it includes the upcoming 0.06 version, for which no
backwards-incompatible change is expected.
2018-07-14 10:46:41 +01:00
Alberto Bertogli
dbd8bd7699 chasquid: Update docstring to match the README file 2018-07-14 10:45:10 +01:00
Alberto Bertogli
644cd63eff sts: Use keyed fields in io.LimitedReader literal
Flagged by go vet:
internal/sts/sts.go:256: io.LimitedReader composite literal uses unkeyed fields
2018-07-14 10:23:36 +01:00
Alberto Bertogli
770a618c84 docs: Fix "chasquid-util user-add" typo 2018-07-14 10:08:27 +01:00
Alberto Bertogli
2d1711ac47 README: Add MTA-STS reference 2018-07-14 10:08:27 +01:00
Alberto Bertogli
ccb9ba47d2 smtp: Remove --experimental__enable_sts flag
This patch removes the --experimental__enable_sts flag, making STS
checking the default.
2018-07-14 10:08:27 +01:00
Alberto Bertogli
0ee7cb4cce sts: Add documentation and fix minor style issues
This patch adds some missing function documentation entries, and fixes
minor style issues caught by the linter.

No functional changes.
2018-07-14 10:08:27 +01:00
Alberto Bertogli
46bce576e8 sts: Add miscellaneous tests
This patch adds a few miscellaneous tests to the sts package, covering
various previously-untested code paths.
2018-07-14 10:08:09 +01:00
Alberto Bertogli
79a8cfc21c sts: DNS TXT record support
This patch adds support for checking the MTA-STS TXT record before
fetching the policy via https.

The content of the record is unused.
2018-07-01 12:19:02 +01:00
Alberto Bertogli
8bf584bd86 sts: Don't pre-filter MX list, but skip them if needed
Instead of pre-filtering the MX list based on STS policy, just check
if it's allowed before each attempt, and skip it if not.

This simplifies the code.
2018-07-01 12:19:02 +01:00
Alberto Bertogli
252ab5d3e3 sts: Update to draft-ietf-uta-mta-sts-18
This patch updates the STS implementation from draft version 02 to 18.

The main changes are:

 - Policy is now in an ad-hoc format instead of JSON (😒).
 - Minor policy well-known URL change (now ends in ".txt").
 - Enforce HTTP media type == text/plain, as with the ad-hoc format this
   becomes much more important.
 - Simplify wildcard mx matching (same algorithm), extend test cases.
 - Valid modes are "enforce" (as before), "testing" (replaces "report"),
   and "none" (new).
2018-07-01 12:19:02 +01:00
Alberto Bertogli
23deaf1f88 Reinstate the MTA-STS (Strict Transport Security) implementation
This commit brings back the experimental MTA-STS (Strict Transport
Security) implementation, removed in commit
7f5bedf4aa.

We will continue development in the "sts" branch, subject to rebase,
until it is ready to be integrated into "next" again.
2018-07-01 12:19:02 +01:00
Alberto Bertogli
a94253ba25 docs: Fix minor typo in chasquid.conf.5.pod 2018-06-06 19:47:09 +01:00
Alberto Bertogli
17b7bbe9c6 dovecot: Remove "experimental" qualifiers
dovecot support has been around for a release, has decent testing and
seems stable enough to remove the "experimental" qualifier.
v0.05
2018-06-04 23:45:18 +01:00
Alberto Bertogli
cf81fbee74 dovecot: Add tests for more error cases
This patch adds more tests for the dovecot library, in particular:
 - Protocol errors (invalid versions, etc.).
 - Invalid command (cli-specific test).
 - Connection breakups.
2018-06-04 01:34:32 +01:00
Alberto Bertogli
36692b52d3 dovecot: Include cli-based tests in the coverage tests
Many areas of the dovecot library are tested via chamuyero scripts, but
these were not being included in the coverage report.

This patch extends the dovecot-auth-cli tests so that they are now
coverage-aware.
2018-06-04 01:18:24 +01:00
Alberto Bertogli
5adb13311b testlib: Add missing comment 2018-06-04 00:06:23 +01:00
Alberto Bertogli
bbe9f4187d protoio: Test some I/O errors
This patch adds some test cases for I/O errors, in particular when
reading, writing and listing from files that don't exist or that we
shouldn't have permissions to access.
2018-06-04 00:04:57 +01:00
Alberto Bertogli
26017548ef courier: Extend MX lookup tests
This patch adds more tests to the MX lookup process, covering some
unusual cases that were missing.
2018-06-04 00:04:57 +01:00
Alberto Bertogli
b24f02e3a5 test: Test noise in the "certs" directory
This patch adds some border cases to the "certs" directory in one of
the test cases, so we check that chasquid does not get confused with
them.
2018-06-03 23:51:04 +01:00
Alberto Bertogli
029bca7013 test: Add TLS tracking integration test
This patch adds a new test, which verifies the TLS tracking.

Because we need to simulate SPF records, and Go does not support fully
intercepting DNS lookups yet, this test relies on dnsmasq to provide a
DNS resolver.

In the future, once Go supports DNS lookup interception, we can get rid
of this additional dependency.
2018-06-02 19:31:28 +01:00
Alberto Bertogli
4373f56a82 chasquid-util: Add domaininfo-remove
This patch adds a chasquid-util subcommand to remove a domain
information entry.

The main use case is to manually allow a security level downgrade, after
performing manual verification.
2018-05-24 23:02:57 +01:00
Alberto Bertogli
a177fec7c3 domaininfo: Reload periodically
This patch makes chasquid reload domaininfo periodically, so it notices
any external changes made to it.

It is in line with what we do for aliases and authentication already,
and makes it possible for external removals an additions to the
domaininfo database to be picked up without a restart.
2018-05-20 13:18:17 +01:00
Alberto Bertogli
2064e9e65d queue: Increase retry time from 12h to 20h
Some transient issues might take more than 12h to resolve, specially if
they happen overnight.

20h gives a bit more margin for retries, while still being short enough
so that users are notified early.
2018-05-20 12:05:32 +01:00
Alberto Bertogli
97826d4f88 README: Match wording with website
Rewrite some of the paragraph to make them (hopefully) clearer, reorder
the feature list in a 2-level structure for more legibility, reference
the IRC channel, and other minor wording changes.
2018-05-20 12:05:32 +01:00