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

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.
This commit is contained in:
Alberto Bertogli
2024-05-10 09:11:35 +01:00
parent 0414af09b4
commit e6a9410377
15 changed files with 99 additions and 25 deletions

View File

@@ -0,0 +1 @@
users file error: open domains/testserver/users: permission denied

View File

@@ -0,0 +1,9 @@
smtp_address: ":1025"
submission_address: ":1587"
submission_over_tls_address: ":1465"
mail_delivery_agent_bin: "test-mda"
mail_delivery_agent_args: "%to%"
data_dir: "../.data"
mail_log_path: "../.logs/mail_log"

View File

@@ -0,0 +1,26 @@
users: {
key: "someone"
value: {
scrypt: {
logN: 14
r: 8
p: 1
keyLen: 32
salt: "J\x01\xed7]\x02\n\xe9;z[\x8d˱\x10\xc1"
encrypted: "\xa50宴\xcbb\xc1!r]K\xd1yI\xa2\x99\x8d\xdaQx\x8e69\xac\xf4$\x01\x11\x03\x8d\x10"
}
}
}
users: {
key: "user"
value: {
scrypt: {
logN: 14
r: 8
p: 1
keyLen: 32
salt: "\n\xc6\x1c\x8f\xb2\x0c\x15p\x8d\xa1\xc3\x05U6\xdb\xc4"
encrypted: "\xc3\xe6B2\x84W\x1a\nq{\x07\xe0\x9c\x854\n\xac\xbc\xb7\x9c\x86Kyk\x8dj\x16\x1a\x8c$*N"
}
}
}

View File

@@ -0,0 +1 @@
aliases file error: open domains/testserver/aliases: permission denied

View File

@@ -0,0 +1,9 @@
smtp_address: ":1025"
submission_address: ":1587"
submission_over_tls_address: ":1465"
mail_delivery_agent_bin: "test-mda"
mail_delivery_agent_args: "%to%"
data_dir: "../.data"
mail_log_path: "../.logs/mail_log"

View File

@@ -0,0 +1 @@
a: b

View File

@@ -19,7 +19,7 @@ mkdir -p c-04-no_cert_dirs/certs/
# Generate certs for the tests that need them.
for i in c-05-no_addrs c-06-bad_maillog c-07-bad_domain_info \
c-08-bad_sts_cache c-09-bad_queue_dir c-10-empty_listening_addr \
c-11-bad_dkim_key;
c-11-bad_dkim_key c-12-bad_users c-13-bad_aliases;
do
CONFDIR=$i/ generate_certs_for testserver
done
@@ -30,6 +30,10 @@ done
cp c-11-bad_dkim_key/domains/testserver/dkim__selector.pem \
c-11-bad_dkim_key/domains/testserver/dkim:selector.pem
# For the bad_users and bad_aliases test, make the relevant file unreadable.
chmod -rw c-12-bad_users/domains/testserver/users
chmod -rw c-13-bad_aliases/domains/testserver/aliases
for i in c-*; do
if chasquid --config_dir="$i" > ".chasquid-$i.out" 2>&1; then
echo "$i failed; output:"
@@ -54,4 +58,8 @@ for i in c-*; do
fi
done
# Give permissions back, to avoid annoying git messages.
chmod +rw c-12-bad_users/domains/testserver/users
chmod +rw c-13-bad_aliases/domains/testserver/aliases
success