git » chasquid » commit 34ade50

test: Work around msmtp having setgid permissions

author Alberto Bertogli
2019-08-31 00:27:19 UTC
committer Alberto Bertogli
2019-08-31 00:27:19 UTC
parent f63e5bf0b262ba2f7f70a17818eeb6fed46272f4

test: Work around msmtp having setgid permissions

In some distributions, including newer Debian versions, msmtp is
installed as setgid.

That prevents $HOSTALIASES from being honoured, which breaks the tests.

This patch works around the problem by creating a copy of the binary,
which will not have the setgid bit set.

test/util/lib.sh +6 -1

diff --git a/test/util/lib.sh b/test/util/lib.sh
index 38ed40b..54469e5 100644
--- a/test/util/lib.sh
+++ b/test/util/lib.sh
@@ -79,8 +79,13 @@ function run_msmtp() {
 	# msmtp will check that the rc file is only user readable.
 	chmod 600 msmtprc
 
+	# msmtp binary is often g+s, which causes $HOSTALIASES to not be
+	# honoured, which breaks the tests. Copy the binary to remove the
+	# setgid bit as a workaround.
+	cp -u "`which msmtp`" "${UTILDIR}/.msmtp-bin"
+
 	HOSTALIASES=${TBASE}/hosts \
-		msmtp -C msmtprc "$@"
+		${UTILDIR}/.msmtp-bin -C msmtprc "$@"
 }
 
 function smtpc.py() {