mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-20 15:07:03 +00:00
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.
75 lines
2.0 KiB
Bash
Executable File
75 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# This test checks that we can use dovecot as an authentication mechanism.
|
|
#
|
|
# Setup:
|
|
# - chasquid listening on :1025.
|
|
# - dovecot listening on unix sockets in .dovecot/
|
|
|
|
set -e
|
|
. $(dirname ${0})/../util/lib.sh
|
|
|
|
init
|
|
|
|
if ! dovecot --version > /dev/null; then
|
|
skip "dovecot not installed"
|
|
exit 0
|
|
fi
|
|
|
|
# Create a temporary directory for dovecot to use, and generate the dovecot
|
|
# config based on the template.
|
|
# Note the lenght of the path must be < 100, because unix sockets have a low
|
|
# limitation, so we use a directory in /tmp, which is not ideal, as a
|
|
# workaround.
|
|
export ROOT="/tmp/chasquid-dovecot-test"
|
|
mkdir -p $ROOT $ROOT/run
|
|
rm -f $ROOT/dovecot.log
|
|
|
|
export GROUP=$(id -g -n)
|
|
envsubst < config/dovecot.conf.in > $ROOT/dovecot.conf
|
|
cp -f config/passwd $ROOT/passwd
|
|
|
|
dovecot -F -c $ROOT/dovecot.conf &
|
|
|
|
# Early tests: run dovecot-auth-cli for testing purposes. These fail early if
|
|
# there are obvious problems.
|
|
OUT=$(dovecot-auth-cli $ROOT/run/auth exists user@srv || true)
|
|
if [ "$OUT" != "yes" ]; then
|
|
fail "user does not exist: $OUT"
|
|
fi
|
|
|
|
OUT=$(dovecot-auth-cli $ROOT/run/auth auth user@srv password || true)
|
|
if [ "$OUT" != "yes" ]; then
|
|
fail "auth failed: $OUT"
|
|
fi
|
|
|
|
|
|
# Set up chasquid, using dovecot as authentication backend.
|
|
generate_certs_for srv
|
|
|
|
mkdir -p .logs
|
|
chasquid -v=2 --logfile=.logs/chasquid.log --config_dir=config &
|
|
wait_until_ready 1025
|
|
|
|
# Send an email as user@srv successfully.
|
|
run_msmtp user@srv < content
|
|
wait_for_file .mail/user@srv
|
|
mail_diff content .mail/user@srv
|
|
|
|
# Fail to send to nobody@srv (user does not exist).
|
|
if run_msmtp nobody@srv < content 2> /dev/null; then
|
|
fail "successfuly sent an email to a non-existent user"
|
|
fi
|
|
|
|
# Fail to send from baduser@srv (user does not exist).
|
|
if run_msmtp -a baduser user@srv < content 2> /dev/null; then
|
|
fail "successfully sent an email with a bad user"
|
|
fi
|
|
|
|
# Fail to send with an incorrect password.
|
|
if run_msmtp -a badpasswd user@srv < content 2> /dev/null; then
|
|
fail "successfully sent an email with a bad password"
|
|
fi
|
|
|
|
success
|