From 31cef473477f35fa185200a02b4d28522c021b92 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 27 Mar 2024 00:21:31 -0700 Subject: [PATCH] mta: improve dma message - mua: replace uriencode, add tests - mt: fix accessing unset var - mt: skip sleep when no tty --- include/mta.sh | 2 +- include/mua.sh | 33 ++++++++++++++------------------- mail-toaster.sh | 8 +++++--- provision/dovecot.sh | 10 +++++----- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/include/mta.sh b/include/mta.sh index b5c7502a..d072d969 100755 --- a/include/mta.sh +++ b/include/mta.sh @@ -89,7 +89,7 @@ enable_dma() tell_status "setting up dma" cp "$_base/usr/share/examples/dma/mailer.conf" "$_base/etc/mail/mailer.conf" - echo "dma.conf: $_base/etc/dma/dma.conf" + echo "editing $_base/etc/dma/dma.conf" sed -i '' \ -e "s/^#SMARTHOST/SMARTHOST $TOASTER_MSA/" \ "$_base/etc/dma/dma.conf" diff --git a/include/mua.sh b/include/mua.sh index 8ca7556d..54dad5a9 100755 --- a/include/mua.sh +++ b/include/mua.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -e +set -e -u # shellcheck disable=3003 test_imap_empty() @@ -44,7 +44,7 @@ test_imap_curl() { # shellcheck disable=SC2001 curl -k -v --login-options 'AUTH=PLAIN' \ - "imaps://$(uriencode $MUA_TEST_USER):$(uriencode MUA_TEST_PASS)@${MUA_TEST_HOST}/" + "imaps://$(uriencode $MUA_TEST_USER):$(uriencode $MUA_TEST_PASS)@${MUA_TEST_HOST}/" } test_imap() @@ -81,26 +81,21 @@ test_pop3_empty() test_pop3() { - # shellcheck disable=SC2001 + # shellcheck disable=2001 curl -k -v --login-options 'AUTH=PLAIN' \ - "pop3s://$(uriencode $MUA_TEST_USER):$(uriencode MUA_TEST_PASS)@${MUA_TEST_HOST}/" + "pop3s://$(uriencode $MUA_TEST_USER):$(uriencode $MUA_TEST_PASS)@${MUA_TEST_HOST}/" } -# https://stackoverflow.com/questions/296536/how-to-urlencode-data-for-curl-command -# shellcheck disable=3005,3018,3024,3045,3057 uriencode() { - local string="${1}" - local strlen=${#string} - local encoded="" - local pos c o - - for (( pos=0 ; pos "$1.mt6" - if [ ! -f "$1" ] || [ -n "$2" ]; then + if [ ! -f "$1" ] || [ "$_overwrite" = "overwrite" ]; then tell_status "installing $1" cp "$1.mt6" "$1" else @@ -812,7 +814,7 @@ tell_settings() echo; echo " *** Configured $1 settings: ***"; echo set | grep "^$1_" echo - sleep 2 + if [ -t 0 ]; then sleep 2; fi } proclaim_success() diff --git a/provision/dovecot.sh b/provision/dovecot.sh index f74c79a5..1f75f1e6 100755 --- a/provision/dovecot.sh +++ b/provision/dovecot.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -e +set -e -u . mail-toaster.sh @@ -534,11 +534,11 @@ int_ip6 = "$(get_jail_ip6 dovecot)" # to permit legacy users to access insecure POP3 & IMAP, add their IPs/masks table persist file "$_pf_etc/insecure_mua" -rdr inet proto tcp from any to port { 993 995 } -> $int_ip4 -rdr inet6 proto tcp from any to port { 993 995 } -> $int_ip6 +rdr inet proto tcp from any to port { 993 995 } -> \$int_ip4 +rdr inet6 proto tcp from any to port { 993 995 } -> \$int_ip6 -rdr inet proto tcp from to port { 110 143 } -> $int_ip4 -rdr inet6 proto tcp from to port { 110 143 } -> $int_ip6 +rdr inet proto tcp from to port { 110 143 } -> \$int_ip4 +rdr inet6 proto tcp from to port { 110 143 } -> \$int_ip6 EO_PF_RDR store_config "$_pf_etc/allow.conf" <