#!/usr/bin/env bash tmp_err_msg=$(mktemp) # ------------- # --- Some functions # ------------- clean_up() { # Perform program exit housekeeping rm -f $tmp_err_msg exit $1 } echononl(){ echo X\\c > /tmp/shprompt$$ if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then echo -e -n "$*\\c" 1>&2 else echo -e -n "$*" 1>&2 fi rm /tmp/shprompt$$ } fatal(){ echo "" echo -e "fatal error: $*" echo "" echo -e "\t\033[31m\033[1mInstalllation will be interrupted\033[m\033[m" echo "" exit 1 } error(){ echo "" echo -e "\t[ \033[31m\033[1mFehler\033[m ]: $*" echo "" } warn (){ echo "" echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*" echo "" } info (){ echo "" echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*" echo "" } echo_done() { echo -e "\033[80G[ \033[32mdone\033[m ]" } echo_ok() { echo -e "\033[80G[ \033[32mok\033[m ]" } echo_warning() { echo -e "\033[80G[ \033[33m\033[1mwarn\033[m ]" } echo_failed(){ echo -e "\033[80G[ \033[1;31mfailed\033[m ]" } echo_skipped() { echo -e "\033[80G[ \033[33m\033[1mskipped\033[m ]" } echononl " Create file \"greylist_client_access_pcre\"" if [[ ! -f /etc/postfix/greylist_client_access_pcre ]]; then cat < /etc/postfix/greylist_client_access_pcre # --- # Check Client Access for greylisting (selective greylisting) # --- # # - Note: # - # - Action 'check_greylist' must be defined by 'smtpd_restriction_classes' # - and also set with an action (check_policy_service inet:127.0.0.1:10023) # - in file /etc/postfix/ main.cf. # - # - Your main.cf may looks like: # - # - smtpd_restriction_classes = check_greylist # - check_greylist = check_policy_service inet:127.0.0.1:10023 # - # - smtpd_recipient_restrictions = # - ... # - check_client_access pcre:/etc/postfix/greylist_client_access_pcre, # - ... # - # - smtpd_relay_restrictions = # - ... # - check_client_access pcre:/etc/postfix/greylist_client_access_pcre, # - ... # --- # - For clients matching the following rules greylisting check is applied. # --- # unkown clients /^unknown$/ check_greylist # everything with 3 or more hyphens in the hostname /(\\-.+){3}$/ check_greylist # everything with 4 or more dots in the hostname /(\\..+){4}$/ check_greylist # dialups /(^|[0-9.x_-])(abo|br(e|oa)dband|cabel|(hk)?cablep?|catv|cbl|cidr|d?client2?|cust(omer)?s?|dhcp|dial?(in|up)?|d[iu]p|[asx]?dsld?|dyn(a(dsl|mic)?)?|home|in-addr|modem(cable)?|(di)?pool|ppp|ptr|rev|static|user|YahooBB[0-9]{12}|c[[:alnum:]]{6,}(\\.[a-z]{3})?\\.virtua|[1-9]Cust[0-9]+|AC[A-Z][0-9A-F]{5}\\.ipt|pcp[0-9]{6,}pcs|S0106[[:alnum:]]{12,}\\.[a-z]{2})[0-9.x_-]/ check_greylist EOF if [[ $? -eq 0 ]] ; then echo_ok else echo_failed fi else echo_skipped fi clean_up 0