Browse Source

allow_external_origin

main
root 2 weeks ago
parent
commit
39e6d4a4fc
  1. 7
      sympa/miaou/miaou-install-from-import-sympa
  2. 2
      sympa/miaou/miaou-migrate-sympa-from-container
  3. 46
      sympa/recipe/sympa_fix_external_origin.recipe

7
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

2
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
}

46
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
Loading…
Cancel
Save