Compare commits

..

13 Commits

Author SHA1 Message Date
6d516ed25a install_postfix_advanced.sh: remove depredated parameter 'permit_mx_backup'. 2026-02-11 21:20:00 +01:00
c6909c937d Merge branch 'master' of git.oopen.de:install/mailsystem 2026-02-11 21:17:33 +01:00
9708c595c4 install_update_dovecot.conf.sample: fix parameter 'cert_base_dir'. 2026-02-11 21:16:37 +01:00
9c52e54182 install_postfixadmin.sh: configuration file at version 4.x is 'config.local.php'. 2026-02-11 00:47:05 +01:00
849cbfa2e4 install_postfixadmin.sh: some minor changes. 2026-02-10 23:58:58 +01:00
0a51e44b93 install_amavis.sh: some minor changes.. 2026-02-10 15:27:39 +01:00
16618f9949 install_opendmarc.sh: no opendmarc check on non_smtpd connections. 2026-02-10 15:02:05 +01:00
b4b47d5a79 install_amavis.sh: keine milters auf localhost:10025. install_postfix_advanced.sh: kein OpenDmarc bei non_smtpd_milters. (DMARC ist eine Inbound-Policy-Prüfung, nicht sinnvoll für lokal/originating.) 2026-02-10 14:14:53 +01:00
d1694bf3a4 install_postfix_advanced.sh: adjust '/etc/postfix/header_checks'. 2026-02-10 00:37:03 +01:00
ee1e2d0b7e install_amavis.sh: add spamassassin rule for Null sender ( (Return-Path: <>). 2026-02-10 00:35:10 +01:00
96a77260c3 Merge branch 'master' of https://git.oopen.de/install/mailsystem 2026-02-04 22:23:01 +01:00
71be7f0754 install_update_dovecot.sh: relax/defuse systemd-hardening 2026-02-04 22:22:31 +01:00
e82b464115 install_postfixadmin.sh: add support for versions 4.x 2026-02-04 21:08:22 +01:00
6 changed files with 469 additions and 197 deletions

View File

@@ -145,7 +145,7 @@ dbhost=""
# - Cert/Key configurations # - Cert/Key configurations
# --- # ---
cert_base_dir="/etc/postfix/ssl" cert_base_dir="/etc/dovecot/ssl"
server_cert=${cert_base_dir}/mailserver.crt server_cert=${cert_base_dir}/mailserver.crt
server_key=${cert_base_dir}/mailserver.key server_key=${cert_base_dir}/mailserver.key
dh_pem_file="${cert_base_dir}/dh_4096.pem" dh_pem_file="${cert_base_dir}/dh_4096.pem"

View File

@@ -2257,6 +2257,45 @@ if ! $installation_failed ; then
fi fi
fi fi
# Create /etc/spamassassin/99_nullsender.cf
#
# Spamassassin Regeln für Nullsender (Return-Path: <>)
#
# Problem:
# echte DSNs haben ebenfalls Return-Path: <>
#
# Aber:
# Echte DSNs sind i.d.R. multipart/report (delivery-status)
#
echononl " Create file \"/etc/spamassassin/99_nullsender.cf\".."
cat <<'EOF' > /etc/spamassassin/99_nullsender.cf 2> $tmp_err_msg
########################################################################
# Null-sender (Return-Path: <>) Behandlung
# Ziel: Fake-Bounces markieren, echte DSNs nicht treffen
########################################################################
# 1) Null-Envelope-From erkannt
header LOCAL_NULL_SENDER Return-Path =~ /^<>$/i
describe LOCAL_NULL_SENDER Null envelope-from (Return-Path <>)
score LOCAL_NULL_SENDER 0.1
# 2) Echte DSNs sind i.d.R. multipart/report (delivery-status)
header LOCAL_DSN_MULTIPART Content-Type =~ /^multipart\/report\b/i
describe LOCAL_DSN_MULTIPART Looks like a real DSN (multipart/report)
score LOCAL_DSN_MULTIPART -3.0
# 3) Fake-Bounce: Null-sender, aber NICHT multipart/report
meta LOCAL_NULL_NOT_DSN LOCAL_NULL_SENDER && !LOCAL_DSN_MULTIPART
describe LOCAL_NULL_NOT_DSN Null-sender but not a DSN (likely fake bounce spam)
score LOCAL_NULL_NOT_DSN 6.0
EOF
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
fi
# - Enable nightly cronjob for spamassassin # - Enable nightly cronjob for spamassassin
# - # -
@@ -3260,6 +3299,18 @@ if $INSTALL_CLAMAV_UNOFFICIAL_SIGS ; then
if [[ "$?" -ne 0 ]] ; then if [[ "$?" -ne 0 ]] ; then
installation_failed=true installation_failed=true
error "$(cat $tmp_err_msg)" error "$(cat $tmp_err_msg)"
warn "command was:
git clone https://github.com/extremeshok/clamav-unofficial-sigs.git /tmp/clamav-unofficial-sigs"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi fi
if ! $installation_failed ; then if ! $installation_failed ; then
echo_ok echo_ok
@@ -4957,6 +5008,7 @@ fi
## - localhost:10025 inet n - y - - smtpd ## - localhost:10025 inet n - y - - smtpd
## - -o content_filter= ## - -o content_filter=
## - -o smtpd_proxy_filter= ## - -o smtpd_proxy_filter=
## - -o smtpd_milters=
## - -o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128 ## - -o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
## - -o smtpd_client_restrictions= ## - -o smtpd_client_restrictions=
## - -o smtpd_helo_restrictions= ## - -o smtpd_helo_restrictions=
@@ -5031,6 +5083,8 @@ EOF
localhost:10025 inet n - y - - smtpd localhost:10025 inet n - y - - smtpd
-o content_filter= -o content_filter=
-o smtpd_proxy_filter= -o smtpd_proxy_filter=
-o smtpd_milters=
-o milter_macro_daemon_name=ORIGINATING
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128 -o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
-o smtpd_client_restrictions= -o smtpd_client_restrictions=
-o smtpd_helo_restrictions= -o smtpd_helo_restrictions=
@@ -5093,6 +5147,8 @@ EOF
localhost:10025 inet n - y - - smtpd localhost:10025 inet n - y - - smtpd
-o content_filter= -o content_filter=
-o smtpd_proxy_filter= -o smtpd_proxy_filter=
-o smtpd_milters=
-o milter_macro_daemon_name=ORIGINATING
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128 -o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
-o smtpd_client_restrictions= -o smtpd_client_restrictions=
-o smtpd_helo_restrictions= -o smtpd_helo_restrictions=
@@ -5145,6 +5201,8 @@ EOF
localhost:10025 inet n - y - - smtpd localhost:10025 inet n - y - - smtpd
-o content_filter= -o content_filter=
-o smtpd_proxy_filter= -o smtpd_proxy_filter=
-o smtpd_milters=
-o milter_macro_daemon_name=ORIGINATING
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128 -o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
-o smtpd_client_restrictions= -o smtpd_client_restrictions=
-o smtpd_helo_restrictions= -o smtpd_helo_restrictions=
@@ -5181,6 +5239,8 @@ EOF
localhost:10025 inet n - y - - smtpd localhost:10025 inet n - y - - smtpd
-o content_filter= -o content_filter=
-o smtpd_proxy_filter= -o smtpd_proxy_filter=
-o smtpd_milters=
-o milter_macro_daemon_name=ORIGINATING
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128 -o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
-o smtpd_client_restrictions= -o smtpd_client_restrictions=
-o smtpd_helo_restrictions= -o smtpd_helo_restrictions=

View File

@@ -881,26 +881,26 @@ else
error "$(cat $log_file)" error "$(cat $log_file)"
fi fi
echononl " Set Variable non_smtpd_milters at '/etc/postfix/main.cf'.." #echononl " Set Variable non_smtpd_milters at '/etc/postfix/main.cf'.."
if $(grep -q -E "^\s*non_smtpd_milters\s*=\s*.*opendkim.sock" /etc/postfix/main.cf 2> /dev/null) ; then #if $(grep -q -E "^\s*non_smtpd_milters\s*=\s*.*opendkim.sock" /etc/postfix/main.cf 2> /dev/null) ; then
if $(grep -q -E "^\s*non_smtpd_milters\s*=\s*.*$(basename "${opendmarc_socket_file}")" /etc/postfix/main.cf); then # if $(grep -q -E "^\s*non_smtpd_milters\s*=\s*.*$(basename "${opendmarc_socket_file}")" /etc/postfix/main.cf); then
echo_skipped # echo_skipped
else # else
perl -i -n -p -e "s&^\s*(non_smtpd_milters\s*=.*opendkim.sock)&\1,local:/$(basename "${opendmarc_socket_dir}")/$(basename "${opendmarc_socket_file}")&" \ # perl -i -n -p -e "s&^\s*(non_smtpd_milters\s*=.*opendkim.sock)&\1,local:/$(basename "${opendmarc_socket_dir}")/$(basename "${opendmarc_socket_file}")&" \
/etc/postfix/main.cf > $log_file 2>&1 # /etc/postfix/main.cf > $log_file 2>&1
if [[ $? -eq 0 ]] ; then # if [[ $? -eq 0 ]] ; then
echo_ok # echo_ok
postfix_needs_restart=true # postfix_needs_restart=true
else # else
echo_failed # echo_failed
error "$(cat $log_file)" # error "$(cat $log_file)"
fi # fi
fi # fi
else #else
#
echo_skipped # echo_skipped
warn "non_smtpd_milters is not adjusted. Complete Postfix configuration (main.cf) manually\!" # warn "non_smtpd_milters is not adjusted. Complete Postfix configuration (main.cf) manually\!"
fi #fi
echononl " Set Variable smtpd_milters at '/etc/postfix/main.cf'.." echononl " Set Variable smtpd_milters at '/etc/postfix/main.cf'.."
@@ -975,53 +975,53 @@ EOF
fi fi
if grep -q -E "^\s*#?\s*non_smtpd_milters\s*=" ${main_cf_file} ; then #if grep -q -E "^\s*#?\s*non_smtpd_milters\s*=" ${main_cf_file} ; then
ensure_dmarc_var "non_smtpd_milters" > "${tmp_main_cf_file}"
cp "${tmp_main_cf_file}" "${main_cf_file}"
else
cat <<EOF >> /etc/postfix/main.cf 2> $log_file
# Was sind non_smtpd_milters?
# #
# non_smtpd_milters gilt für alle Postfix-Prozesse, die Mails verarbeiten, aber NICHT # ensure_dmarc_var "non_smtpd_milters" > "${tmp_main_cf_file}"
# der smtpd-Daemon sind. # cp "${tmp_main_cf_file}" "${main_cf_file}"
# #
# Das betrifft z. B.: #else
# #
# cleanup Header/Content-Bereinigung # cat <<EOF >> /etc/postfix/main.cf 2> $log_file
# qmgr Queue-Manager
# lmtp / smtp Auslieferung nach extern
# local lokale Zustellung
# #
# Das sind z. B.: ## Was sind non_smtpd_milters?
# ##
# - interne Bounces (MAILER-DAEMON) ## non_smtpd_milters gilt für alle Postfix-Prozesse, die Mails verarbeiten, aber NICHT
# ## der smtpd-Daemon sind.
# - Cron-Mails vom Server ##
# ## Das betrifft z. B.:
# - Weiterleitungen, die Postfix selbst generiert ##
# ## cleanup Header/Content-Bereinigung
# - Mails, die über sendmail CLI gesendet werden ## qmgr Queue-Manager
# ## lmtp / smtp Auslieferung nach extern
# - Mails, die Amavis über LMTP zurückgibt ## local lokale Zustellung
# ##
# - etc. ## Das sind z. B.:
# ##
# ## - interne Bounces (MAILER-DAEMON)
# DKIM soll auch die ausgehenden Mails signieren, die nicht über smtpd daemon versendet werden. ##
non_smtpd_milters = $opendmarc_socket_string ## - Cron-Mails vom Server
EOF ##
fi ## - Weiterleitungen, die Postfix selbst generiert
postfix_needs_restart=true ##
if [[ $? -eq 0 ]] ; then ## - Mails, die über sendmail CLI gesendet werden
echo_ok ##
else ## - Mails, die Amavis über LMTP zurückgibt
echo_failed ##
error "$(cat $log_file)" ## - etc.
fi ##
##
## DKIM soll auch die ausgehenden Mails signieren, die nicht über smtpd daemon versendet werden.
#non_smtpd_milters = $opendmarc_socket_string
#EOF
#fi
#postfix_needs_restart=true
#if [[ $? -eq 0 ]] ; then
# echo_ok
#else
# echo_failed
# error "$(cat $log_file)"
#fi
echo "" echo ""

View File

@@ -2911,8 +2911,13 @@ fi
cat <<EOF >> /etc/postfix/main.cf cat <<EOF >> /etc/postfix/main.cf
# Policyd-Weight # Policyd-Weight
#check_policy_service inet:127.0.0.1:12525, #check_policy_service inet:127.0.0.1:12525,
# ---------------------------------------------------------------------------------
# DEPRECATED permit_mx_backup
#
# warning: support for restriction "permit_mx_backup" will be removed from Postfix;
# permit Backup MX # permit Backup MX
permit_mx_backup, # permit_mx_backup,
# ---------------------------------------------------------------------------------
# permit, if all restrictions so far passed # permit, if all restrictions so far passed
permit permit
@@ -2953,8 +2958,13 @@ smtpd_relay_restrictions =
# managed by the verify(8) server; see http://www.postfix.org/ADDRESS_VERIFICATION_README.html # managed by the verify(8) server; see http://www.postfix.org/ADDRESS_VERIFICATION_README.html
# for more details # for more details
reject_unverified_recipient, reject_unverified_recipient,
# ---------------------------------------------------------------------------------
# DEPRECATED permit_mx_backup
#
# warning: support for restriction "permit_mx_backup" will be removed from Postfix;
# permit Backup MX # permit Backup MX
permit_mx_backup, # permit_mx_backup,
# ---------------------------------------------------------------------------------
# permit, if all restrictions so far passed # permit, if all restrictions so far passed
permit permit
@@ -3058,20 +3068,18 @@ EOF
# #
EOF EOF
if [[ -n "$(which opendkim)" ]] && [[ -n "$(which opendmarc)" ]] ; then if [[ -n "$(which opendkim)" ]] ; then
cat <<EOF >> /etc/postfix/main.cf
non_smtpd_milters = local:/opendkim/opendkim.sock,local:/opendmarc/opendmarc.sock
EOF
elif [[ -n "$(which opendkim)" ]] ; then
cat <<EOF >> /etc/postfix/main.cf cat <<EOF >> /etc/postfix/main.cf
non_smtpd_milters = local:/opendkim/opendkim.sock non_smtpd_milters = local:/opendkim/opendkim.sock
EOF EOF
else else
cat <<EOF >> /etc/postfix/main.cf cat <<EOF >> /etc/postfix/main.cf
non_smtpd_milters = local:/opendmarc/opendmarc.sock non_smtpd_milters =
EOF EOF
fi fi
else else
cat <<EOF >> /etc/postfix/main.cf cat <<EOF >> /etc/postfix/main.cf
@@ -3616,41 +3624,58 @@ fi
_file="/etc/postfix/header_checks.pcre" _file="/etc/postfix/header_checks.pcre"
echononl " Create file '$_file' used for header replacing" echononl " Create file '$_file' used for header replacing"
if [[ ! -f "$_file" ]]; then if [[ ! -f "$_file" ]]; then
cat << EOF > "$_file" cat << 'EOF' > "$_file"
# --- # ---
# - Replace headers # - Header Checks - /etc/postfix/header_checks
# --- # ---
#
# Ziel: offensichtlich kaputte RFC-Header ablehnen (wenig False Positives)
# - Replace recieved from ########################################
#/^Received: from (.* \\([-._[:alnum:]]+ \\[[.[:digit:]]{7,15}\\]\\)).*?([[:space:]]+).*\\(Authenticated sender: ([^)]+)\\)(.*)/ REPLACE Received: from [127.0.0.1] (localhost [127.0.0.1])\$2(Authenticated sender: \$3)\$4 # A) Kaputter From:-Header
########################################
# 1) From: ist leer
/^From:\s*$/ REJECT Invalid From header (empty) - Spamschutzregel FROM-1001
# 2) Mehr als ein '@' im From:-Header -> syntaktisch kaputt
/^From:.*@.*@/ REJECT Invalid From header (multiple @) - Spamschutzregel FROM-1002
# --- # 3) Mehrere Mailboxen durch Komma getrennt (wie: Die@..., Lions@..., ...)
# - Ignore Headers # (Legitime Fälle nutzen i.d.R. Display-Namen/Group-Syntax; dieses Muster ist in Spam sehr häufig)
# --- /^From:\s*[^<>,]+@[^,]+,\s*[^<>,]+@/ REJECT Invalid From header (multiple mailboxes) - Spamschutzregel FROM-1003
#/^\s*User-Agent/ IGNORE # 4) Typische kaputte UTF-8-Fragmente
#/^\s*X-Enigmail/ IGNORE /^From:.*\xC3\xA2/ REJECT Invalid UTF-8 in From header - Spamschutzregel FROM-1004
#/^\s*X-Mailer/ IGNORE
#/^\s*X-Originating-IP/ IGNORE
# --- ########################################
# - Reject / Discard headers # B) Optional: sehr spezifische lokale Blacklist
# --- ########################################
/^To:.*<>/ REJECT Possible SPAM Blank email address To: header - Header-Spamschutzregel T0-1001 #/^Reply-To: .+\@inx1and1\..+/ REJECT Possible spam (local pattern)
/\(envelope-from <>\)/ REJECT Possible SPAM - Header-Spamschutzregel RECIEV-1001
/^Reply-To: .+\@inx1and1\..+/ REJECT Possible SPAM - Header-Spamschutzregel REPLY-1001 ########################################
# C) Warn
########################################
/^From:.*<>/ REJECT Possible SPAM - Header-Spamschutzregel FROM-1001 # Date-Rejects sind oft zu aggressiv -> wenn nötig: lieber taggen oder loggen statt reject
/^Date: .* 19[0-9][0-9]/ WARN Date far in the past Header-Spamschutzregel DATE-1001
/^Date: .* 200[0-9]/ WARN Date far in the past Header-Spamschutzregel DATE-1002
/^Date: .* 201[0-9]/ WARN Date far in the past Header-Spamschutzregel DATE-1003
########################################
# Bemerkungen
########################################
# (envelope-from <>) nicht pauschal rejecten:
# echte DSNs/Bounces haben legitimerweise MAIL FROM: <>
#/\(envelope-from <>\)/ REJECT Null envelope-from
/^Date: .* 19[0-9][0-9]/ REJECT Date from the past. Fix your system clock. - Header-Spamschutzregel DATE-1001
/^Date: .* 200[0-9]/ REJECT Date from the past. Fix your system clock. - Header-Spamschutzregel DATE-1002
/^Date: .* 201[0-9]/ REJECT Date from the past. Fix your system clock. - Header-Spamschutzregel DATE-1003
/^Date: .* 2020/ REJECT Date from the past. Fix your system clock. - Header-Spamschutzregel DATE-1004
EOF EOF
if [[ $? -eq 0 ]] ; then if [[ $? -eq 0 ]] ; then
echo_ok echo_ok

View File

@@ -187,10 +187,9 @@ detect_mysql_version () {
# - # -
systemd_supported=false systemd_supported=false
systemd=$(which systemd)
systemctl=$(which systemctl) systemctl=$(which systemctl)
if [[ -n "$systemd" ]] && [[ -n "$systemctl" ]] ; then if [[ -n "$systemctl" ]] ; then
systemd_supported=true systemd_supported=true
fi fi
@@ -256,6 +255,14 @@ do
echo -e "\n\t\033[33m\033[1mA version number is required!\033[m\n" echo -e "\n\t\033[33m\033[1mA version number is required!\033[m\n"
fi fi
done done
IFS='.' read -r PF_ADMIN_MAJOR_VERSION PF_ADMIN_MINOR_VERSION PF_ADMIN_PATCH_LEVEL <<< "$PF_ADMIN_VERSION"
#echo ""
#echo "PF_ADMIN_MAJOR_VERSION: $PF_ADMIN_MAJOR_VERSION"
#echo "PF_ADMIN_MINOR_VERSION: $PF_ADMIN_MINOR_VERSION"
#echo "PF_ADMIN_PATCH_LEVEL: $PF_ADMIN_PATCH_LEVEL"
#exit
echo "" echo ""
echo -e "\033[32m--\033[m" echo -e "\033[32m--\033[m"
echo "" echo ""
@@ -275,6 +282,9 @@ DEFAULT_APACHE_SERVER_CERT="server-bundle.crt"
DEFAULT_APACHE_SERVER_KEY="server.key" DEFAULT_APACHE_SERVER_KEY="server.key"
DEFAULT_DEBIAN_APACHE_VHOST_DIR="/etc/apache2/sites-available" DEFAULT_DEBIAN_APACHE_VHOST_DIR="/etc/apache2/sites-available"
DEFAULT_APACHE_VHOST_DIR="/usr/local/apache2/conf/vhosts" DEFAULT_APACHE_VHOST_DIR="/usr/local/apache2/conf/vhosts"
DEFAULT_COMPOSER="/usr/local/bin/composer"
DEFAULT_POSTFIX_DB_HOST_PGSQL="/run/postgresql" DEFAULT_POSTFIX_DB_HOST_PGSQL="/run/postgresql"
if [[ -S "/tmp/mysql.sock" ]] ; then if [[ -S "/tmp/mysql.sock" ]] ; then
DEFAULT_POSTFIX_DB_HOST_MYSQL="unix:/tmp/mysql.sock" DEFAULT_POSTFIX_DB_HOST_MYSQL="unix:/tmp/mysql.sock"
@@ -379,6 +389,8 @@ if [[ -z "$APACHE_VHOST_DIR" ]] ; then
fi fi
fi fi
[[ -n "${COMPOSER}" ]] || COMPOSER=${DEFAULT_COMPOSER}
[[ -n "$POSTFIX_DB_TYPE" ]] || fatal "Database Type of Postfix Database (POSTFIX_DB_TYPE) not present!" [[ -n "$POSTFIX_DB_TYPE" ]] || fatal "Database Type of Postfix Database (POSTFIX_DB_TYPE) not present!"
[[ -n "$POSTFIX_DB_HOST_MYSQL" ]] || POSTFIX_DB_HOST_MYSQL="$DEFAULT_POSTFIX_DB_HOST_MYSQL" [[ -n "$POSTFIX_DB_HOST_MYSQL" ]] || POSTFIX_DB_HOST_MYSQL="$DEFAULT_POSTFIX_DB_HOST_MYSQL"
[[ -n "$POSTFIX_DB_HOST_PGSQL" ]] ||POSTFIX_DB_HOST_PGSQL="$DEFAULT_POSTFIX_DB_HOST_PGSQL" [[ -n "$POSTFIX_DB_HOST_PGSQL" ]] ||POSTFIX_DB_HOST_PGSQL="$DEFAULT_POSTFIX_DB_HOST_PGSQL"
@@ -926,11 +938,79 @@ done
if $_failed ; then if $_failed ; then
echo_failed echo_failed
error "$(cat $log_file)" error "$(cat $log_file)"
echononl "\tcontinue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Script terminated by user input.."
else else
echo_ok echo_ok
fi fi
echo -e "\n\n\t\033[37m\033[1mInstall (global) composer..\033[m\n"
echononl "\tDownload composer from 'getcomposer.org'.."
php -r "copy('https://getcomposer.org/installer', '${_src_base_dir}/composer-setup.php');" > $log_file 2>&1
if [[ "$?" = "0" ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
echononl "\tcontinue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Script terminated by user input.."
fi
echononl "\tInstall composer to ${COMPOSER}"
php ${_src_base_dir}/composer-setup.php --install-dir=$(dirname ${COMPOSER}) \
--filename=$(basename ${COMPOSER}) > $log_file 2>&1
if [[ "$?" = "0" ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
echononl "\tcontinue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Script terminated by user input.."
fi
echononl "\tRemove the installer"
php -r "unlink('${_src_base_dir}/composer-setup.php');" > $log_file 2>&1
if [[ "$?" = "0" ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
echononl "\tcontinue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Script terminated by user input.."
fi
echo -e "\n\n\t\033[37m\033[1mBase install Postfixadmin..\033[m\n" echo -e "\n\n\t\033[37m\033[1mBase install Postfixadmin..\033[m\n"
@@ -1102,6 +1182,37 @@ else
echo_ok echo_ok
fi fi
echononl "\tInstall PHP dependencies ( composer install --no-dev ... ).."
if [[ ${PF_ADMIN_MAJOR_VERSION} -gt 3 ]] ; then
if $PHP_DEBIAN_INSTALLATION ; then
su ${HTTP_USER} -c"cd ${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}
php /usr/local/bin/composer install --prefer-dist --no-interaction --no-dev" -s /bin/bash \
> $log_file 2>&1
else
su ${HTTP_USER} -c"cd ${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}
/usr/local/php-${php_latest_ver}/bin/php /usr/local/bin/composer --prefer-dist \
--no-interaction install --no-dev" -s /bin/bash > $log_file 2>&1
fi
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
echononl "\tcontinue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Script terminated by user input.."
fi
else
echo_skipped
fi
echononl "\tRemove existing symlink '${WEBSITE_BASEDIR}/htdocs'" echononl "\tRemove existing symlink '${WEBSITE_BASEDIR}/htdocs'"
if [[ -h "${WEBSITE_BASEDIR}/htdocs" ]]; then if [[ -h "${WEBSITE_BASEDIR}/htdocs" ]]; then
@@ -2097,7 +2208,7 @@ fi
echo -e "\n\n\t\033[37m\033[1mConfigure Postfix Admin\033[m\n" echo -e "\n\n\t\033[37m\033[1mConfigure Postfix Admin\033[m\n"
if [[ $MAJOR_VERSION -eq 3 ]] && [[ $MINOR_VERSION -gt 0 ]]; then if [[ $MAJOR_VERSION -gt 3 ]] || [[ $MAJOR_VERSION -eq 3 ]] && [[ $MINOR_VERSION -gt 0 ]]; then
pfa_conf_file="${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}/config.local.php" pfa_conf_file="${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}/config.local.php"
cp -a "${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}/config.inc.php" "$pfa_conf_file" cp -a "${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}/config.inc.php" "$pfa_conf_file"
else else
@@ -3496,6 +3607,26 @@ else
error "$(cat $log_file)" error "$(cat $log_file)"
fi fi
echononl "\tRestart Apache Webservice.."
if [[ -n "$APACHE_SERVICE_FILE" ]] || [[ -n "$APACHE_INIT_SCRIPT" ]] ; then
if [[ -n "$APACHE_SERVICE_FILE" ]] ; then
systemctl restart $APACHE_SERVICE_FILE > $log_file 2>&1
else
$APACHE_INIT_SCRIPT restart > $log_file 2>&1
fi
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
warn "Neither an init-script nor a service file for 'apache2' webservice found!"
fi
# - Start all PHP FPM engines # - Start all PHP FPM engines
# - # -
if [[ -n "$php_major_versions" ]]; then if [[ -n "$php_major_versions" ]]; then
@@ -3543,7 +3674,7 @@ fi
echo "" echo ""
info "Browse to \033[1mhttp://${WEBSITE_NAME}/setup.php\033[m to create a 'setup password'\n$(cat <<EOF info "Browse to \033[1mhttps://${WEBSITE_NAME}/setup.php\033[m to create a 'setup password'\n$(cat <<EOF
\t \033[33mIn caes of updating postfix.admin browse this URL and \033[1mlogin with your \t \033[33mIn caes of updating postfix.admin browse this URL and \033[1mlogin with your
\t setup_password\033[m\033[33m, because only after that the database '${POSTFIX_DB_NAME}' \t setup_password\033[m\033[33m, because only after that the database '${POSTFIX_DB_NAME}'

View File

@@ -2597,6 +2597,8 @@ chown -R vmail:vmail /usr/local/dovecot-${_version}/etc/dovecot/sieve
if $systemd_support; then if $systemd_support; then
_folder_created=false
## - # - At time, we don't use private tmp directory for divecot. ## - # - At time, we don't use private tmp directory for divecot.
## - # - ## - # -
## - echononl "\tAdjust Systemd service file, set PrivateTmp=false.." ## - echononl "\tAdjust Systemd service file, set PrivateTmp=false.."
@@ -2621,8 +2623,15 @@ if $systemd_support; then
## - here: ## - here:
## - LimitNOFILE=32768 ## - LimitNOFILE=32768
## - ## -
if [[ -f "/lib/systemd/system/dovecot.service" ]] \ ## - zwei Bemerkungen:
&& $(grep -q -E "^LimitNOFILE=" /lib/systemd/system/dovecot.service) ; then ## - - keine runden Klammern notwendig, da die bash '&&' vor '||' auswertet
## - - hier auch keine backslah '\' am ende der zeile notwendig, da statement
## - offensichtlich noch nichzt abgeschlossen ist (die bash erkennt das)
## -
if [[ -f /lib/systemd/system/dovecot.service ]] &&
grep -qE '^[[:space:]]*LimitNOFILE=' /lib/systemd/system/dovecot.service ||
[[ -f /etc/systemd/system/dovecot.service ]] &&
grep -qE '^[[:space:]]*LimitNOFILE=' /etc/systemd/system/dovecot.service ; then
_LimitNOFILE="$(grep -E "^LimitNOFILE=[[:digit:]]+" /lib/systemd/system/dovecot.service | cut -d'=' -f2)" _LimitNOFILE="$(grep -E "^LimitNOFILE=[[:digit:]]+" /lib/systemd/system/dovecot.service | cut -d'=' -f2)"
@@ -2638,6 +2647,7 @@ if $systemd_support; then
mkdir "/etc/systemd/system/dovecot.service.d" > /dev/null 2>&1 mkdir "/etc/systemd/system/dovecot.service.d" > /dev/null 2>&1
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo -e "$rc_done" echo -e "$rc_done"
_folder_created=true
else else
echo -e "$rc_failed" echo -e "$rc_failed"
adjust_limit_nofile=false adjust_limit_nofile=false
@@ -2656,8 +2666,54 @@ LimitNOFILE=$service_limit_nofile
EOF EOF
echo -e "$rc_done" echo -e "$rc_done"
fi fi
fi fi
## - Adjust systemd hardening:
## -
## - Options such as ProtectSystem=full/strict make the service's mount namespace,
## - including /usr (and thus /usr/local/dovecote/..), read-only, even though it is w
## - ritable outside the service.
## -
## - However, we would like to allow dovecot to write to the directory
## - /usr/local/dovecot/etc/dovecot/sieve/.
## -
## - ProtectSystem=off
## -
## - zwei Bemerkungen:
## - - keine runden Klammern notwendig, da die bash '&&' vor '||' auswertet
## - - hier auch keine backslah '\' am ende der zeile notwendig, da statement
## - offensichtlich noch nichzt abgeschlossen ist (die bash erkennt das)
## -
if [[ -f /lib/systemd/system/dovecot.service ]] &&
grep -qE '^[[:space:]]*ProtectSystem=' /lib/systemd/system/dovecot.service ||
[[ -f /etc/systemd/system/dovecot.service ]] &&
grep -qE '^[[:space:]]*ProtectSystem=' /etc/systemd/system/dovecot.service ; then
if ! ${_folder_created} ; then
echononl "\tCreate Directory '/etc/systemd/system/dovecot.service.d'.."
if [[ -d "/etc/systemd/system/dovecot.service.d" ]] ; then
echo -e "$rc_skipped"
else
mkdir "/etc/systemd/system/dovecot.service.d" > /dev/null 2>&1
if [[ $? -eq 0 ]]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
fi
fi
fi
echononl "\tSet 'ProtectSystem=off' for 'dovecot.service'.."
cat <<EOF > /etc/systemd/system/dovecot.service.d/systemd-hardening.conf
[Service]
ProtectSystem=off
EOF
echo -e "$rc_done"
fi
echononl "\tReload systemd .." echononl "\tReload systemd .."
systemctl daemon-reload > /dev/null 2>&1 systemctl daemon-reload > /dev/null 2>&1