summaryrefslogtreecommitdiff
path: root/postfix/postfix.sh
blob: 9ac1d0e0043b8e35eef12533caeffe1a27391660 (plain)
  1. #!/bin/sh
  2. #
  3. # /etc/local-COMMON/postfix/postfix.sh
  4. # Copyright 2002-2007 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # $Id: postfix.sh,v 1.76 2008-05-25 19:00:16 jonas Exp $
  7. #
  8. # Auto-tweak plain installed postfix Debian package
  9. #
  10. # TODO:
  11. # * Implement stuff from here: http://www.wsrcc.com/spam/
  12. # * Implement stuff from here: http://www.muine.org/~hoang/postfix.html
  13. # * Implement stuff from here: http://jimsun.linxnet.com/misc/postfix-anti-UCE.txt
  14. # * Figure out a way to use chroot jail for TLS stuff.
  15. # * Use https://www.dnswl.org/
  16. set -e
  17. # Let's standardize sort
  18. export LC_ALL=C
  19. warn() {
  20. echo >&2 "Warning: $1"
  21. }
  22. exit1() {
  23. echo >&2 "Error: $1"
  24. echo >&2 "Exiting..."
  25. exit 1
  26. }
  27. # Favor specific CA for our own server and client certificates
  28. # (comment out to trust any CA)
  29. #cacert_smtpd="/etc/ssl/certs/cacert.org.pem"
  30. cacert_smtp=
  31. cacert_lmtp=
  32. # File containing all trusted CA certificates
  33. # (comment out if no chroot or it contains all individual files)
  34. cacert_default="/etc/ssl/certs/ca-certificates.crt"
  35. realmsdir='/etc/local-REDPILL'
  36. configdirs='/etc/local /etc/local-ORG /etc/local-REDPILL /etc/local-COMMON'
  37. confdir='/etc/postfix'
  38. postconf=/usr/sbin/postconf
  39. sp='[[:space:]]'
  40. pf23="$($postconf -d mail_version | grep -Po '= \K([3-9]|2\.([3-9]|1\d+))(\.[0-9])*$')"
  41. if ! [ -d "$realmsdir" ]; then
  42. warn "Realms directory \"$realmsdir\" does not exist."
  43. fi
  44. #postgrey=
  45. #if [ -x /usr/sbin/postgrey ]; then
  46. # # FIXME: Use this somehow, and only warn below
  47. # postgrey=1
  48. #else
  49. # exit1 "ERROR: Greylisting support (Debian package postgrey) missing."
  50. #fi
  51. cyrus=
  52. if [ -x /usr/sbin/saslauthd ]; then
  53. if saslauthd -v 2>&1 | grep -q '^saslauthd 2.1'; then
  54. cyrus=1
  55. else
  56. warn "Cyrus SASL too old - requires >= 2.1.1)."
  57. fi
  58. else
  59. warn "Cyrus SASL missing - (Debian package sasl2-bin)."
  60. fi
  61. dovecot=
  62. dovecot_deliver=
  63. if [ -x /usr/sbin/dovecot ]; then
  64. dovecot=1
  65. if [ -x /usr/lib/dovecot/deliver ]; then
  66. dovecot_deliver=1
  67. else
  68. warn "Dovecot deliver missing."
  69. fi
  70. else
  71. warn "Dovecot missing - (Debian package dovecot-core or dovecot)."
  72. fi
  73. sslcert=
  74. if [ -f /etc/ssl/certs/postfix.pem ]; then
  75. sslcert=1
  76. else
  77. warn "No TLS encryption - requires SSL certificate at /etc/ssl/certs/postfix.pem."
  78. fi
  79. sasl_main_type=
  80. sasl_dovecot=
  81. sasl_cyrus=
  82. if [ -n "$sslcert" ]; then
  83. # FIXME: We really want to check for at least 2.1.1 but that's tricky...
  84. if [ -n "$cyrus" ]; then
  85. sasl_cyrus=1
  86. sasl_main_type=cyrus
  87. fi
  88. if [ -n "$dovecot" ]; then
  89. if [ -n "$pf23" ]; then
  90. sasl_dovecot=1
  91. sasl_main_type=dovecot
  92. else
  93. warn "No Dovecot SASL - requires postfix >= 2.3."
  94. fi
  95. fi
  96. if [ -z "$sasl_main_type" ]; then
  97. warn "No SASL authentication - requires Cyrus SASL or Dovecot."
  98. fi
  99. else
  100. warn "No SASL authentication - requires TLS encryption."
  101. fi
  102. amavis=
  103. default_amavis_maxproc=2
  104. if [ -x /usr/sbin/amavisd ] || [ -x /usr/sbin/amavisd-new ]; then
  105. amavis=1
  106. else
  107. warn "AMaViS missing (Debian package amavisd-new)."
  108. fi
  109. dkimproxy=
  110. #dkimproxy_maxproc_in=5
  111. # FIXME: update actual outgoing maxproc from /etc/default/dkimproxy (and /etc/dkimproxy/dkimproxy_out.conf too?)
  112. dkimproxy_maxproc_out=5
  113. if [ -x /usr/sbin/dkimproxy.in ]; then
  114. if [ "1" = "$amavis" ]; then
  115. dkimproxy=1
  116. else
  117. warn "No DKIM/Domainkey - requires DKIMproxy and AMaViS."
  118. fi
  119. else
  120. warn "DKIMproxy missing (Debian package dkimproxy)."
  121. fi
  122. catfilefromownrealm() {
  123. set -e
  124. file="$1"
  125. [ -d "$realmsdir" ] || exit 0
  126. thisrealm="$(cat /etc/local-ORG/realm || dnsdomainname | tr '[a-z]' '[A-Z]')"
  127. cat "$realmsdir/$thisrealm/$file"
  128. }
  129. catallfilesfromotherrealms() {
  130. set -e
  131. file="$1"
  132. [ -d "$realmsdir" ] || exit 0
  133. [ -f "$realmsdir/realms" ] || exit 0
  134. realms="$(cat "$realmsdir/realms" | sed 's/#.*//')"
  135. thisrealm="$(cat /etc/local-ORG/realm || dnsdomainname | tr '[a-z]' '[A-Z]')"
  136. for realm in $realms; do
  137. if [ "$thisrealm" != "$realm" ]; then
  138. cat "$realmsdir/$realm/$file"
  139. fi
  140. done
  141. }
  142. catfirstfile() {
  143. set -e
  144. file="$1"
  145. context="${2:-postfix}"
  146. configdir=''
  147. for dir in $configdirs; do
  148. if [ -d "$dir/$context" ] && [ -f "$dir/$context/$file" ]; then
  149. configdir="$dir/$context"
  150. break
  151. fi
  152. done
  153. if [ -z "$configdir" ]; then
  154. exit1 "ERROR: file \"$file\" not found."
  155. fi
  156. cat "$configdir/$file"
  157. }
  158. # TODO: support quoted string, and trailing comment.
  159. getperlvarfromfile() {
  160. set -e
  161. export var="$1"
  162. export default="$2"
  163. file="$3"
  164. context="${4:-postfix}"
  165. catfirstfile "$file" "$context" \
  166. | perl -nE'/^\$$ENV{"var"}\h*=\h*(\d+)/ and $s=$1; END {print length($s) ? $s : $ENV{'default'}}'
  167. }
  168. getlinesfromfile() {
  169. set -e
  170. param="$1"
  171. shift
  172. replacements=
  173. for subparam in $@; do
  174. case "$subparam" in
  175. *=)
  176. oldparam="`echo $subparam | awk -F= '{print $1}'`"
  177. replacements="$replacements;s/,*[^,]*$oldparam[^,]*,*/,/"
  178. continue
  179. ;;
  180. *=*=*)
  181. oldparam="`echo $subparam | awk -F= '{print $1}'`"
  182. newparam="`echo $subparam | awk -F= '{print $2}'`"
  183. newparamfile="`echo $subparam | awk -F= '{print $3}'`"
  184. ;;
  185. *)
  186. oldparam=$subparam
  187. newparam=$subparam
  188. newparamfile=$subparam
  189. ;;
  190. esac
  191. newparamvalues="`getlinesfromfile $newparamfile | sed -e 's/.*=[ ]*//' -e 's/,/ /g'`"
  192. newstring=
  193. for newparamvalue in $newparamvalues; do
  194. newstring="${newstring}$newparam $newparamvalue,"
  195. done
  196. replacements="$replacements;s/$oldparam/$newstring/"
  197. done
  198. echo -n "$param = "
  199. catfirstfile "$param" | sed 's/#.*//' | tr '\n' ',' | sed -e 's/^[, ]*//;s/[, ]\+/,/g' -e 's/\^/ /g' -e "s/,\$//$replacements"
  200. }
  201. addoroverwritewithindents() {
  202. set -e
  203. file="$1"
  204. export token="$2"
  205. # provide replacement as STDIN
  206. perl -0777 -pi \
  207. -E 'BEGIN{ $s=<STDIN>; chomp $s }'\
  208. -E 's/$ENV{"token"}.*(?:\n\h.*)+\n/$s/m and $seen=1;'\
  209. -E 'END{ unless ($seen) { print $s } }'\
  210. "$file"
  211. }
  212. postmapfiles=
  213. tempdir="$(mktemp -td postfix.XXXXXX)"
  214. cp -a -t "$tempdir" "$confdir"/*
  215. # Inspired by D. J. Bernstein: http://cr.yp.to/smtp/greeting.html
  216. $postconf -c "$tempdir" -e 'smtpd_banner = $myhostname NO UCE ESMTP $mail_name (Debian/GNU)'
  217. # Some badly configured setup use hostname instead of FQDN
  218. # Disable completely: Effective, but hurts executive type guys using windows servers... :-(
  219. #if $postconf -c "$tempdir" myhostname | grep -q '\.'; then
  220. # $postconf -c "$tempdir" -e 'smtpd_helo_required = yes'
  221. #fi
  222. $postconf -c "$tempdir" -e 'smtpd_helo_required = no'
  223. $postconf -c "$tempdir" -e "`getlinesfromfile permit_mx_backup_networks`"
  224. $postconf -c "$tempdir" -e "maps_rbl_domains ="
  225. $postconf -c "$tempdir" -e "`getlinesfromfile smtpd_client_restrictions reject_rhsbl_client`"
  226. $postconf -c "$tempdir" -e "`getlinesfromfile smtpd_helo_restrictions`"
  227. $postconf -c "$tempdir" -e "`getlinesfromfile smtpd_sender_restrictions reject_rhsbl_sender ${dkimproxy:-sender_access_regex=}`"
  228. $postconf -c "$tempdir" -e "`getlinesfromfile smtpd_recipient_restrictions reject_maps_rbl=reject_rbl_client=maps_rbl_domains`"
  229. $postconf -c "$tempdir" -e "`getlinesfromfile smtpd_data_restrictions`"
  230. # FIXME: clear only specific line (not whole file) when dkimproxy unused
  231. if [ -f "$tempdir/sender_access_regex" ]; then
  232. if [ -n "$dkimproxy" ]; then
  233. grep -q -F '/^/ FILTER dkimsign:[127.0.0.1]:10026' "$tempdir/sender_access_regex" \
  234. || echo '/^/ FILTER dkimsign:[127.0.0.1]:10026' >> "$tempdir/sender_access_regex"
  235. else
  236. if grep -q -F '/^/ FILTER dkimsign:[127.0.0.1]:10026' "$tempdir/sender_access_regex"; then
  237. echo "echo '' > \"$confdir/sender_access_regex\"" >> "$tempdir/COMMANDS"
  238. rm "$tempdir/sender_access_regex"
  239. fi
  240. fi
  241. postmapfiles="$postmapfiles sender_access_regex"
  242. fi
  243. # Support exceptions to default response
  244. # (Day Old Bread (dob) lists need to reject only temporarily)
  245. $postconf -c "$tempdir" -e "rbl_reply_maps = hash:$confdir/rbl_reply_map"
  246. cat /etc/local-COMMON/postfix/rbl_reply_map \
  247. | sed 's/#.*//' \
  248. > "$tempdir/rbl_reply_map"
  249. postmapfiles="$postmapfiles rbl_reply_map"
  250. # Verify senders of common suspicious and known verifiable domains
  251. # (exclude verification of postmaster@ to not verify verification probes)
  252. # (add own domains before peers for (rare) cases of duplicates)
  253. # FIXME: somehow do this step only if enabled in smtpd_sender_restrictions
  254. # TODO: Properly implement exception exclusion like yahoo (which does not want to be checked any longer!)
  255. cat /etc/local-COMMON/postfix/maildomains | grep -v yahoo | sort | sed 's/$/ reject_unverified_sender/' > "$tempdir/sender_access"
  256. ( catfilefromownrealm maildomains | sort; catallfilesfromotherrealms maildomains | sort ) \
  257. | sed 's/\(.*\)$/postmaster@\1 permit\n\1 reject_unverified_sender/' >> "$tempdir/sender_access"
  258. [ ! -f "$tempdir/sender_access.addon" ] || cat "$tempdir/sender_access.addon" >> "$tempdir/sender_access"
  259. postmapfiles="$postmapfiles sender_access"
  260. $postconf -c "$tempdir" -e "unverified_sender_reject_code = 550"
  261. # Trust recipient verification too
  262. $postconf -c "$tempdir" -e "unverified_recipient_reject_code = 550"
  263. if [ -n "$dovecot_deliver" ]; then
  264. $postconf -c "$tempdir" -e mailbox_command=/usr/lib/dovecot/deliver
  265. fi
  266. if [ -n "$sasl_cyrus" ]; then
  267. saslsubdir="sasl"
  268. mkdir -p "$tempdir/$saslsubdir"
  269. echo 'mech_list: plain login' > "$tempdir/$saslsubdir/smtpd.conf"
  270. echo 'minimum_layer: 0' >> "$tempdir/$saslsubdir/smtpd.conf"
  271. echo 'sasl_pwcheck_method: saslauthd' >> "$tempdir/$saslsubdir/smtpd.conf"
  272. echo 'auto_transition: false' >> "$tempdir/$saslsubdir/smtpd.conf"
  273. groups postfix | grep -q sasl || echo "adduser postfix sasl" >> "$tempdir/COMMANDS"
  274. # Release TLS-related daemons from chroot jail (bringing SASL into the jail is just too messy)
  275. sed --in-place \
  276. -e "s/^\(smtp$sp\+inet\($sp\+[n-]\)\{2\}$sp\+\)[n-]\(\($sp\+-\)\{2\}$sp\+smtpd\).*/\1n\3 -o smtpd_sasl_auth_enable=yes/" \
  277. -e "s/^#\?\(\(smtps\|587\)$sp\+inet\($sp\+[n-]\)\{2\}$sp\+\)[n-]/\1n/" \
  278. -e "s/^#\(tlsmgr$sp\)/\1/" \
  279. "$tempdir/master.cf"
  280. addoroverwritewithindents $tempdir/master.cf '^tlsmgr\h' << EOF
  281. tlsmgr unix - - - 300 1 tlsmgr
  282. EOF
  283. fi
  284. case "$sasl_main_type" in
  285. '') ;;
  286. dovecot)
  287. $postconf -c "$tempdir" -e smtpd_sasl_type=dovecot
  288. $postconf -c "$tempdir" -e smtpd_sasl_path=private/auth
  289. ;;
  290. cyrus)
  291. $postconf -c "$tempdir" -e smtpd_sasl_type=cyrus
  292. [ -z "$pf23" ] || $postconf -c "$tempdir" -e smtpd_sasl_path=smtpd
  293. [ -n "$pf23" ] || $postconf -c "$tempdir" -e smtpd_sasl_application_name=smtpd
  294. ;;
  295. *) exit1 "ERROR: Wrong SASL type \"$sasl_main_type\"!";;
  296. esac
  297. # Avoid smtpd_tls_CApath or smtpd_tls_CAfile to trick outlook.com
  298. # See <http://postfix.1071664.n5.nabble.com/Problems-with-incoming-mails-from-outlook-com-td78356.html>
  299. if [ -n "$sslcert" ]; then
  300. $postconf -c "$tempdir" -e 'smtpd_tls_cert_file = /etc/ssl/certs/postfix.pem'
  301. $postconf -c "$tempdir" -e 'smtpd_tls_loglevel = 1'
  302. $postconf -c "$tempdir" -e 'smtpd_use_tls = yes'
  303. $postconf -c "$tempdir" -e 'smtp_tls_CApath = /etc/ssl/certs'
  304. $postconf -c "$tempdir" -e 'smtpd_tls_CApath = '
  305. $postconf -c "$tempdir" -e 'lmtp_tls_CApath = /etc/ssl/certs'
  306. $postconf -c "$tempdir" -e 'smtpd_tls_CAfile = '
  307. $postconf -c "$tempdir" -e smtp_tls_CAfile="${cacert_smtp:-$cacert_default}"
  308. $postconf -c "$tempdir" -e lmtp_tls_CAfile="${cacert_lmtp:-$cacert_default}"
  309. $postconf -c "$tempdir" -e 'smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache'
  310. $postconf -c "$tempdir" -e 'smtpd_tls_session_cache_timeout = 3600s'
  311. $postconf -c "$tempdir" -e 'tls_random_exchange_name = ${data_directory}/prng_exch'
  312. $postconf -c "$tempdir" -e 'smtpd_tls_auth_only = yes'
  313. $postconf -c "$tempdir" -e 'smtpd_sasl_auth_enable = no' # SASL is enabled explicitly with TLS transport
  314. $postconf -c "$tempdir" -e 'smtpd_sasl_security_options = noanonymous'
  315. $postconf -c "$tempdir" -e 'smtpd_sasl_local_domain = '
  316. $postconf -c "$tempdir" -e 'smtpd_tls_received_header = yes'
  317. $postconf -c "$tempdir" -e 'broken_sasl_auth_clients = yes'
  318. $postconf -c "$tempdir" -e 'tls_random_source = dev:/dev/urandom'
  319. # Accepting client certificates breaks SMTP AUTH on OutLook Express on Mac (Classic)
  320. $postconf -c "$tempdir" -e 'smtpd_tls_ask_ccert = no'
  321. if [ -e /etc/ssl/private/postfix.pem ]; then
  322. $postconf -c "$tempdir" -e 'smtpd_tls_key_file = /etc/ssl/private/postfix.pem'
  323. # Enable client side TLS only when private certificate is present
  324. $postconf -c "$tempdir" -e 'smtp_tls_cert_file = /etc/ssl/certs/postfix.pem'
  325. $postconf -c "$tempdir" -e 'smtp_tls_key_file = /etc/ssl/private/postfix.pem'
  326. $postconf -c "$tempdir" -e 'smtp_tls_loglevel = 1'
  327. $postconf -c "$tempdir" -e 'smtp_use_tls = yes'
  328. $postconf -c "$tempdir" -e 'smtp_tls_note_starttls_offer = no' # Enable to collect info for smtp_tls_per_site option
  329. $postconf -c "$tempdir" -e 'smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache'
  330. # Force using TLS for peers
  331. catallfilesfromotherrealms mailhost | sort | sed 's/^/[/;s/$/]:submission secure/' > "$tempdir/tls_policy"
  332. [ ! -f "$tempdir/tls_policy.addon" ] || cat "$tempdir/tls_policy.addon" >> "$tempdir/tls_policy"
  333. postmapfiles="$postmapfiles tls_policy"
  334. $postconf -c "$tempdir" -e "smtp_tls_policy_maps = hash:$confdir/tls_policy"
  335. else
  336. $postconf -c "$tempdir" -e 'smtp_use_tls = no'
  337. warn "No client-side TLS - requires private SSL certificate at /etc/ssl/private/postfix.pem."
  338. fi
  339. fi
  340. if [ -n "$amavis" ]; then
  341. $postconf -c "$tempdir" -e 'max_use = 10' # Avoid too much reuse
  342. amavis_maxproc=$(getperlvarfromfile max_servers "$default_amavis_maxproc" amavisd.conf.addon amavis)
  343. addoroverwritewithindents $tempdir/master.cf '^smtp-amavis\h' << EOF
  344. smtp-amavis unix - - n - $amavis_maxproc smtp
  345. -o smtp_data_done_timeout=1200s
  346. -o smtp_never_send_ehlo=yes
  347. -o smtp_send_xforward_command=yes
  348. -o disable_dns_lookups=yes
  349. -o max_use=20
  350. EOF
  351. addoroverwritewithindents $tempdir/master.cf '^127.0.0.1:10025\h' << EOF
  352. 127.0.0.1:10025 inet n - n - - smtpd
  353. -o content_filter=
  354. -o local_recipient_maps=
  355. -o relay_recipient_maps=
  356. -o smtpd_restriction_classes=
  357. -o smtpd_delay_reject=no
  358. -o smtpd_client_restrictions=permit_mynetworks,reject
  359. -o smtpd_helo_restrictions=
  360. -o smtpd_sender_restrictions=
  361. -o smtpd_recipient_restrictions=permit_mynetworks,reject
  362. -o smtpd_data_restrictions=reject_unauth_pipelining
  363. -o smtpd_end_of_data_restrictions=
  364. -o mynetworks=127.0.0.0/8
  365. -o smtpd_error_sleep_time=0
  366. -o smtpd_soft_error_limit=1001
  367. -o smtpd_hard_error_limit=1000
  368. -o smtpd_client_connection_count_limit=0
  369. -o smtpd_client_connection_rate_limit=0
  370. -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks
  371. EOF
  372. if [ -n "$dkimproxy" ]; then
  373. $postconf -c "$tempdir" -e 'content_filter = smtp-amavis:[127.0.0.1]:10028'
  374. addoroverwritewithindents $tempdir/master.cf '^submission\h' << EOF
  375. submission inet n - n - - smtpd
  376. -o syslog_name=postfix/submission
  377. -o smtpd_tls_security_level=encrypt
  378. -o smtpd_sasl_auth_enable=yes
  379. -o smtpd_client_restrictions=permit_sasl_authenticated,reject
  380. -o content_filter=dkimsign:[127.0.0.1]:10028
  381. EOF
  382. addoroverwritewithindents $tempdir/master.cf '^pickup\h' << EOF
  383. pickup fifo n - - 60 1 pickup
  384. -o content_filter=dkimsign:127.0.0.1:10028
  385. EOF
  386. addoroverwritewithindents $tempdir/master.cf '^dkimsign\h' << EOF
  387. dkimsign unix - - n - $dkimproxy_maxproc_out smtp
  388. -o smtp_send_xforward_command=yes
  389. -o smtp_discard_ehlo_keywords=8bitmime,starttls
  390. EOF
  391. addoroverwritewithindents $tempdir/master.cf '^127\.0\.0\.1:10029\h' << EOF
  392. 127.0.0.1:10029 inet n - n - - smtpd
  393. -o content_filter=
  394. -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
  395. -o smtpd_helo_restrictions=
  396. -o smtpd_client_restrictions=
  397. -o smtpd_sender_restrictions=
  398. -o smtpd_recipient_restrictions=permit_mynetworks,reject
  399. -o mynetworks=127.0.0.0/8
  400. -o smtpd_authorized_xforward_hosts=127.0.0.0/8
  401. EOF
  402. else
  403. $postconf -c "$tempdir" -e 'content_filter = smtp-amavis:[127.0.0.1]:10024'
  404. addoroverwritewithindents $tempdir/master.cf '^submission\h' << EOF
  405. submission inet n - n - - smtpd
  406. -o syslog_name=postfix/submission
  407. -o smtpd_tls_security_level=encrypt
  408. -o smtpd_sasl_auth_enable=yes
  409. -o smtpd_sasl_local_domain=\$mydomain
  410. EOF
  411. addoroverwritewithindents $tempdir/master.cf '^pickup\h' << EOF
  412. pickup fifo n - - 60 1 pickup
  413. EOF
  414. fi
  415. fi
  416. diff -ruN "$confdir" "$tempdir" || if [ $? -gt 1 ]; then exit $?; else needs_reload="1"; fi
  417. if [ "$force" = "1" ]; then
  418. do_update="y"
  419. elif [ "1" = "$needs_reload" ]; then
  420. echo -n "Above is the intended changes. OK to update (y/N)? "
  421. read do_update
  422. fi
  423. case $do_update in
  424. y|Y)
  425. if [ -f "$tempdir/COMMANDS" ]; then
  426. cat "$tempdir/COMMANDS" | sh -s
  427. fi
  428. rm -f "$tempdir/COMMANDS"
  429. diff -q "$confdir/master.cf" "$tempdir/master.cf" || if [ $? -gt 1 ]; then exit $?; else needs_restart="1"; fi
  430. cp -a -f -t "$confdir" "$tempdir"/*
  431. rm -rf "$tempdir"
  432. for file in $postmapfiles; do
  433. postmap "$confdir/$file"
  434. done
  435. if [ "1" = "$needs_restart" ]; then
  436. invoke-rc.d postfix restart
  437. else
  438. invoke-rc.d postfix force-reload
  439. fi
  440. if [ "1" = "$needs_reload" ]; then
  441. echo >&2 "Changes applied!"
  442. fi
  443. ;;
  444. *)
  445. if [ "1" = "$needs_reload" ]; then
  446. exit1 "Aborted!"
  447. fi
  448. ;;
  449. esac
  450. if [ "1" != "$needs_reload" ]; then
  451. echo >&2 "No changes needed!"
  452. fi
  453. # Based on this: http://jimsun.linxnet.com/misc/postfix-anti-UCE.txt
  454. # Support for trusted MX backup networks added
  455. # PCRE stuff avoided, as PCRE is only optional on newest Debian packages
  456. # RBLs replaced with those recommended by http://www.antispews.org/
  457. # AMaViS tweaks as documented in amavisd-new package
  458. # AUTH-SMTP based on these:
  459. # http://lists.q-linux.com/pipermail/plug/2003-July/029503.html
  460. # http://www.porcupine.org/postfix-mirror/newdoc/SASL_README.html
  461. # Here's a convenient overview of different blackholes:
  462. # http://rbls.org/