Extend selective SRS management and add installer tests

This commit is contained in:
2026-10-20 11:20:38 +02:00
parent 3a7248191c
commit 53b92f7867
13 changed files with 2332 additions and 2 deletions
+41
View File
@@ -203,6 +203,14 @@ postsrsd_srs_domain() {
}
srs_alias_tool() {
local action="$1"
python3 "$SRS_ALIAS_HELPER" "$action" \
--main-cf "$POSTFIX_MAIN_CF" \
--domain "$_SRS_DOMAIN" \
--reverse-map "socketmap:inet:${SRS_REVERSE_SOCKET_HOST}:${SRS_REVERSE_SOCKET_PORT}:reverse"
}
state_main_cf_matches() {
local parameter="$1"
local was_set="$2"
@@ -919,6 +927,8 @@ check_required_commands \
load_srs_config
load_srs_state
[[ -f "$SRS_ALIAS_HELPER" && ! -L "$SRS_ALIAS_HELPER" ]] ||
fatal "Missing regular SRS alias helper: ${SRS_ALIAS_HELPER}"
# ----------
@@ -1412,7 +1422,12 @@ blank_line
# Handle detected state
# ----------
srs_alias_status="$(srs_alias_tool status 2>"$log_file")" ||
fatal "Unsafe virtual alias configuration: $(cat "$log_file")"
if [[ "$srs_state" == "disabled" ]]; then
[[ "$srs_alias_status" == 'absent' ]] ||
fatal "SRS marked disabled but virtual alias items remain (${srs_alias_status})."
info "Selective SRS is already disabled. Nothing to do."
clean_up 0
fi
@@ -1425,6 +1440,11 @@ fi
if ! $installation_ok || ! $services_exist ; then
fatal "Selective SRS is enabled, but the installation is incomplete. Deactivation was not attempted."
fi
if [[ "$srs_alias_status" == 'legacy' ]]; then
fatal "SRS virtual alias settings are not tracked. Run the revised activate-srs.sh once to adopt them first."
fi
[[ "$srs_alias_status" == 'managed' || "$srs_alias_status" == 'absent' ]] ||
fatal "Unsafe SRS alias status: ${srs_alias_status}"
# ----------
@@ -1583,6 +1603,19 @@ else
fi
# ----------
# Remove only SRS-owned virtual alias list items; preserve later admin edits
# ----------
if [[ "$srs_alias_status" == 'managed' ]]; then
echononl "Remove tracked SRS virtual alias items.."
if srs_alias_tool remove > "$log_file" 2>&1 ; then
echo_ok
else
echo_failed
fatal_with_deactivation_rollback "Cannot safely remove SRS alias items: $(cat "$log_file")"
fi
fi
# ----------
# Restore master.cf
# ----------
@@ -1782,6 +1815,14 @@ else
verification_ok=false
fi
echononl "Verify SRS virtual alias items are absent.."
if [[ "$(srs_alias_tool status 2>"$log_file")" == 'absent' ]]; then
echo_ok
else
echo_failed
verification_ok=false
fi
echononl "Verify pre-SRS master.cf state.."
if state_master_option_matches \
smtp \