Fix: Make sure to use the proper name for pluginviewer based on distro

Debian/Ubuntu use 'saslpluginviewer`, so we should check for that.
This commit is contained in:
Bojan Čekrlić 2023-10-27 17:55:34 +02:00
parent 945add7f9d
commit e8c6cd5332
3 changed files with 14 additions and 3 deletions

View file

@ -7,7 +7,7 @@ fi
do_alpine() {
apk update
apk add --upgrade cyrus-sasl cyrus-sasl-static cyrus-sasl-digestmd5 cyrus-sasl-crammd5 cyrus-sasl-login cyrus-sasl-ntlm
apk add --upgrade cyrus-sasl cyrus-sasl-static cyrus-sasl-digestmd5 cyrus-sasl-crammd5 cyrus-sasl-login cyrus-sasl-ntlm libsasl
apk add postfix
apk add opendkim
apk add --upgrade ca-certificates tzdata supervisor rsyslog musl musl-utils bash opendkim-utils libcurl jsoncpp lmdb logrotate netcat-openbsd
@ -21,7 +21,7 @@ do_ubuntu() {
export DEBIAN_FRONTEND=noninteractive
echo "Europe/Berlin" > /etc/timezone
apt-get update -y -q
apt-get install -y libsasl2-modules
apt-get install -y libsasl2-modules sasl2-bin
apt-get install -y postfix
apt-get install -y opendkim
apt-get install -y ca-certificates tzdata supervisor rsyslog bash opendkim-tools curl libcurl4 libjsoncpp25 sasl2-bin postfix-lmdb logrotate cron net-tools ${RELEASE_SPECIFIC_PACKAGES}

View file

@ -10,4 +10,9 @@ fi
if ! hash nc; then
echo "netcat not found!" >2
exit 1
fi
if ! hash pluginviewer && ! hash saslpluginviewer; then
echo "pluginviewer not found!" >2
exit 1
fi

View file

@ -325,6 +325,7 @@ EOF
postfix_setup_xoauth2_post_setup() {
local other_plugins
local plugin_viewer="pluginviewer"
if [ -n "$XOAUTH2_CLIENT_ID" ] || [ -n "$XOAUTH2_SECRET" ]; then
do_postconf -e 'smtp_sasl_security_options='
do_postconf -e 'smtp_sasl_mechanism_filter=xoauth2'
@ -338,7 +339,12 @@ postfix_setup_xoauth2_post_setup() {
#
# The fix is therefore simple: If we're not using OAuth2, we remove the plugin from the list and
# keep all the plugins installed.
other_plugins="$(pluginviewer -c | grep Plugin | cut -d\ -f2 | cut -c2- | rev | cut -c2- | rev | grep -v EXTERNAL | grep -v sasl-xoauth2 | tr '\n' ',' | rev | cut -c2- | rev)"
if hash saslpluginviewer > /dev/null 2>&1; then
# Ubuntu/Debian have renamed pluginviewer to saslpluginviewer so this fails with those distros.
plugin_viewer="saslpluginviewer"
fi
other_plugins="$(${plugin_viewer} -c | grep Plugin | cut -d\ -f2 | cut -c2- | rev | cut -c2- | rev | grep -v EXTERNAL | grep -v sasl-xoauth2 | tr '\n' ',' | rev | cut -c2- | rev)"
do_postconf -e "smtp_sasl_mechanism_filter=${other_plugins}"
fi
}