词条 | Qmail |
释义 | qmail是一个因特网邮件传送代理(简写为MTA),它运行在linux/Unix兼容系统下,是一个直接代替UNIX下Sendmail软件的邮件传送程序。qmail使用SMTP协议与其它系统上的MTA交换邮件。 介绍作为Linux下面主流的邮件系统内核,大量著名的商业邮件系统都是在Qmail内核下开发,比如Hotmail等。Qmail具有安装方便、安全性高、邮件结构合理、支持SMTP服务、队列管理、邮件反弹、基于域名的邮件路由、SMTP传输、转发和邮件列表、本地(邮件)传送、POP3 服务等强大的功能。它已经逐渐替代传统的Sendmail成为linux下邮件系统内核的主流选择。qmail是面向安全而设计的,作者曾经悬赏500美元来找出qmail的安全漏洞,但是直到2006年,还是没有人能领取这笔奖金。 qmail的主要竞争对手是Exim以及Postfix。与它的竞争对手不同的是,Qmail已经许多年没有更新了,用户已经习惯于通过第三方的插件及补丁来使qmail增加新的功能。 qmail 的源代码现已开放为公有领域。 总体架构Before delving too deeply into further configuration and tailoring of qmail, it is important to understand the basic structure of qmail. Qmail is often referred to as merely a mail server software package. While this may be accurate in one sense, it is more accurate to think of qmail as a mail delivery architecture whose architect has thoughtfully provided a basic implementation of all the components of that architecture. 在深入探索qmail的配置和调节之前,了解一些qmail的基础架构是重要的。Qmail经常被仅仅归类为一个邮件服务器软件包。这可能只在某一点上是正确的,将qmail考虑为一个邮件分发体系会更加准确,这个体系结构的构建者为这个体系的所有组件深入的提供了一些基础接口。 Qmail is very modular—it consists of a series of simple programs communicating via specific and limited interfaces. Each simple program has a specific and limited task to perform. This architecture allows each component program to be easily replaced or new programs to be inserted between the basic components. Qmail是非常模块化的——它包含了一系列通过特定且受限的接口来互相沟通的简单程序。每个简单的程序都有一个特定且受限的任务需要完成。这个体系结构允许每个组件都被容易的替代或让新的程序插入到基础组件之中。 Additionally, this architecture limits the security impact of any one of the components. Each program is further separated from the others, whenever possible, by giving each program a different UNIX user and specific permissions so that it can"t affect anything it is not supposed to. Because the communication interfaces are limited, it is significantly more difficult to attack the software and achieve much—attacking a component that does not have enough privileges to do anything other than what it is supposed to do is much less useful for an attacker. 另外,这个体系限制了所有组件的安全影响。任何一个程序都与另外的程序隔离开来,在任何可能的情况,给每个程序一个不同的UNIX用户和特定权限来确保它不会做任何它不应该做的事。因为通讯接口被限制了,因此显然更难去攻击软件或更多别的——攻击一个没有足够权限来做任何它不应该做的事的组件对攻击者来说是很没有用处的。 The simplest example is receiving email from the network. The trail of programs in basic qmail is as follows: tcpserver to qmail-smtpd to qmail-queue. The tcpserver program has two tasks: open up a port to listen to the network, and run qmail-smtpd as the appropriate user for every connection. Because listening to low ports (such as the SMTP port, 25) requires root permissions, tcpserver generally runs as root. However, because tcpserver doesn"t attempt to understand the communication, it is very difficult to attack. The qmail-smtpd program has only two tasks as well: speaking the SMTP protocol sufficiently to receive email messages, and sending these email messages to qmail-queue. As such, qmail-smtpd need not do anything with the on-disk queue or the network. This allows qmail-smtpd to be run as a user with very limited permissions, and also allows qmail-smtpd to be a much simpler, and easier to verify and debug, program than it would be otherwise, even though it has to interact directly with user (or attacker) input. The qmail-queue program has only one task—to write messages to the on-disk queue prepended with a Received header. It need not talk to the network, or understand the contents of the messages it writes to disk, making the program simple and easy to verify and thus hard for an attacker to break. 最简单的例子是从网络上收邮件。一个基础的qmail实验如下:tcpserver到qmail-smtpd到qmail-queue。tcpserver程序有两个任务:打开一个端口来监听网络,并对每个连接以正确的用户来启动qmail-smtpd。因为监听低端口(如SMTP的端口:25)要求root权限,所以tcpserver通常以root用户运行。然而,因为tcpserver并不试图理解通讯,所以很难被攻击。qmail-smtpd程序也只有两个任务需要运行:充分使用SMTP协议来接收消息,并发送这些邮件消息到qmail-queue。就这个而言,qmail-smtpd本身并不需要对磁盘上的队列或网络做任何事情。这允许qmail-smtpd能被一个权限非常受限的用户来运行,而且允许qmail-smtpd成为一个非常简单,而且容易被验证和排错的程序,即使它需要与用户(或攻击者)输入直接沟通。qmail-queue程序则只有一个任务——将消息写到已经有了接收头的磁盘队列上。它无需和网络沟通,或者了解它写到磁盘上的消息的内容,使得程序简单并容易被验证,从而使得攻击者更难破坏它。Note that this architecture can be easily extended. The tcpserver program can execute any program, which can in turn execute qmail-smtpd as necessary. This might be useful, for example, to make decisions about whether to permit a connection to reach qmail-smtpd or to set and unset environment variables before qmail-smtpd is executed. It could even be used to sanitize data before it gets to qmail-smtpd. Similarly, while qmail-smtpd normally executes qmail-queue, it may invoke any program. This program can then execute qmail-queue as necessary, which might be useful, for example, to filter out email messages that contain viruses. 要注意的是这个体系结构很容易被扩展。tcpserver程序可以执行轮流执行所需的qmail-smtpd的任何程序。这可能很有帮助,例如,决定在qmail-smtpd被运行前是否允许一个连接到达qmail-smtpd或设置或取消一个环境变量。它甚至可以用来对数据在到达qmail-smtpd前进行安全过滤。类似的,当qmail-smtpd正常的运行qmail-queue时,它可以调用任何程序。这个程序可以执行所需的qmail-queue,这可能会有用,来过滤哪些包含病毒的邮件消息。 As another example, the qmail-start program executes several programs: qmail-send, qmail-lspawn, qmail-rspawn, and qmail-clean. Each of these programs has a specific task. qmail-send must monitor the on-disk queue of mail and route mail appropriately by commanding either qmail-lspawn or qmail-rspawn to deliver the message depending on whether the message should be delivered to a local user or a remote user, respectively. Once messages have been delivered, it commands qmail-clean to remove the message from the queue. Both qmail-lspawn and qmail-rspawn receive delivery commands and spawn the necessary number of instances of qmail-local and qmail-remote to do the actual delivery. The qmail-remote program is a simple program that reads an email from standard input, and delivers it to the hosts and recipients specifi ed to it by arguments. It does not have sufficient permissions to read out of the queue itself, and so must be handed the message to deliver. It can even be used alone as follows: echo message | qmail-remote smtp.example.xcom senderexample.xcom recipient example.xxx 又如另一个例子,qmail-start程序执行一些程序:qmail-send,qmail-lspawn,qmail-rspawn和qmail-clean。以上每个程序都有一个特定的任务。qmail-send必须监控磁盘上的邮件队列,并且分别根据是要将邮件投递给本地用户还是远程用户来执行qmail-lspawn或qmail-rspaw来正确的按路由发送。一旦邮件被发送,它就会运行qmail-clean来清除队列中的消息。qmail-lspawn和qmail-rspawn都会收到发送命令并产生运行qmail-local和qmail-remote的实例所需的数字,这些程序实例会真正开始发送邮件。qmail-remote程序是一个简单的程序,它从标准输入读取邮件,然后将它发送给由它的参数指定的主机和收件人。它没有足够的权限来读取队列本身之外的任何东西,因此必须亲手发送邮件。它甚至可以像下面这样单独使用: The qmail-local program is also simple; its task is to read an email from standard input and deliver it to the specified local user, using the procedures detailed in that user"s .qmail files. Like qmail-remote, it does not have sufficient permissions to read or modify the on-disk queue. qmail-local程序也很简单,它的任务是读取来自标准输入的邮件并将之发送给指定的本地用户,依据这个用户的.qmail文件所描述的具体步骤。和qmail-remote一样,它也没有足够的权限去读取或修改 Each of these programs is independent of the others, and relies only on the interface provided to it. By restricting the permissions that each component has, both attacking the system as well as achieving much with a single compromised component is made significantly more difficult. This is the fundamental concept behind the privilege-separation security technique employed by qmail. 这些程序都相互独立,并且只依赖于提供给它的接口。通过限制每个组件的权限,使得攻击系统或通过攻击一个组件来获取更多都变得极其困难。这就是被qmail使用的在其基础概念之后的权限分离安全技术。 【免责声明】本文仅代表作者本人观点,与和讯网无关。和讯网站对文中陈述、观点判断保持中立,不对所包含内容的准确性、可靠性或完整性提供任何明示或暗示的保证。请读者仅作参考,并请自行承担全部责任。 简单配置及使用目录qmail 安装部署 1 一、 准备工作 1 二、 LAMP残留(执行即可) 1 三、上传所需安装包 2 四、 检查DNS配置 2 五、 设置或关闭防火墙 2 六、 卸载已有的邮件系统 3 七、 解压缩netqmail-1.05.tar.gz 3 八、 安装daemontools 3 九、 安装ucspi-tcp 3 十、 创建所需的用户 4 十一、 准备安装qmail 4 十二、 qmail编译安装 5 十三、 设置管理员的邮箱地址 5 十四、 开启SPF设置 5 十五、 添加qmail的帮助手册 5 十六、 为qmail服务建立监控目录和日志文件 5 十七、 检查服务 6 十八、 安装vpopmail 7 十九、 检查服务 9 二十、 用POP3和SMTP测试 10 二十一、安装qmailadmin 14 过程过程一:Qmail的安装。 1. 获得Qmail程序。 Qmail是自由软件,在Internet上可以获得它的源代码(C源代码)及基于各种平台和操作系统的二进制文件。二进制文件可以不须编译直接使用,但要注意选择与您的平台和操作系统版本一致的文件,否则可能不能使用。源代码可以在您的任何环境下工作(UNIX)但需要自己进行编译安装。这里我们选择源代码。从Internet上下载的源代码通常是以tar程序打的包然后再用压缩软件进行压缩。如:qmail-1.03.tar.gz 这里使用的是gzip进行压缩的(假设你的机器上已安装了gzip)。使用 gzip -d qmail-1.03.tar.gz 解压缩成qmail-1.03.tar 然后再用tar -xvf qmail-1.03.tar 解包成qmail-1.03目录。那么源代码文件均在此目录中了。 2. 编译安装Qmail。 Qmail源代码文件中有几个配置文件可以修改以适合您的环境。 conf-qmail :此文件包含Qmail的安装目录,默认值是 /var/qmail/ conf-users:此文件包含Qmail需要使用的用户,默认用户是 root,alias,(这两个用户在unix下应该已经由系统建立好了,下面的用户应该自己创)qmails,qmaid,qmaill, qmailr,qmailq,qma-ilp。 conf-groups:此文件包含Qmail 需要使用的组,默认的组为qmail(qmails,qmaild,qmaill,qmailr,qmailq,qmailp要属于此组)。 conf-cc:此文件包含Qmail使用的编译器,默认使用cc编译器,如须使用其它C编译器,应该将其替换为此编译器如 gcc. conf-ld:此文件包含Qmail使用的编译器,默认使用cc编译器,如须使用其它C编译器,应该将其替换为此编译器如 gcc 在进行安装前系统应该已经安装了make命令。 定制好这些文件后,在/var/qmail/下使用命令:make。make命令将编译源代码、连接.obj 文件。如果此过程中断或出错,应参考上面配置文件正确与否。用户和组建立的正确与否。如果此过程没有问题使用命令:make check setup。此命令将安装所有文件到/var/qmail/(在执行此命令前先用 makedir /var/qmail 创建该目录)下。 另外需要安装checkpasswd,它的获得和安装和Qmail一样。此程序用于用户使用POP3协议收取邮件时对用户的密码验证。 过程二:Qmail的初级配置 Qmail安装好了以后将在/var/qmail/下生成若干文件和目录。 1.用vi 编辑器打开文件 /etc/inetd.conf,并在文件尾添加如下行: smtp stream tcp nowait qmaild /var/qmail/bin/tcp-env tcp-env /var/qmail/bin/qmail-smtpd (和上面一行同在一行) pop3 stream tcp nowait root /var/qmail/bin/qmail-popup qmail-popup yourname /bin/checkpassword /var/qmail/bin/qmail-pop3d Maildir(和上面两行同在一行) 其中yourname是您的完整的Internet主机名,Maildir 是采用的邮箱格式(这里我们使用较流行的Maildir格式) 2.检查/etc/services文件中是否有如下两行,如没有则添加进去: smtp 25/tcp mail pop3 110/tcp # Post Office 3. DNS中有关Qmail的设置. 如果Qmail的邮件是与Internet上的其它邮件服务器交互的话(否则只能此服务器的邮件用户相互收发邮件了),还需要在DNS服务器中设置有关 Qmail的条目(如果使用别人的DNS服务器,应向DNS管理员申请添加条目)即添加一条关于邮件交换的条目(具体的设置请向DNS管理员咨询) 4. 控制文件的创建 Qmail的控制文件放在/var/qmail/control/下,如果不与Internet上的邮件服务器互传邮件的话,需要配置很多的文件。否则最简单的只需配置一个文件:me 它的内容是此邮件服务器的完整Internet主机名即:yourname 过程三:邮件用户的创建 邮件用户就是系统用户,所以您应该向系统添加用户,为了安全和管理的需要,最好创建一个E-mail用户组,将E-mail用户归属于此组,创建用户目录时最好在同一个文件系统下创建在同一个目录下(当然此文件系统不够大时可以创建在其它文件系统的某个目录下) 然后,在每个用户的初始目录下用命令:/var/qmail/bin/maildirmake创建邮箱目录并赋予适当的权限,您可以使用Shell脚本来完成每个用户邮箱的创建,下面是此脚本的一个简单的例子: if test $1 then echo "Creating $1's directory and file..." useradd -d /usr/email-users/$1 -g emusers -s /bin/passwd $1 cd /usr/email-users/ mkdir $1 chown $1 $1 cd $1 /var/qmail/bin/maildirmake Maildir echo ./Maildir/ > .qmail chown $1 Maildir chown $1 Maildir/* chown $1 .qmail echo "Please input $1's email password" passwd $1 echo "$1's account has been created!!!" else echo "Please input the user'name!" fi 系统管理员可以使用emuadd email_user_name (此脚本的文件名,并将此文件存放在/bin下)来传建email_user_name的邮箱 过程四:Qmail系统的使用 当上述过程结束后重新启动计算机。 在邮件客户端程序中设置如下:(假如E-mail服务器的主机名为your,name,DNS中设置的邮件交换管理的域为mail.domain,注意:通常mail.domain与.name相同,以E-mail用户user为例) 电子邮件地址:user@mail.domain SMTP服务器地址:yourname POP3服务器地址:yourname POP3账号:user POP3账号密码:(由管理员给你,可以自己修改) 启动设置Qmail 运行有两种方式。tcpserver,xinet。 当域名解析有问题的时候,tcpserver运行会有问题。 qmail1.0.8,ucspi-tcp-0.88 (1) tcpserver方式 # pop3 设置 /usr/local/bin/tcpserver -P -H -R 0 pop-3 /var/qmail/bin/qmail-popup /home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2>&1 | /var/qmail/bin/splogger & # smtpd 设置 /usr/local/bin/tcpserver -H -R -t 1 -v -P -x/etc/qmail/tcp.smtp.cdb -u 511 -g 506 smtp /var/qmail/bin/qmail-smtpd /home/vpopmail/bin/vchkpw /bin/true | /var/qmail/bin/splogger & (2) xinetd方式 /etc/xinetd.d/pop3-3 service pop-3 { disable = no socket_type = stream wait = no user = root server = /var/qmail/bin/qmail-popup nice = 10 server_args = home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir & } /etc/xinetd.d/smtp service smtp { disable = no socket_type = stream wait = no user = vpopmail server = /var/qmail/bin/qmail-smtpd nice = 10 server_args = /home/vpopmail/bin/vchkpw /bin/true } |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。