From: someone@zmail.ru
Date: Mon, 2 Jul 2003 13:01:37 +0000 (UTC)
Subject: Почтовый сервер на базе Exim с использованием DbMail для аккаунтов пользователей.
su-2.05a# ./build.sh
This is the dbmail build script
I will have to ask you some questions about your system
What database do you wish to use? Choices are (m)ysql and (p)ostgresql >
m
You have selected MySQL as database
The library directory for MySQL is now [/usr/local/lib/mysql/].
Enter new directory or press RETURN to keep this setting:
The include directory for MySQL is now [/usr/include/mysql/].
Enter new directory or press RETURN to keep this setting:
/usr/local/include/mysql
The libraries are currently set to [-lmysqlclient -lcrypto].
Enter new libraries (preceed each by -l) or press RETURN to keep this setting:
Creating makefile..
Done. You can now make dbmail by running 'make clean all'.
Do you want this to be executed right now?
y
Make succesfull. Do you want to install the binaries and man pages?
y
Target binary directory is now /usr/local/sbin.
Enter new directory or press RETURN to keep this setting:
This script will install dbmail on your system.
Before executing this script be sure to have read the INSTALL file.
Although dbmail is very easy to install you'll need to know a few little
things before you can start using it.
If you have any problems, man files will also be installed so you can
always check the manpage of a program.
Next i'll be asking you as what user and group you want to be running DBMAIL.
Best thing is to create a user called dbmail with a dbmail group.
Don't forget to edit these users in the dbmail.conf file and run dbmail-config
afterwards. The pop3 daemon and the imapd daemon have capabilities to
drop their privileges! Use that capability!
As what user are the dbmail daemons going to run? [default: dbmail]
As what group are the dbmail daemons going to run? [default: dbmail] mail
Ok installing dbmail executables as dbmail:mail..
Ok installing manfiles in /usr/local/man/man1/..
Done
su-2.05a# strip /usr/local/sbin/dbmail*
После чего создаем базу данных, пользователя и соответсвующие таблицы,
для этого выполним:
su-2.05a# mysql -u root -p < sql/mysql/create_tables.mysql
su-2.05a# mysql -u root mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 2 to server version: 3.23.49-log
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> GRANT ALL PRIVILEGES ON dbmail.* TO dbmail@localhost
-> IDENTIFIED BY 'my_password' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
Для правильной работы Exim, требуется добавить в созданную
ранее базу данных dbmail, таблицу с именем domains, для этого выполним:
su-2.05a# mysql -u dbmail -p dbmail
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 3 to server version: 3.23.49-log
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> CREATE TABLE domains (
-> did int(10) unsigned NOT NULL auto_increment,
-> domainname varchar(128) NOT NULL default '',
-> type enum('LOCAL','RELAY','VIRTUAL') NOT NULL default 'LOCAL',
-> PRIMARY KEY (did)
-> );
Query OK, 0 rows affected (0.08 sec)
smtp_banner = "Welcome on our mail server!n
This system does not accept Unsolicited
Commercial Emailnand will blacklist
offenders via our spam processor.nHave a
nice day!nn${primary_hostname} ESMTP"
######################################################################
# ACL CONFIGURATION #
# Specifies access control lists for incoming SMTP mail #
######################################################################
######################################################################
# ROUTERS CONFIGURATION #
# Specifies how addresses are handled #
######################################################################
# THE ORDER IN WHICH THE ROUTERS ARE DEFINED IS IMPORTANT! #
# An address is passed to each router in turn until it is accepted. #
######################################################################
dbmailuser:
driver = accept
condition = ${lookup mysql{SELECT alias_idnr FROM aliases WHERE
alias='${quote_mysql:$local_part@$domain}' OR
alias='${quote_mysql:@$domain}'}{yes}{no}}
transport = dbmail_delivery
######################################################################
# TRANSPORTS CONFIGURATION #
######################################################################
# ORDER DOES NOT MATTER #
# Only one appropriate transport is called for each delivery. #
######################################################################
begin transports
remote_smtp:
driver = smtp
dbmail_delivery:
driver = pipe
check_string =
command = /usr/local/sbin/dbmail-smtp -d ${pipe_addresses}
current_directory = "/var/spool/dbmail"
escape_string =
group = mail
message_prefix =
message_suffix =
path = "/bin:/sbin:/usr/local/bin:/usr/local/sbin"
user = dbmail
# There are no authenticator specifications in this default configuration file.
begin authenticators
# AUTH PLAIN authentication method with MySQL used by Netscape Messenger.
auth_plain:
driver = plaintext
public_name = PLAIN
server_condition = ${lookup mysql{SELECT user_idnr FROM users
WHERE userid = '${quote_mysql:$2}' AND passwd = '${quote_mysql:$3}'}}
server_set_id = $2
# AUTH LOGIN authentication method with MySQL support used by Outlook Express.
auth_login:
driver = plaintext
public_name = LOGIN
server_condition = ${lookup mysql{SELECT user_idnr FROM users
WHERE userid = '${quote_mysql:$1}' AND passwd = '${quote_mysql:$2}'}}
server_prompts = "Username:: : Password::"
server_set_id = $1
# AUTH CRAM-MD5 authentication method with MySQL used by The Bat!.
auth_cram_md5:
driver = cram_md5
public_name = CRAM-MD5
server_secret = ${lookup mysql{SELECT passwd FROM users
WHERE userid = '${quote_mysql:$1}'}{$value}fail}
server_set_id = $1
######################################################################
# CONFIGURATION FOR local_scan() #
######################################################################
# If you have built Exim to include a local_scan() function that contains
# tables for private options, you can define those options here. Remember to
# uncomment the "begin" line. It is commented by default because it provokes
# an error with Exim binaries that are not built with LOCAL_SCAN_HAS_OPTIONS
# set in the Local/Makefile.
su-2.05a# telnet localhost 25
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220-Welcome on our mail server!
220-This system does not accept Unsolicited Commercial Email
220-and will blacklist offenders via our spam processor.
220-Have a nice day!
220-
220 mydomain.org ESMTP
ehlo test.ru
250-mydomain.org Hello localhost [127.0.0.1]
250-SIZE 5242880
250-PIPELINING
250 HELP
mail from:someone at zmail.ru
250 OK
rcpt to:sysadmin@mydomain.org
250 Accepted
data
354 Enter message, ending with "." on a line by itself
Hello!
.
250 OK id=19NuQl-000NZA-47
quit
221 mydomain.org closing connection
Connection closed by foreign host.
su-2.05a# tail /var/log/maillog
Jun 5 13:05:28 free_access exim[90602]: 2003-06-05 13:05:28 19NuQl-000NZA-47 <= someone at zmail.ru H=localhost (test.ru) [127.0.0.1] P=esmtp S=317 from <someone at zmail.ru> for sysadmin@mydomain.org
Jun 5 13:05:30 free_access exim[90603]: 2003-06-05 13:05:30 19NuQl-000NZA-47 => sysadmin <sysadmin@mydomain.org> R=dbmailuser T=dbmail_delivery
Jun 5 13:05:30 free_access exim[90603]: 2003-06-05 13:05:30 19NuQl-000NZA-47 Completed
На первый взгляд все работает, идем дальше, теперь проверим dbmail-pop3d.
su-2.05a# telnet localhost 110
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK DBMAIL pop3 server ready to rock <15662.1057056129@mydomain.org>
user sysadmin@mydomain.org
+OK Password required for sysadmin@mydomain.org
pass mypassword
+OK sysadmin@mydomain.org has 1 message (667 octets)
list
+OK 1 message (667 octets)
1 667
.
quit
+OK see ya later
Connection closed by foreign host.
Теперь обеспечим работу антивируса DrWeb в связке с Exim.
su-2.05a# tar xzpf drweb-4.29.2-freebsd4.tar.gz
su-2.05a# cd drweb-4.29.2-freebsd4
su-2.05a# ./install.sh
Enter destination directory (/opt/drweb is default):
Select interface language: 0) english 1) russian
0
Dr.Web is installed to /opt/drweb.
Edit /drweb32.ini to complete setup.
После этого, отредактируем конфигурационный /etc/drweb/drweb32.ini файл, изменив:
;User = drweb
на:
User = drweb
После этого отредактируем конфигурационный файл exim'а.
### начало /etc/mail/exim.conf ###
######################################################################
# MAIN CONFIGURATION SETTINGS #
######################################################################
....
trusted_users = mail:drweb
....
######################################################################
# ROUTERS CONFIGURATION #
# Specifies how addresses are handled #
######################################################################
# THE ORDER IN WHICH THE ROUTERS ARE DEFINED IS IMPORTANT! #
# An address is passed to each router in turn until it is accepted. #
######################################################################
begin routers
# Enable Anti-Virus support with DrWeb.
drweb_router:
driver = accept
condition = "${if eq {$received_protocol}{drweb-scanned}{0}{1}}"
transport = drweb
no_verify
....
######################################################################
# TRANSPORTS CONFIGURATION #
######################################################################
# ORDER DOES NOT MATTER #
# Only one appropriate transport is called for each delivery. #
######################################################################
begin transports
....
address_reply:
driver = autoreply
# Enable Anti-Virus support with DrWeb.
drweb:
driver = pipe
check_string =
command = /opt/drweb/drweb-exim -f <${sender_address}> -- ${pipe_addresses}
current_directory = "/var/drweb/spool"
escape_string =
group = mail
headers_add = "X-Virus-Scanned: by DrWeb For Unix"
message_prefix =
message_suffix =
path = "/bin:/sbin:/usr/bin:/usr/sbin:/opt/drweb"
no_return_output
no_return_path_add
user = drweb
### конец /etc/mail/exim.conf ###
Автоматизируем процесс обновления вирусных баз DrWeb.
su-2.05a# tar xzpf String-CRC32-1.2.tar.gz
su-2.05a# cd String-CRC32-1.2
su-2.05a# perl Makeperl.PL
su-2.05a# make
su-2.05a# make test
su-2.05a# make install
su-2.05a# crontab -e
Указываем запуск скрипта обновления каждый день в 4-ре часа утра.
0 4 * * * /opt/drweb/update/update.pl
Несколько слов хочу сказать про установку SpamAssassin, собственно
сам процесс установки детально описан вот здесь:
http://www.opennet.ru/base/net/qmail_antispam.txt.html
Для обеспечения работы SpamAssassin+Exim, нужно выполнить следующее:
### начало /etc/mail/exim.conf ###
######################################################################
# ROUTERS CONFIGURATION #
# Specifies how addresses are handled #
######################################################################
# THE ORDER IN WHICH THE ROUTERS ARE DEFINED IS IMPORTANT! #
# An address is passed to each router in turn until it is accepted. #
######################################################################
begin routers
# Enable Anti-Virus support with DrWeb.
drweb_router:
driver = accept
condition = "${if or{ {eq {$received_protocol}{drweb-scanned}}
{eq {$received_protocol}{spam-scanned}} } {0}{1}}"
transport = drweb
no_verify
# Enable Anti-Spam support with SpamAssassin.
spamcheck_router:
no_verify
condition = "${if and { {!def:h_X-Spam-Flag:}
{!eq {$received_protocol}{spam-scanned}}} {1}{0}}"
driver = accept
transport = spamcheck
....
######################################################################
# TRANSPORTS CONFIGURATION #
######################################################################
# ORDER DOES NOT MATTER #
# Only one appropriate transport is called for each delivery. #
######################################################################
begin transports
....
address_reply:
driver = autoreply
# Enable Anti-Spam support with SpamAssassin.
spamcheck:
driver = pipe
batch_max = 100
command = /usr/sbin/exim -oMr spam-scanned -bS
use_bsmtp = true
transport_filter = /usr/bin/spamc
home_directory = "/tmp"
current_directory = "/tmp"
user = mail
group = mail
log_output = true
return_fail_output = true
return_path_add = false
message_prefix =
message_suffix =
# Enable Anti-Virus support with DrWeb.
drweb:
driver = pipe
check_string =
command = /opt/drweb/drweb-exim -f <${sender_address}> -- ${pipe_addresses}
current_directory = "/var/drweb/spool"
escape_string =
group = mail
headers_add = "X-Virus-Scanned: by DrWeb For Unix"
message_prefix =
message_suffix =
path = "/bin:/sbin:/usr/bin:/usr/sbin:/opt/drweb"
no_return_output
no_return_path_add
user = drweb
### конец /etc/mail/exim.conf ###
960 Прочтений • [Почтовый сервер на базе Exim с использованием DbMail для аккаунтов пользователей. (freebsd mail database virtual virus)] [08.05.2012] [Комментариев: 0]