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