Бруй В.В., Карлов С.В. - Linux-сервер - пошаговые инструкции - инсталляции и настройки (1077321), страница 89
Текст из файла (страница 89)
which is a lousy way of checking if the# date is longer than n chars long.#if ${length_80:$header_date:} is not $header_date:thenfail text "This message has been rejected because it has\n\an overlength date field which can be used\n\to subvert Microsoft mail programs\n\The following URL has further information\n\http://www.securityfocus.com/frames/?content=/templates/article.html%3Fid%3D61"seen finishendif## --------------------------------------------------------------------# These messages are now being sent with a <> envelope sender, but# blocking all error messages that pattern match prevents bounces# getting back....
so we fudge it somewhat and check for known# header signatures. Other bounces are allowed through.#if $header_from: contains "@sexyfun.net"thenfail text "This message has been rejected since it has\n\the signature of a known virus in the header."seen finishendifif error_message and $header_from: contains "Mailer-Daemon@"then# looks like a real error message - just ignore itfinishendif## --------------------------------------------------------------------# Look for single part MIME messages with suspicious name extensions.# Check Content-Type header using quoted filename [content_type_quoted_fn_match]#Глава 27. Exim – почтовый транспортный агент389if $header_content-type: matches"(?:file)?name=(\"[^\"]+\\\\.(?:ad[ep]|ba[st]|chm|cmd|com|cpl|crt|eml|exe|hlp|hta|in[fs]|isp|jse?|lnk|md[be]|ms[cipt]|pcd|pif|reg|scr|sct|shs|url|vb[se]|ws[fhc])\")"thenfail text "This message has been rejected because it has\n\potentially executable content $1\n\This form of attachment has been used by\n\recent viruses or other malware.\n\If you meant to send this file then please\n\package it up as a zip file and resend it."seen finishendif# Same again using unquoted filename [content_type_unquoted_fn_match]#if $header_content-type: matches"(?:file)?name=(\\\\S+\\\\.(?:ad[ep]|ba[st]|chm|cmd|com|cpl|crt|eml|exe|hlp|hta|in[fs]|isp|jse?|lnk|md[be]|ms[cipt]|pcd|pif|reg|scr|sct|shs|url|vb[se]|ws[fhc]))"thenfail text "This message has been rejected because it has\n\potentially executable content $1\n\This form of attachment has been used by\n\recent viruses or other malware.\n\If you meant to send this file then please\n\package it up as a zip file and resend it."seen finishendif## --------------------------------------------------------------------# Attempt to catch embedded VBS attachments in emails.
These were# used as the basis for the ILOVEYOU virus and its variants - many# many varients. Quoted filename - [body_quoted_fn_match].#if $message_body matches "(?:Content-(?:Type:(?>\\\\s*)[\\\\w-]+/[\\\\w]+|Disposition:(?>\\\\s*)attachment);(?>\\\\s*)(?:file)?name=|begin(?>\\\\s+)[07]{3,4}(?>\\\\s+))(\"[^\"]+\\\\.(?:ad[ep]|ba[st]|chm|cmd|com|cpl|crt|eml|exe|hlp|hta|in[fs]|isp|jse?|lnk|md[be]|ms[cipt]|pcd|pif|reg|scr|sct|shs|url|vb[se]|ws[fhc])\")[\\\\s;]"thenfail text "This message has been rejected because it has\n\a potentially executable attachment $1\n\This form of attachment has been used by\n\recent viruses or other malware.\n\If you meant to send this file then please\n\package it up as a zip file and resend it."seen finishendif# Same again using unquoted filename [body_unquoted_fn_match].if $message_body matches "(?:Content-(?:Type:(?>\\\\s*)[\\\\w-]+/[\\\\w]+|Disposition:(?>\\\\s*)attachment);(?>\\\\s*)(?:file)?name=|begin(?>\\\\s+)[07]{3,4}(?>\\\\s+))(\\\\S+\\\\.(?:ad[ep]|ba[st]|chm|cmd|com|cpl|crt|eml|exe|hlp|hta|in[fs]|isp|jse?|lnk|md[be]|ms[cipt]|pcd|pif|reg|scr|sct|shs|url|vb[se]|ws[fhc]))[\\\\s;]"thenfail text "This message has been rejected because it has\n\a potentially executable attachment $1\n\This form of attachment has been used by\n\recent viruses or other malware.\n\If you meant to send this file then please\n\390Часть 7.
Программное обеспечение для организации службы электронной почтыpackage it up as a zip file and resend it."seen finishendif## ---------------------------------------------------------------------ЗАМЕЧАНИЕ: Этот файл может быть модифицирован для фильтрации сообщений, содержащих вирусы и спам. Кроме того, он может быть использован вами в качестве примера при создании собственныхфильтров.Шаг 2Определите права доступа к файлу /etc/mail/system-filter и назначьте его владельцем пользователя root:[root@test /]# chmod 640 /etc/mail/system-filter[root@test /]# chown 0.12 /etc/mail/system-filterКонфигурационный файл /etc/sysconfig/eximФайл /etc/sysconfig/exim используется для передачи Exim необходимых опций при запуске.Шаг 1Создайте файл /etc/sysconfig/exim, отредактируйте строки в соответствии с вашими потребностями и приведенными ниже рекомендациями:# Run Exim as a daemon on the system. Remove the "-bd" option# to run Exim as a Null Client Mail Server.DAEMON="-bd "# Procede the queue every 1 minutes.QUEUE="-q1m"В этом файле строка:DAEMON=""предписывает выполнять Exim в качестве службы и принимать внешние сообщения.Строка:UEUE="-q1m"предписывает предпринимать попытки постановки сообщений в очередь с интервалом в 1 минуту.Шаг 2Определите права доступа к файлу /etc/sysconfig/exim и назначьте его владельцем пользователя root:[root@test /]# chmod 644 /etc/sysconfig/exim[root@test /]# chown 0.0 /etc/sysconfig/eximФайл инициализационный /etc/init.d/eximШаг 1Создайте /etc/init.d/exim, содержащий следующие строки:#!/bin/bash#########This shell script takes care of starting and stopping Exim.chkconfig: 2345 80 30description: Exim is a Mail Transport Agent, which is the program \that moves mail from one machine to another.processname: eximconfig: /etc/mail/exim.confpidfile: /var/run/exim.pid# Source function library..
/etc/init.d/functions# Source networking configuration.Глава 27. Exim – почтовый транспортный агент. /etc/sysconfig/network# Source for additional options if we have them.if [ -f /etc/sysconfig/exim ] ; then. /etc/sysconfig/eximfi# Check that networking is up.[ ${NETWORKING} = "no" ] && exit 0# If Exim is not available stop now.[ -f /usr/sbin/exim ] || exit 0# Path to the Exim binary.exim=/usr/sbin/eximRETVAL=0prog="Exim"start() {echo -n $"Starting $prog: "daemon $exim $DAEMON $QUEUERETVAL=$?echo[ $RETVAL -eq 0 ] && touch /var/lock/subsys/eximreturn $RETVAL}stop() {echo -n $"Shutting down $prog: "killproc $eximRETVAL=$?echo[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/eximreturn $RETVAL}# See how we were called.case "$1" instart)start;;stop)stop;;status)status $eximRETVAL=$?;;restart)stopstartRETVAL=$?;;condrestart)if [ -f /var/lock/subsys/exim ]; thenstopstartRETVAL=$?fi;;*)echo $"Usage: $0 {start|stop|status|restart|condrestart}"exit 1391392Часть 7.
Программное обеспечение для организации службы электронной почтыesacexit $RETVALШаг 2Сделайте файл исполняемым и определите его владельцем суперпользователя root:[root@test /]# chmod 700 /etc/init.d/exim[root@test /]# chown 0.0 /etc/init.d/eximШаг 3Для автоматического запуска Exim при загрузке системы создайте необходимые символьные ссылки:[root@test /]# chkconfig --add exim[root@test /]# chkconfig --level 2345 exim onШаг 4Проверьте наличие и при необходимости добавьте соответствующие записи в файлы зоны и обратнойзоны вашего DNS-сервера.Тестирование EximШаг 1Запустите Exim:[root@test /]# /etc/init.d/exim startЗапускается Exim:[ОК]Шаг 2Проверьте правильность синтаксиса конфигурационных файлов:[root@test /]# /usr/sbin/exim -bVЕсли вы получите сообщение, не содержащее ошибок, аналогичное приведенному ниже:Exim version 4.20 #1 built 06-Jun-2003 13:46:13Copyright (c) University of Cambridge 2003Berkeley DB: Sleepycat Software: Berkeley DB 3.3.11: (July 12, 2001)Authenticators: cram_md5 plaintextRouters: accept dnslookup ipliteral manualroute queryprogram redirectConfiguration file is /etc/mail/exim.confто, скорее всего, конфигурационные файлы не содержат синтаксических ошибок.Шаг 3Проверьте, возможна ли доставка сообщений локальным пользователям:[root@test /]# /usr/sbin/exim -bt postmasterreal_person@test.bruy.info<-- postmaster@test.bruy.inforouter = localuser, transport = local_deliveryШаг 4Проверьте, возможна ли доставка сообщений пользователям на удаленных системах в Интернет:[root@test /]# /usr/sbin/exim -bt karloff@mtu.rukarloff@mtu.rurouter = dnslookup, transport = remote_smtphost mx.mtu.ru[195.34.32.57] MX=3host hueymiccailhuitl.mtu.ru [195.34.32.122] MX=5host mtu.ru[195.34.32.10] MX=20Шаг 5Проверьте доставку сообщений локальным пользователям.
Для этого отправьте письмо локальномупользователю, например, postmaster:[root@test /]# /usr/sbin/exim -v postmasterTo: postmaster@test.bruy.info <Enter>From: root@test.bruy.info <Enter>Subject: Проверка <Enter>Проверка доставки локальной почты с помощью Exim <Enter><Ctrl>+<D>Глава 27. Exim – почтовый транспортный агент393LOG: MAIN<= root@test.bruy.info U=root P=local S=350Проверьте наличие сообщения в очереди на доставку:[root@test /]# /usr/bin/mailq0m 376 19OEfY-0002FA-7s <>real_person@test.bruy.infoПосмотрите тело сообщения:[root@test /]# /usr/sbin/exim -Mvb 19OEfY-0002FA-7s19OEfY-0002FA-7s-DПроверка доставки локальной почты с помощью EximПосле исчезновения сообщения из очереди, т.