首 页 网络编程
网页制作 图形图象 操作系统 冲浪宝典
软件教学 认证考试

网络安全 网络办公 行业资讯 评测对比
您当前位置:站长天空 -> 认证考试-> ORACLE认证
vpopmail+spamassassin+clamscan_qmail
作者:网友供稿 点击:0
推荐
西部数码-全国虚拟主机10强!20余项虚拟主机管理功能,全国领先!第6代双线路虚拟主机,南北访问畅通无阻!可在线rar解压,自动数据恢复设置虚拟目录等.免费赠送访问统计,企业邮局.Cn域名注册10元/年,自助建站480元起,免费试用7天,满意再付款!P4主机租用799元/月.月付免压金
站内搜索
文章页数:[1] 
There was some discussion a while back about making SA work with vpopmail.

Most solutions I saw used .qmail-username or .qmail-default which wasnt the
right method for us. Below is a quick write up on how to use SA+clamscan
from a .qmail file in the users maildir. We also pull user preferences for
SA from SQL, so the line we use to call SA might not be what you want.
Delivery and hand off for scanning is handled by maildrop.

First and foremost, make certain that the user vpopmail has a valid shell...
this is very important as vdeliermail will run anything in the .qmail as the
user vpopmail, provided the application doesnt do a setuid/setgid, which
maildrop does not do. (That alone cost me 3 hours to troubleshoot.)

For each user you want to enable SA and virus scanning put the following in
a .qmail file in the users directory:

| /var/qmail/bin/preline /usr/local/bin/maildrop
/usr/home/vpopmail/domains/.mailfilter

Make sure that this file has been chmoded to 600 (u+rw) and is owned by
vpopmail:vchkpw otherwise it will not be run.

The .mailfilter listed above contains (some of this script has come from
another list member, but I forgot his name, if you contact me I will give
credit where credit is due), it must also be chmoded to 600 with owner
vpopmail:vchkpw :

import EXT
import HOST
VHOME=`/usr/home/vpopmail/bin/vuserinfo -d [EMAIL PROTECTED]

# Check for Spam if it is smaller than 250KB
if($SIZE < 262144)
{
xfilter "/usr/local/bin/spamc -d 192.168.1.2 -t 20 -f -u [EMAIL PROTECTED]"
}
if ((/^X-Spam-Flag:.*YES/))
{
`/bin/test -d $VHOME/Maildir/.Spam`
if( $RETURNCODE == 1 )
{
`/var/qmail/bin/maildirmake $VHOME/Maildir/.Spam;
/usr/sbin/chown -R vpopmail:vchkpw $VHOME/Maildir/.Spam`
}
to "$VHOME/Maildir/.Spam/"
}

# If it isnt Spam, then we scan for Virus if it is smaller than 2MB in
size... anything larger... they are on their own
if($SIZE < 2000000)
{
xfilter "/usr/home/vpopmail/domains/clamscan.sh"
}
if ((/^X-Virus-Status:.*INFECTED/))
{
`/bin/test -d $VHOME/Maildir/.Virus`
if ( $RETUNRCODE == 1 )
{
`/var/qmail/bin/maildirmake $VHOME/Maildir/.Virus;
/usr/sbin/chown -R vpopmail:vchkpw $VHOME/Maildir/.Virus`
}
to "$VHOME/Maildir/.Virus/"
}

#If it isnt Spam or Virus, then deliver normally
to "$VHOME/Maildir/"

The specific lines of interest are the xfilter lines. We use spamc/spamd to
offload the very CPU intensive process of spam scanning to another machine
on the private network. That is what the -d directive is for which tells SA
which IP to connect to for spamd...

The clamscan.sh file is a wrapper for the clamscan binary. We need to do
this because of the incompatibility between how clamscan operates and how
maildrop expects an xfilter program to operate. maildrop expects any message
it sends out to an xfilter program to be returned to it via stdout. The
problem is that the clamscan binary only returns the results of the scan,
not the message, so we have to create a shell script to pass the altered
message back to maildrop via stdout, also we use the shell script to alter
the exit code of clamscan (0 if clean and 1 if infected) to be compatible
with what maildrop expects. maildrop expects the application to return a
exit code of 0, so we have to alter it.

You will need bash in order to use this.

#!/usr/local/bin/bash
# Created by Tom Walsh
# slim at ala.net

MSG=$(/bin/cat /dev/stdin) # Is there a better way to do this?
SCAN=$(echo "$MSG" | /usr/local/bin/clamscan - --stdout --disable-summary)
EXIT="$?"
VIRUS=$(echo "$SCAN" | awk {print $2})
SUBJECT=$(echo "$MSG" | /usr/local/bin/reformail -x Subject:)

if [ "$EXIT" == "1" ]; then
SUBJECT="**VIRUS** [$VIRUS] $SUBJECT"
MSG=$(echo "$MSG" | /usr/local/bin/reformail -a"X-Virus-Status:
INFECTED" -i"Subject: $(echo "$SUBJECT")")
else
MSG=$(echo "$MSG" | /usr/local/bin/reformail -a"X-Virus-Status: CLEAN")
fi

echo "$MSG"

exit 0

And just for completeness... I have included our spamd config line to let
you know how to pull settings from SQL:

/usr/local/bin/spamd -a -d -q -x -m 50 -u spamd -i 192.168.1.2 -A
192.168.1.100 -A 192.168.1.101

The -i directive tells spamd to listen on IP 192.168.1.2, by default it only
listens on 127.0.0.1
The -A directives tell spamd which IPs to accept connections from.

You also need to odify your local.cf file to include the settings for
connecting to the SQL server.... All of that is covered in the README for
SQL: http://www.spamassassin.org/dist/sql/README

I hope that helps somebody... We are going to be ramping up the load on the
SA box shortly to see how well it scales... We are considering doing load
balancing via two SA boxes and a psuedo-random IP selector script that will
feed a variable $IP to the .mailfilter script above... something like:

IP=`/path/to/ipscript.sh`

xfilter "/usr/local/bin/spamc -d $IP -t 20 -f -u [EMAIL PROTECTED]"

If anybody has any comments or suggestions I would be willing to hear
them... I am currently writing up a howto to post to the web soon, but it is
rather FBSD specific I am afraid...

As a side note with regard to spamd reading the settings from SQL... spamd
makes a lookup on the [EMAIL PROTECTED], but also makes a lookup on GLOBAL
and @GLOBAL, so you can have a global preference for anybody that doesnt
have an entry in the SQL table... A very nice feature.

HTH,

Tom Walsh
Network Administrator
http://www.ala.net/

文章整理:站长天空 网址:http://www.z6688.com/
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

文章页数:[1] 


放大字体显示 缩小字体显示 打印文章 推荐给朋友
热门文章
·一个特牛的日期时间判断正则表达式-ASP教程,正则表达式
·Remoting编程知识一-.NET教程,.NET Framework
·从客户端检测到有潜在危险的Request.Form 值-ASP教程,客户端相关
·关于DataRow和DataColumn的一点个人简单理解-.NET教程,数据库应用
·DataTable.Select使用小心得-.NET教程,数据库应用
·在Java中如何模拟多继承-JSP教程,Java技巧及代码
·上海移动数据网综合网管的实现
·在VC中用GDI+绘制角度可变的颜色渐变效果-.NET教程,VB.Net语言
·超漂亮的绿色按扭制做-网页设计,Photoshop
·Java获取Html变量的值-JSP教程,Java技巧及代码
最新文章
·阿里联盟:关于结算时间问题的统一说明_网赚技巧
·谷歌官方组织adsense优化大赛_网赚技巧
·google adsense 2007巡讲大会上海站总结_网赚技巧
·网络只是一个开始:专访91now站长小鱼头_站长访谈
·asp.net应用程序资源访问安全模型_asp.net技巧
·给那些迷惑于做垃圾站的站长们_站长心得
·免费——不是威客网站的杀手锏_站长心得
·圈圈浅谈个人网站发展和赚钱的模式-网站推广的口碑篇_站长心得
·说网解络之web2.0概念诠释(1)_站长心得
·google adsense系列技巧100条_google推广
相关主题
  • vpopmail 管理员手册_qmail
  • vpopmail与qmail联合工作的机制_qmail
  • vpopmail实现qmail账户的数据库管理-网管专栏,邮件服务
  • vpopmail 管理员手册-网管专栏,邮件服务
  • Vpopmail 管理员手册-网管专栏,邮件服务
  • 西部数码虚拟主机

    友情链接
    CNNIC 西部数码
    万网 自助建站
    虚拟主机 asp空间
    域名注册 域名
    域名申请 主页空间
    论坛空间 网站空间
    国际域名 虚拟空间
    空间租用 DDOS防火墙
    成都主机托管 四川主机托管
    主机租用 服务器租用
    网站目录 自助建站
    虚拟主机 网址大全
    软件下载
    自助链接
    虚拟主机资讯 特价虚拟主机
    版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
    关于我们:站长天空:专业提供最新的站长资讯、在线教程、虚拟主机权威评测、虚拟主机性能对比、网站制作教程,开发教程,站长工具。包括网页制作教程、冲浪宝典、编程参考、操作系统、软件教学、行业动态等。
    特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
    发表评论 打印  刷新     关闭