diff --git a/sympa/miaou/miaou-install-from-import-sympa b/sympa/miaou/miaou-install-from-import-sympa index 6f1e2b8..dc7da88 100755 --- a/sympa/miaou/miaou-install-from-import-sympa +++ b/sympa/miaou/miaou-install-from-import-sympa @@ -47,9 +47,10 @@ function install_fake_additional { miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa_ldap_auth_remote.recipe } -function fix_dkim_dmarc { - echo 'fix dkim global on...' +function fix_entries { + echo 'fix entries global on...' miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa_fix_dkim_dmarc.recipe + miaou-recipe "$CONTAINER" "$BASEDIR"/../recipe/sympa_fix_external_origin.recipe } function import { @@ -73,6 +74,6 @@ parse_options $* install import -fix_dkim_dmarc +fix_entries install_fake_additional diff --git a/sympa/miaou/miaou-migrate-sympa-from-container b/sympa/miaou/miaou-migrate-sympa-from-container index 9f3518b..2e8fc68 100755 --- a/sympa/miaou/miaou-migrate-sympa-from-container +++ b/sympa/miaou/miaou-migrate-sympa-from-container @@ -56,7 +56,7 @@ function export_sympa { ./sympa_purge.bash ./sympa_export.bash EOF - SYMPA_ARCHIVE=$(miaou-exec $CONTAINER -- find -maxdepth 1 -type f -name "*.sympa" | sort -rn | head -1) + SYMPA_ARCHIVE=$(miaou-exec $CONTAINER -- find -type f -name "\*.sympa" | sort -rn | head -1) miaou-pull $CONTAINER $SYMPA_ARCHIVE } diff --git a/sympa/recipe/sympa_fix_external_origin.recipe b/sympa/recipe/sympa_fix_external_origin.recipe new file mode 100644 index 0000000..5eb471e --- /dev/null +++ b/sympa/recipe/sympa_fix_external_origin.recipe @@ -0,0 +1,46 @@ +#!/usr/bin/env miaou-recipe + +# CONSTANTS + +GLOBAL_CONF=/etc/sympa/sympa/sympa.conf +LIST_DATA_DIR=/var/lib/sympa/list_data +FOUND=false + +# FUNCTIONS + +function fix_external_origin { + if ! grep -q "^allowed_external_origin.*\*$" $GLOBAL_CONF; then + /opt/miaou-bash/tools/append_or_replace '^allowed_external_origin.*$' 'allowed_external_origin *' $GLOBAL_CONF + + echo 'allowed_external_origin now enabled' + FOUND=true + else + echo 'allowed_external_origin already enabled globally!' + fi + config_files=$(find $LIST_DATA_DIR -name "config" -type f) + for i in $config_files; do + if grep -q ^allowed_external_origin $i; then + FOUND=true + echo "found problematic configuration in $i" + remove_section_from_file $i allowed_external_origin + fi + done +} + +function remove_section_from_file { + local file=$1 + local section=$2 + awk "/^$section/{found=1} !found{print} /^$/{found=0}" $file > $file.new + mv $file.new $file + chown sympa:sympa $file +} + +function restart_services { + $FOUND && systemctl restart sympa wwsympa.socket || true +} + +# MAIN + +set -Eue +fix_external_origin +restart_services