14 Commits

Author SHA1 Message Date
Alberto Bertogli
e6a9410377 Exit if there's an error reading users/aliases files on startup
Today, when starting up, if there's an error reading the users or
aliases files, we only log but do not exit. And then those files will
not be attempted to be read on the periodic reload.

We also treat "file does not exist" as an error for users file, but not
aliases file, resulting in inconsistent behaviour between the two.

All of this makes some classes of problems (like permission errors) more
difficult to spot and troubleshoot. For example,
https://github.com/albertito/chasquid/issues/55.

So this patch makes errors reading users/aliases files on startup a
fatal error, and also unifies the "file does not exist" behaviour to
make it not an error in both cases.

Note that the behaviour on the periodic reload is unchanged: treat these
errors as fatal too. This may be changed in future patches.
2024-05-10 12:09:53 +01:00
Alberto Bertogli
83ae4c3478 userdb: Add support for receive-only users
Some use cases, like receive-only MTAs, need domain users for receiving
emails, but have no real need for passwords since they will never use
submission.

Today, that is not supported, and those use-cases require the
administrator to come up with a password unnecessarily, adding
complexity and possibly risk.

This patch implements "receive-only users", which don't have a valid
password, thus exist for the purposes of delivering mail, but always
fail authentication.

See https://github.com/albertito/chasquid/issues/44 for more details and
rationale.

Thanks to xavierg who suggested this feature on IRC.
2023-12-03 11:59:26 +00:00
Alberto Bertogli
3ebe5c5173 Replace uses of ioutil
ioutil package was deprecated in Go 1.16, replace all uses with their
respective replacements.

This patch was generated with a combination of `gofmt -r`, `eg`, and
manually (for `ioutil.ReadDir`).
2022-11-12 20:06:35 +00:00
Alberto Bertogli
0718749314 Update auto-generated code
This patch updates the auto-generated code to match the latest tooling
versions.

In particular, the protobufs are regenerated, and the new version no
longer supports unkeyed literals, so some minor changes are needed.

Other than that, the cipher list is extended with the latest ciphers.
2019-10-24 21:37:09 +01:00
Alberto Bertogli
3584441549 test: Use testlib.RemoveIfOk where appropriate
Some tests did not make use of testlib.RemoveIfOk, which resulted in
some duplication; this patch fixes that.

While at it, userdb tests have its own simpler variant, so add some
safety checks to it.
2019-09-10 01:09:44 +01:00
Alberto Bertogli
d4992ef8c5 auth: Implement an Authenticator type
This patch implements an Authenticator type, which connections use to
do authentication and user existence checks.

It simplifies the abstractions (the server doesn't need to know about
userdb, or keep track of domain-userdb maps), and lays the foundation
for other types of authentication backends which will come in later
patches.
2018-02-10 22:24:39 +00:00
Alberto Bertogli
9864f40f3b test: Tidy up creation and removal of test directories
We have many places in our tests where we create temporary directories,
which we later remove (most of the time). We have at least 3 helpers to
do this, and various places where it's done ad-hoc (and the cleanup is
not always present).

To try to reduce the clutter, and make the tests more uniform and
readable, this patch introduces two helpers in a new "testutil" package:
one for creating and one for removing temporary directories.

These new functions are safer, better tested, and make the tests more
consistent.  All the tests are updated to use them.
2017-07-14 02:02:43 +01:00
Alberto Bertogli
ad25706d72 Normalize local usernames using PRECIS
This patch implements local username normalization using PRECIS
(https://tools.ietf.org/html/rfc7564,
https://tools.ietf.org/html/rfc7613)

It makes chasquid accept local email and authentication regardless of
the case. It covers both userdb and aliases.

Note that non-local usernames remain untouched.
2016-10-10 00:51:05 +01:00
Alberto Bertogli
0995eac474 chasquid: Fail at RCPT TO time if a user does not exist
It's more convenient and in line with standard practice to fail RCPT TO if the
user does not exist.

This involves making the server and client aware of aliases, but it doesn't
end up being very convoluted, and simplifies other code.
2016-10-10 00:51:04 +01:00
Alberto Bertogli
859d4733f8 userdb: Add a method to remove users
This patch adds a method to userdb to remove users.
It will not be used by chasquid, but by the command-line tool.
2016-10-10 00:51:04 +01:00
Alberto Bertogli
394067bbd3 userdb: Use protocol buffers instead of our custom format
Protocol buffers are a more portable, practical and safe format for the user
database.
2016-10-10 00:51:03 +01:00
Alberto Bertogli
aac2d3c061 Minor style and simplification cleanups
This patch does various minor style and simplification cleanups, fixing things
detected by tools such as go vet, gofmt -s, and golint.

There are no functional changes, this change is purely cosmetic, but will
enable us to run those tools more regularly now that their output is clean.
2016-09-12 04:06:56 +01:00
Alberto Bertogli
ff103c18c3 courier: Let the users configure the mail delivery agent
This patch adds configuration options for the MDA binary and command line
arguments, and changes the (soon to be renamed) procmail courier to make use
of them.
2016-07-16 12:33:51 +01:00
Alberto Bertogli
9015e97ae1 Implement a simple user database (internal/userdb)
This patch adds a package implementing a simple user database, called userdb.
It has a human readable space-separated extensible format, and uses scrypt for
password storage (but supports plain as well, for debugging and testing).

chasquid is not using it yet, that will come in later patches.
2016-07-16 12:33:50 +01:00