From 15dbc26592ad35baf019defc93a7ff1377ebb1fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Mon, 9 Dec 2024 10:08:20 +0100 Subject: [PATCH] fix exclusion domain list --- src/bash/filter.sh | 28 +++++++++++++++------------- src/bash/testCopyInOut.sh | 0 2 files changed, 15 insertions(+), 13 deletions(-) mode change 100644 => 100755 src/bash/testCopyInOut.sh diff --git a/src/bash/filter.sh b/src/bash/filter.sh index 2989e89..19e0e80 100755 --- a/src/bash/filter.sh +++ b/src/bash/filter.sh @@ -47,8 +47,8 @@ DEFAULT_MODE="both" DEFAULT_PERIOD="month" DEFAULT_TRACK="" -cd $(dirname $0) -DOMAINEDEPOT=$(cat config/domainedepot) +cd "$(dirname $0)" +DOMAINEDEPOT="$(cat config/domainedepot)" # Exit codes from EX_TEMPFAIL=75 EX_UNAVAILABLE=69 @@ -62,7 +62,7 @@ MAILS=/tmp/FILTER MAX_KEEP_IN_MAIL=5ki MAX_UPLOAD_SIZE=1Gi SHRINK_CMD=/home/filter/eMailShrinker -JIRAFEAU_URL=https://depot.${DOMAINEDEPOT:-"kaz.bzh"} +JIRAFEAU_URL="https://depot.${DOMAINEDEPOT:-"kaz.bzh"}" JIRAFEAU_LOCAL=http://depot MD5_CMD=/usr/bin/md5sum DISCLAMER_CMD=altermime @@ -72,7 +72,7 @@ ARCHIVE_MIME="text/kaz_email_archive" FILE_SKIP_DOMAINS="config/file_domaines_non_depollues.txt" #on enlève les commentaires et les lignes vides -SKIP_DOMAINS=$(grep -Ev '^#|^[[:space:]]*$' $FILE_SKIP_DOMAINS 2>/dev/null) +SKIP_DOMAINS="$(sed 's:#.*$::g' 's/[[:blank:]]//g' "${FILE_SKIP_DOMAINS}" 2>/dev/null)" KEEP_FAILED=true DEBUG=true @@ -144,15 +144,17 @@ function check_skip_domains() { local SKIP_DOMAINS="$1" local LIST_EMAILS="$2" - for email in $LIST_EMAILS; do + for email in ${LIST_EMAILS}; do # Extraire le domaine de l'email (partie après le "@") local domain="${email##*@}" - # Utiliser grep pour vérifier si le domaine est dans la liste des domaines à sauter - if echo "${SKIP_DOMAINS}" | grep -q -w "${domain}"; then - echo "yes" - return - fi + for domain in ${SKIP_DOMAINS}; do + # vérification si le domaine est dans la liste des domaines à sauter + if [[ " ${email} " =~ "${domain} " ]] ; then + echo "yes" + return + fi + done done # Si aucun domaine n'a été trouvé, retourner "no" @@ -172,8 +174,8 @@ fi #format "-f sender -- dest1 [...dest(i)] " LIST_EMAILS=$(echo $@) #on nettoie -LIST_EMAILS=$(sed 's/-f//g' <<< $LIST_EMAILS) -LIST_EMAILS=$(sed 's/--//g' <<< $LIST_EMAILS) +LIST_EMAILS=$(sed 's/-f//g' <<< ${LIST_EMAILS}) +LIST_EMAILS=$(sed 's/--//g' <<< ${LIST_EMAILS}) MAIL_SOURCE=$(echo $@ | awk 'BEGIN{FS=" "} {print $2}') DATE_TEMPS=$(date "+%Y-%m-%d-%H:%M:%S") @@ -231,7 +233,7 @@ if [ "${MODE}" = "none" ]; then fi -if [ "$(check_skip_domains "$SKIP_DOMAINS" "$LIST_EMAILS")" = "yes" ]; then +if [ "$(check_skip_domains "${SKIP_DOMAINS}" "${LIST_EMAILS}")" = "yes" ]; then LOG_FIC " - ${GREEN}send without change (skip domain)${NC}" ${SENDMAIL} "$@" < "${INSPECT_DIR}/in.$$" quitFilter 0 diff --git a/src/bash/testCopyInOut.sh b/src/bash/testCopyInOut.sh old mode 100644 new mode 100755