From 767d8b6ed3f32fa6b8542b4234c19ad42320e71d Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sat, 10 Oct 2020 22:44:23 +0200 Subject: fix quote variables, and drop unneeded quotes --- postfix/postfix.sh | 74 +++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/postfix/postfix.sh b/postfix/postfix.sh index 5255959..48c6b59 100755 --- a/postfix/postfix.sh +++ b/postfix/postfix.sh @@ -36,8 +36,8 @@ TLS_CERT=${TLS_CERT:-/etc/ssl/certs/postfix.pem} TLS_KEY=${TLS_KEY:-/etc/ssl/private/postfix.pem} realmsdir="/etc/local-$REDPILL" -thisrealm="$(cat "/etc/local-$REALM/realm" || dnsdomainname | tr '[:lower:]' '[:upper:]')" -confdir="/etc/postfix" +thisrealm=$(cat "/etc/local-$REALM/realm" || dnsdomainname | tr '[:lower:]' '[:upper:]') +confdir=/etc/postfix if ! [ -d "$realmsdir" ]; then warn "Realms directory \"$realmsdir\" does not exist." fi @@ -104,7 +104,7 @@ fi catfilefromownrealm() { set -e - file="$1" + file=$1 [ -d "$realmsdir" ] || exit 0 cat "$realmsdir/$thisrealm/$file" @@ -112,11 +112,11 @@ catfilefromownrealm() { catallfilesfromotherrealms() { set -e - file="$1" + file=$1 [ -d "$realmsdir" ] || exit 0 [ -f "$realmsdir/realms" ] || exit 0 - realms="$(cat "$realmsdir/realms" | sed 's/#.*//')" + realms=$(cat "$realmsdir/realms" | sed 's/#.*//') for realm in $realms; do if [ "$thisrealm" != "$realm" ]; then @@ -127,9 +127,9 @@ catallfilesfromotherrealms() { catfirstfile() { set -e - file="$1" - context="${2:-postfix}" - configdir='' + file=$1 + context=${2:-postfix} + configdir= for dir in /etc/local "/etc/local-$REALM" "/etc/local-$REDPILL" /etc/local-COMMON; do if [ -d "$dir/$context" ] && [ -f "$dir/$context/$file" ]; then configdir="$dir/$context" @@ -145,30 +145,30 @@ catfirstfile() { # TODO: support quoted string, and trailing comment. getperlvarfromfile() { set -e - export var="$1" - export default="$2" - file="$3" - context="${4:-postfix}" + export var=$1 + export default=$2 + file=$3 + context=${4:-postfix} catfirstfile "$file" "$context" \ - | perl -nE'/^\$$ENV{"var"}\h*=\h*(\d+)/ and $s=$1; END {print length($s) ? $s : $ENV{'default'}}' + | perl -nE'/^\$$ENV{"var"}\h*=\h*(\d+)/ and $s=$1; END {print length($s) ? $s : $ENV{"default"}}' } getlinesfromfile() { set -e - param="$1" + param=$1 shift replacements= - for subparam in $@; do + for subparam in "$@"; do case "$subparam" in *=) - oldparam="$(echo $subparam | awk -F= '{print $1}')" + oldparam=$(echo "$subparam" | awk -F= '{print $1}') replacements="$replacements;s/,*[^,]*$oldparam[^,]*,*/,/" continue ;; *=*=*) - oldparam="$(echo $subparam | awk -F= '{print $1}')" - newparam="$(echo $subparam | awk -F= '{print $2}')" - newparamfile="$(echo $subparam | awk -F= '{print $3}')" + oldparam=$(echo "$subparam" | awk -F= '{print $1}') + newparam=$(echo "$subparam" | awk -F= '{print $2}') + newparamfile=$(echo "$subparam" | awk -F= '{print $3}') ;; *) oldparam=$subparam @@ -176,7 +176,7 @@ getlinesfromfile() { newparamfile=$subparam ;; esac - newparamvalues="$(getlinesfromfile $newparamfile | sed -e 's/.*=[ ]*//' -e 's/,/ /g')" + newparamvalues=$(getlinesfromfile "$newparamfile" | sed -e 's/.*=[ ]*//' -e 's/,/ /g') newstring= for newparamvalue in $newparamvalues; do newstring="${newstring}$newparam $newparamvalue," @@ -193,20 +193,20 @@ _postconf() { postmapfiles= -tempdir="$(mktemp -td postfix.XXXXXX)" +tempdir=$(mktemp -td postfix.XXXXXX) cp -a -t "$tempdir" "$confdir"/* # Inspired by D. J. Bernstein: http://cr.yp.to/smtp/greeting.html -_postconf -e 'smtpd_banner = $myhostname NO UCE ESMTP $mail_name (Debian/GNU)' +_postconf -e smtpd_banner='$myhostname NO UCE ESMTP $mail_name (Debian/GNU)' # Some badly configured setup use hostname instead of FQDN # Disable completely: Effective, but hurts executive type guys using windows servers... :-( #if _postconf myhostname | grep -q '\.'; then -# _postconf -e 'smtpd_helo_required = yes' +# _postconf -e smtpd_helo_required=yes #fi -_postconf -e 'smtpd_helo_required = no' +_postconf -e smtpd_helo_required=no _postconf -e "$(getlinesfromfile permit_mx_backup_networks)" -_postconf -e "maps_rbl_domains =" +_postconf -e maps_rbl_domains= _postconf -e "$(getlinesfromfile smtpd_client_restrictions reject_rhsbl_client)" _postconf -e "$(getlinesfromfile smtpd_helo_restrictions)" _postconf -e "$(getlinesfromfile smtpd_sender_restrictions reject_rhsbl_sender ${dkimproxy:-sender_access_regex=})" @@ -229,7 +229,7 @@ fi # Support exceptions to default response # (Day Old Bread (dob) lists need to reject only temporarily) -_postconf -e "rbl_reply_maps = hash:$confdir/rbl_reply_map" +_postconf -e rbl_reply_maps="hash:$confdir/rbl_reply_map" cat /etc/local-COMMON/postfix/rbl_reply_map \ | sed 's/#.*//' \ > "$tempdir/rbl_reply_map" @@ -245,10 +245,10 @@ cat /etc/local-COMMON/postfix/maildomains | grep -v yahoo | sort | sed 's/$/ rej | sed 's/\(.*\)$/postmaster@\1 permit\n\1 reject_unverified_sender/' >> "$tempdir/sender_access" [ ! -f "$tempdir/sender_access.addon" ] || cat "$tempdir/sender_access.addon" >> "$tempdir/sender_access" postmapfiles="$postmapfiles sender_access" -_postconf -e "unverified_sender_reject_code = 550" +_postconf -e unverified_sender_reject_code=550 # Trust recipient verification too -_postconf -e "unverified_recipient_reject_code = 550" +_postconf -e unverified_recipient_reject_code=550 if [ -n "$dovecot_lmtp" ]; then _postconf -e mailbox_transport=lmtp:unix:private/dovecot-lmtp @@ -283,9 +283,9 @@ if [ -n "$tls_cert" ]; then _postconf -e smtpd_tls_security_level=may _postconf -e smtpd_tls_cert_file="$TLS_CERT" _postconf -e smtpd_tls_key_file="$TLS_KEY" - _postconf -e 'smtpd_tls_loglevel = 1' - _postconf -e 'smtpd_tls_auth_only = yes' - _postconf -e 'smtpd_tls_received_header = yes' + _postconf -e smtpd_tls_loglevel=1 + _postconf -e smtpd_tls_auth_only=yes + _postconf -e smtpd_tls_received_header=yes else _postconf -e smtpd_tls_security_level=none _postconf -X smtpd_tls_cert_file @@ -387,8 +387,8 @@ amavisfeed unix - - n - $amavis_maxproc lmtp ' _postconf -e receive_override_options=no_address_mappings if [ -n "$dkimproxy" ]; then - _postconf -e 'content_filter = amavisfeed:[127.0.0.1]:10028' - _postconf -Pe pickup/fifo/content_filter=dkimsign:127.0.0.1:10028 + _postconf -e content_filter='amavisfeed:[127.0.0.1]:10028' + _postconf -Pe pickup/fifo/content_filter='dkimsign:127.0.0.1:10028' if [ -n "$submission" ]; then _postconf -Pe submission/inet/content_filter='dkimsign:[127.0.0.1]:10028' _postconf -Pe smtps/inet/content_filter='dkimsign:[127.0.0.1]:10028' @@ -412,7 +412,7 @@ dkimsign unix - - n - $dkimproxy_maxproc_out smtp else _postconf -MX dkimsign/unix _postconf -MX 127.0.0.1:10029/inet - _postconf -e 'content_filter = amavisfeed:[127.0.0.1]:10024' + _postconf -e content_filter='amavisfeed:[127.0.0.1]:10024' _postconf -PX pickup/fifo/content_filter if [ -n "$submission" ]; then _postconf -PX submission/inet/content_filter @@ -430,10 +430,10 @@ fi _postconf -X max_use _postconf -MX smtp-amavis/unix -diff -ruNw "$confdir" "$tempdir" || if [ $? -gt 1 ]; then exit $?; else needs_reload="1"; fi +diff -ruNw "$confdir" "$tempdir" || if [ $? -gt 1 ]; then exit $?; else needs_reload=1; fi if [ "$force" = "1" ]; then - do_update="y" + do_update=y elif [ "1" = "$needs_reload" ]; then echo -n "Above is the intended changes. OK to update (y/N)? " read do_update @@ -445,7 +445,7 @@ case $do_update in fi rm -f "$tempdir/COMMANDS" - diff -q "$confdir/master.cf" "$tempdir/master.cf" || if [ $? -gt 1 ]; then exit $?; else needs_restart="1"; fi + diff -q "$confdir/master.cf" "$tempdir/master.cf" || if [ $? -gt 1 ]; then exit $?; else needs_restart=1; fi cp -a -f -t "$confdir" "$tempdir"/* rm -rf "$tempdir" -- cgit v1.2.3