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
5c09138db8 chasquid-util: Remove dependency on docopt-go
The docopt-go library is quite convenient, but it has been abandoned for
a while :(

Since we only use it for chasquid-util, this patch removes it and
replaces it with a custom small parser, that is a reasonable fit for the
required use cases.

The patch also adds a couple of tests to increase coverage.

NOTE: docopt-go accepted some undocumented behaviour, in particular the
use of "-a b" instead of "-a=b". The new parser does not, so some
user scripts may require updating.

I think this should be rare enough not to be worth the complexity of
adjusting the parser to allow it.
2021-01-16 23:21:35 +00:00
Alberto Bertogli
def6e1cee2 dovecot-auth-cli: Test invalid arguments handling
This patch adds a minor test to dovecot-auth-cli to verify that the
check for invalid number of arguments is working as expected.

It's mostly for consistency, as the utility is only used for testing
purposes.
2021-01-16 23:21:35 +00:00
Alberto Bertogli
34b1f6cf21 expvarom: Add EOF marker, and minor documentation updates
This patch adds the EOF marker as required by the new specification, and
also adds some links to it in the comments, as reference.
2021-01-16 13:08:46 +00:00
Alberto Bertogli
887a1cef68 gitlab-ci: Only run the image jobs if we have credentials
The image jobs should only run if there are valid credentials for
pushing the images to the respective registries, to avoid false
negatives in the test pipeline.

This can happen when the gitlab CI is run on projects that aren't set up
to push docker images, either because they're clones of the official
repo, or they are under a different gitlab instance (e.g. Debian's
salsa).

We do it by using a "rules:if" clause on specific variables:
- for Docker, $DOCKER_REGISTRY_USER which is set externally
- for GitLab, $CI_REGISTRY_IMAGE which has the address of the registry
  tied to the project.

Note that for GitLab we can't use the credentials for conditional
execution directly, since they are "persisted variables" which are not
available in this context (see [1] for more details). The
$CI_REGISTRY_IMAGE should be good enough to determine whether image
registry is enabled for the repo.

[1]: https://docs.gitlab.com/ee/ci/variables/where_variables_can_be_used.html#persisted-variables
2020-11-22 12:46:58 +00:00
Alberto Bertogli
aa9455c418 test: Ignore fexp in the regular Go build
fexp is a testing utility, including it in the regular Go build confuses
some automation as it can think it's part of chasquid proper.

All other testing utilities are ignored via the "+build ignore"
annotation for this reason, so this patch adds it to fexp to fix this
issue.
2020-11-22 11:57:14 +00:00
Alberto Bertogli
78df715a02 docs: v1.6 release notes v1.6 2020-11-22 09:35:08 +00:00
Alberto Bertogli
8769e01f23 test: Update haproxy test config
The haproxy test config includes an obsolete "debug" entry, and is
missing some timeouts which, while harmless in this context, cause a
warning that can be confusing.

This patch fixes the debug entry by running haproxy -d as recommended,
and adds the essential timeouts to avoid the warning.
2020-11-22 09:35:08 +00:00
Alberto Bertogli
a9d7e36d29 gitlab: Export test directory as an artifact
To debug test failures, it can be convenient to explore the contents of
the test directories after the test runs, as they contain logs and
generated files.

This patch configures the GitLab CI to export the repo tree (which
includes the test directory) as GitLab CI artifacts, so they can be
easily accessed after the tests have completed.
2020-11-13 20:49:42 +00:00
Alberto Bertogli
e79586a014 Implement HAProxy protocol support
This patch implements support for incoming connections wrapped in the
HAProxy protocol v1.

This is useful when running chasquid behind a HAProxy server, as it
needs the original source IP to perform SPF checks.

This patch is a reimplementation of one originally provided by Denys
Vitali in pull request #15, except the logic for the protocol handling
is moved to a new package, and the smtpsrv.Conn handling of the source
IP is simplified.

It is marked as experimental for now, since we want to give it a bit
more exposure just in case the option/api needs adjustment.

Thanks a lot to Denys Vitali (@denysvitali in github) for sending the
original patch for this, and helping test it!
2020-11-13 20:49:42 +00:00
Leandro Lucarella
c9d3ba0ca0 Add @domain to chasquid-util --help where appropriate
This makes it more clear how to specify which domain the user being
operated on is the sub-command targeting when using `--help`.

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Update code to match the updated parameter name.
2020-11-12 23:24:21 +00:00
ThinkChaos
bb1b921e3c Add /exit endpoint to monitoring server
Allows terminating chasquid via the network. Useful to trigger a restart
(if there is an init system to relaunch chasquid) and thus reload certificates.

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Added tests, and adjusted shutdown sequence.
2020-11-12 23:24:21 +00:00
Alberto Bertogli
e9c6775418 test: Remove dependency on wget
This patch removes the dependency on wget for fetching content over
http, which was used in one of the tests to do some checking on debug
and metric pages, as well as loop detection.

Instead of wget, we now use a small built-in utility called fexp.
2020-11-12 23:24:21 +00:00
Alberto Bertogli
025cb2d96a courier: Rename Procmail to MDA
This patch renames courier.Procmail to courier.MDA, to make it more
obvious that the functionality is not tied to that particular MDA.

It's just for readability, there are no functional changes.
2020-09-17 02:47:42 +01:00
Alberto Bertogli
1cc7b9a864 smtpsrv: Pass EHLO/HELO domain to the post-data hook
Some utilities might want to access the EHLO/HELO domain in the
post-data hook (for example, to do additional SPF validations).

This patch implements that support, including sanitizing the EHLO domain
on the environment variable to reduce the risk of problems.
2020-09-17 01:29:49 +01:00
Alberto Bertogli
5bebb00af9 smtpsrv: Rename internal variable ehloAddress -> ehloDomain
The EHLO parameter is generally referred to as "domain", even though it
can take either a domain or an address.

For clarity, rename the variable and comments to match.

This is stylistic only, there are no functional changes.
2020-09-17 01:29:49 +01:00
Alberto Bertogli
4c26713f40 docs: Add details about the hook variables
This patch adds some wording to explain each of the hook variables.
2020-09-17 01:29:49 +01:00
Alberto Bertogli
7914590cfa docs: Update and extend links to distribution packages
This patch updates and extends the links to the distribution packages,
referencing them from the README (it's more likely to be what the reader
wants to see), and also extending the Arch packaging with binary package
information.
2020-09-13 11:31:31 +01:00
Alberto Bertogli
9e3c102f34 docs: v1.5 release notes v1.5 2020-09-12 12:03:25 +01:00
Alberto Bertogli
1fcc4ffe0f queue: Remove dependency on external protobuf package
The queue protobuf definition currently uses the well-known timestamp
protobuf package.

This adds a build-time dependency on it, which is fairly harmless when
building from source (since the golang protobuf compiler includes it
already), but adds overhead for packaging on distributions.

Since this is the only external proto dependency we have, and the
protobuf message itself is trivial, this patch removes it an instead
embeds a compatible definition.

That way we remove the dependency and simplify packaging, with almost
negligible code overhead.

The change is fully backwards compatible and has no functional changes.
2020-09-12 10:56:17 +01:00
Alberto Bertogli
48c37b5687 monitoring: Show the go version used to build the binary
This patch makes the monitoring web server index show the go compiler
version used to build the binary, which can be convenient when
troubleshooting.
2020-09-11 12:34:36 +01:00
Alberto Bertogli
a2ce7c7323 docs: Minor style changes to the monitoring documentation
This patch contains minor style and formatting changes to the Monitoring
documentation, to (hopefully) improve readability and consistency.
2020-08-21 12:07:33 +01:00
Alberto Bertogli
7fe42a368a monitoring: Add OpenMetrics exporter
This patch makes chasquid's monitoring server expose an OpenMetrics
metrics endpoint.

It adds a new package "expvarom" which implements an HTTP handler that
exports expvar variables in the OpenMetrics text format.

Then, the handler is registered by the monitoring server at /metrics
(where most things expect it to be).

The existing exported variables are also extended with descriptions,
which is optional, but improves the readability of the metrics.
2020-08-21 12:07:33 +01:00
Alberto Bertogli
7e412db19b test: Check debugging pages are not empty
When testing the debugging pages, do a quick check to verify that the
returned pages are not empty.

This covers the case where a template fails to execute at runtime, and
without this change it wouldn't be caught by tests.
2020-08-20 00:08:36 +01:00
Alberto Bertogli
607a455b20 docs: Update README links to the documentation
The documentation is now available directly at
https://blitiri.com.ar/p/chasquid/, so remove the /docs/ suffix from the
links in the README.

The /docs/ variant will continue to be functional for a while anyway.
2020-07-30 00:16:14 +01:00
Alberto Bertogli
bee37ef7a4 modules: Update blitiri.com.ar/go/spf to v1.1.1
This patch updates the blitiri.com.ar/go/spf dependency to v1.1.1, which
includes a fix for potential mismatches with a:, mx: and ptr:.
2020-07-28 02:12:29 +01:00
Alberto Bertogli
a6a20fb6e0 monitoring: Add a config dump handler
This patch adds a handler to the monitoring HTTP server which dumps
the parsed config, so it can easily be reviewed for troubleshooting.
2020-07-28 02:12:29 +01:00
Alberto Bertogli
33446fd565 monitoring: Reorganize index structure
This patch improves the organization of the monitoring index page:

- Include the hostname (both OS and configured) for convenience.
- Round the uptime presentation for readability.
- Add a tiny CSS for consistency with the traces.
- Re-arrange the list of links for readability.
2020-07-08 23:23:17 +01:00
Alberto Bertogli
a08b86a663 Move monitoring HTTP server code to a separate file
This patch moves the monitoring HTTP server code to its own file, for
readability purposes only.
2020-07-08 22:15:37 +01:00
Alberto Bertogli
380da0c1a1 dovecot-auth-cli: Add help message
The dovecot-auth-cli binary can be useful to debug and troubleshoot
dovecot auth issues.

This patch adds a small help message to make it easier for users to
understand how to use it.
2020-07-08 00:30:11 +01:00
Alberto Bertogli
35e19dc4a2 protoio: Use new protobuf API for text marshalling
This patch makes protoio use the new protobuf API for
marshalling/unmarshalling text protobufs, as well as extends the tests
to cover marshalling failures.

The protobuf text output is not stable/deterministic and some spaces are
added randomly, so some integration tests have to be adjusted to account
for it.
2020-06-30 11:14:52 +01:00
Alberto Bertogli
4116c046bc hooks: Ignore rspamd's greylist action
The default hook will use rspamc (the command-line client of rspamd) if
it is installed. rspamc will emit one suggested action, and then the
hook will interpret it and return accordingly.

Because the possible actions returned by rspamc are user-configured,
this patch adds a comment to make it clear that the hook will need
adjustment if the configuration uses non-default actions.

In particular, the greylisting module (which usually handles the
"greylist" action) is not run when using rspamc. This can cause
unnecessary rejections and is quite misleading.

This patch removes the "greylist" action handling; now the default hook
will only reject mail once it reaches rspamd's configured threshold for
direct rejection.

In the future, a more custom integration with rspamd might be added to
allow for rspamd-based greylisting, but until then this is a more
reasonable default.

Thanks to Jonas Seydel (thor77) and Max Mazurov (fox.cpp@disroot.org)
for noticing this issue, helping investigate, and discussing the course
of action.
2020-06-01 21:05:02 +01:00
Thor77
b6248f3089 hooks: Fix output of command -v dkimsign added to message
When checking if the dkimsign command exists, the default hook doesn't
redirect the output to /dev/null, so if the command is present it will
emit unwanted output (interpreted as message headers, as expected).

This patch adds the missing redirection.

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Extended commit message.
2020-06-01 14:18:11 +01:00
Alberto Bertogli
d781b3f403 Update blitiri.com.ar/go/systemd to v1.1.0
This patch updates the modules to blitiri.com.ar/go/systemd v1.1.0.

There are no significant changes, but it's the first version which
supports go modules.
2020-05-29 02:04:07 +01:00
Alberto Bertogli
d9d56552f3 maillog: Support logging to stdout and stderr
This patch adds support for writing maillog to stdout and stderr, which
can be desirable in certain environments.

Thanks to Denys Vitali <denys@denv.it> who sent an alternative patch for
this functionality.
2020-05-24 02:26:18 +01:00
Alberto Bertogli
d83c1dc591 smtpsrv: Fix error code on transient authentication issues
When we can't authenticate due to a transient issue, for example if we
rely on Dovecot and it is not responding, we should use a differentiated
error code to avoid confusing users.

However, today we return the same error code as when the user enters the
wrong password, which could confuse users as their MUA might think their
credentials are no longer valid.

This patch fixes the issue by returning a differentiated error code in
that case, as per RFC 4954.

Thanks to Max Mazurov (fox.cpp@disroot.org) for reporting this problem.
2020-05-23 01:05:12 +01:00
Alberto Bertogli
b4c8244e48 modules: Update blitiri.com.ar/go/spf to v1.1.0
This patch updates the modules to blitiri.com.ar/go/spf v1.1.0.

There are no significant changes, but it's the first version which
includes go modules.
2020-05-22 22:41:39 +01:00
ThinkChaos
db810084a0 Reopen logs on SIGHUP
This makes it possible to manage chasquid logs using logrotate.

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Added tests, minor style and comment changes.
2020-05-22 20:34:42 +01:00
ThinkChaos
ade107f62e maillog: Use blitiri.com.ar/go/log for mail log
In preparation for supporting log rotation, this patch makes the maillog
package to use blitiri.com.ar/go/log instead of its own writer.

Some of the tests are made more strict, to better test the log format.

Amended-by: Alberto Bertogli <albertito@blitiri.com.ar>
  Fixed build, extended commit message, adjusted to the log options
  API, and added tests.
2020-05-22 20:09:19 +01:00
Alberto Bertogli
0f686399b6 modules: Update blitiri.com.ar/go/log to v1.1.0
This patch updates the modules to blitiri.com.ar/go/log v1.1.0.

That version includes new APIs we will rely on in subsequent patches.
They are experimental but it should be fine for our case, and we can
adjust if they change.
2020-05-22 20:08:14 +01:00
Alberto Bertogli
9fe790d7c6 aliases: Log the "alias-exists" hook output, for debugging
The output of the alias-exists hook is unused, so currently it's
discarded silently.

However, it can be very useful to debug issues when the hook is not
working as expected.

So this patch makes chasquid log the combined output (stdout and stderr)
to the execution trace.
2020-05-22 14:43:28 +01:00
Alberto Bertogli
bee7a9f193 docs: v1.4 release notes v1.4 2020-05-22 12:59:29 +01:00
Alberto Bertogli
aacd50e87a modules: Update Go module versions
This patch updates the Go module versions to the latest available.
2020-05-22 12:59:29 +01:00
Alberto Bertogli
4367c9e059 travis: Remove references in documentation, allow to fail
The Travis tests don't work due to a Travis networking issue reaching
some external hosts.

Until it is fixed, remove references from the documentation, since its
output is misleading.

We also allow it to fail, which makes the GitHub UI not show commits as
having failed tests because of Travis.

Since the previous commit, GitLab CI does almost all the same tests, so
there should be no significant loss of coverage anyway.
2020-05-22 12:11:27 +01:00
Alberto Bertogli
a48af00162 gitlab-ci: Run go tests on multiple versions
This patch makes the GitLab CI config run go tests on Go 1.11 and the
latest Go release.

This is in addition to existing tests (which are renamed for clarity).

This replaces the main use case of Travis CI, which was to test on
multiple Go versions.
2020-05-17 11:49:03 +01:00
Alberto Bertogli
f296bc31a8 cirrus: Allow the testing user to write to $GOPATH
Cirrus CI caches the module directory inside $GOPATH so it can be shared
between test runs, to speed them up.

However, it is currently created as root, which causes new entries to
fail since they run under the "testing" user.

This patch fixes that problem by making the "testing" user own the
entire $GOPATH, which includes the module directory.
2020-05-17 10:02:49 +01:00
Alberto Bertogli
4c28efcb20 config: Allow overrides from the command line
This patch allows the configuration values to be overridden from the
command-line, with a new -config_overrides flag.

There is a fairly specific use case for this, when editing the
configuration file is not feasible or convenient (e.g. running an
user-supplied configuration in a managed environment).
2020-05-17 00:10:06 +01:00
Alberto Bertogli
7909b479eb config: Tidy default handling and comparisons in tests
This patch tidies how defaults are handled in the config, using a new
logic to allow "overriding" one config (the default) with another (the
user supplied).

It also improves how the comparisons are done in the tests, using the
more convenient "github.com/google/go-cmp/cmp" package, which also
prints nice diffs on errors.

This is in preparation for a future path where the override mechanism
will be reused.
2020-05-16 23:48:09 +01:00
Alberto Bertogli
b1fe4f81f9 config: Improve logging of errors
Currently, the config package logs errors itself, in addition to
returning them.

That is confusing and results in some duplication of logging.

This patch makes config just return errors, and adjusts the callers
to log them properly.
2020-05-16 23:46:43 +01:00
Alberto Bertogli
50986a7b7e Update protobuf library to v2
There is a new protobuf library (and corresponding code generator) for
Go: google.golang.org/protobuf.

It is fairly compatible with the previous v1 API
(github.com/golang/protobuf), but there are some changes.

This patch adjusts the code and generated files to the new API.

The on-wire/on-disk format remains unchanged so this should be
transparent to the users.
2020-05-16 10:12:51 +01:00
Alberto Bertogli
5ec567b27e travis: Only notify IRC about failures on change
There's no need to notify IRC on every failure, it can get spammy when
we're iterating trying to fix something.

This patch changes the config to notify IRC on change instead of always.
2020-05-13 23:50:01 +01:00