个人工具
登录
查看“UbuntuHelp:Postfix/Dspam”的源代码 - Ubuntu中文
UbuntuHelp
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“UbuntuHelp:Postfix/Dspam”的源代码
来自Ubuntu中文
←
UbuntuHelp:Postfix/Dspam
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{From|https://help.ubuntu.com/community/Postfix/Dspam}} {{Languages|UbuntuHelp:Postfix/Dspam}} == Introduction == [http://dspam.nuclearelephant.com/about.php DSPAM] is a free software statistical spam filter written by Jonathan A. Zdziarski, author of the book Ending Spam and other books. It is intended to be a scalable, content-based spam filter for large multi-user systems. DSPAM is written in C and distributed under the terms of the GNU General Public License. DSPAM's original author claims that some users of DSPAM have reported as high as 99.5 to 99.95% accuracy, including "best recorded levels of accuracy ... 99.991% by one avid user (2 errors in 22,786) and 99.987% by the author.". == Installation == In order to install Dspam, first install the '''dspam''' package from the Universe repository using your favorite package manager. For example: <pre><nowiki> sudo aptitude install dspam </nowiki></pre> Simply accept the defaults when the installation process asks questions. The configuration will be done in greater detail in the next stage. == Configuration == There are two main configuration files for dspam: 1. <code><nowiki>/etc/default/dspam</nowiki></code> 2. <code><nowiki>/etc/dspam/dspam.conf</nowiki></code> === Dspam configuration === Edit the first file to allow dspam starting: <pre><nowiki> # Variables for dspam. # # Do not start dspam. START=yes # User that runs dspam. USER=dspam # Options for dspam. #OPTIONS="--debug" </nowiki></pre> Now, in order to start dspam as a daemon, we'll edit the second file: (here's a full dump of the file, without commented lines| <code><nowiki>cat /etc/dspam/dspam.conf | egrep -v "^\s*(#|$)"</nowiki></code>) <pre><nowiki> Home /var/spool/dspam StorageDriver /usr/lib/dspam/libhash_drv.so TrustedDeliveryAgent "/usr/sbin/sendmail" DeliveryHost 127.0.0.1 DeliveryPort 10024 DeliveryIdent localhost DeliveryProto SMTP OnFail error Trust root Trust dspam Trust mail Trust mailnull Trust smmsp Trust daemon Trust postfix Trust www-data TrainingMode teft TestConditionalTraining on Feature chained Feature whitelist Algorithm graham burton PValue graham Preference "spamAction=tag" Preference "signatureLocation=headers" # 'message' or 'headers' Preference "showFactors=off" AllowOverride trainingMode AllowOverride spamAction spamSubject AllowOverride statisticalSedation AllowOverride enableBNR AllowOverride enableWhitelist AllowOverride signatureLocation AllowOverride showFactors AllowOverride optIn optOut AllowOverride whitelistThreshold HashRecMax 98317 HashAutoExtend on HashMaxExtents 0 HashExtentSize 49157 HashMaxSeek 100 HashConnectionCache 10 Notifications off PurgeSignatures 14 # Stale signatures PurgeNeutral 90 # Tokens with neutralish probabilities PurgeUnused 90 # Unused tokens PurgeHapaxes 30 # Tokens with less than 5 hits (hapaxes) PurgeHits1S 15 # Tokens with only 1 spam hit PurgeHits1I 15 # Tokens with only 1 innocent hit LocalMX 127.0.0.1 SystemLog on UserLog on Opt out TrackSources spam ham ParseToHeaders on ChangeModeOnParse on ChangeUserOnParse on ServerPort 11124 ServerQueueSize 32 ServerPID /var/run/dspam/dspam.pid ServerMode auto ServerParameters "--deliver=innocent -d %u" ServerIdent "localhost.localdomain" ClientHost 127.0.0.1 ClientPort 11124 ProcessorBias on Include /etc/dspam/dspam.d/ </nowiki></pre> As you can see, we're going to bind the daemon to a localhost port to get more performance. === Postfix Integration === Now let's make Postfix speak to Dspam. Edit the <code><nowiki>/etc/postfix/master.cf</nowiki></code> and add the following: <pre><nowiki> # DSPAM 127.0.0.1:10024 inet n - n - - smtpd -o smtpd_authorized_xforward_hosts=127.0.0.0/8 dspam-retrain unix - n n - 10 pipe flags=Ru user=dspam argv=/etc/dspam/dspam-retrain $nexthop $sender $recipient </nowiki></pre> wright after: <pre><nowiki> smtp inet n - - - - smtpd </nowiki></pre> The dspam-retrain will be used to pass spam messages to dspam for training. Now edit <code><nowiki>/etc/postfix/main.cf</nowiki></code>, and replace in: <pre><nowiki> smtpd_client_restrictions = </nowiki></pre> the last line (which usually ends in word `permit`), with the following: <pre><nowiki> check_client_access pcre:/etc/postfix/dspam_filter_access permit_auth_destination </nowiki></pre> You should get something like: <pre><nowiki> smtpd_client_restrictions = [...] check_client_access pcre:/etc/postfix/dspam_filter_access permit_auth_destination </nowiki></pre> Also add somewhere (usually at the end of the file) the following: <pre><nowiki> # DSPAM dspam_destination_recipient_limit = 1 </nowiki></pre> <code><nowiki>/etc/postfix/dspam_filter_access</nowiki></code> file should contain the rules to connect to dspam lmtp daemon: <pre><nowiki> /./ FILTER lmtp:[127.0.0.1]:11124 </nowiki></pre> Now modify the <code><nowiki>/etc/postfix/transport</nowiki></code> to create the rules for training addresses: <pre><nowiki> spam@your.domain.tld dspam-retrain:spam ham@your.domain.tld dspam-retrain:innocent </nowiki></pre> In the end, let's create the file that will parse messages for training dspam. Create <code><nowiki>/etc/dspam/dspam-retrain</nowiki></code> with the following: <pre><nowiki> #! /usr/bin/perl # Get arguments $class = $ARGV[0] || die; shift; $sender = $ARGV[0] || die; shift; $recip = $ARGV[0] || die; shift; if ($recip =~ /^(spam|ham)-(\w+)@/) { # username is part of the recipient $user = $2; } elsif ($sender =~ /^(\w+)@/) { # username is in the sender $user = $1; } else { print "Can't determine user\n"; exit 75; # EX_TEMPFAIL } # Pull out DSPAM signatures and send them to the dspam program while (<>) { if ((! $subj) && (/^Subject: /)) { $subj = $_; } elsif (/(!DSPAM:[a-f0-9]+!)/) { open(F, "|/usr/bin/dspam --source=error --class=$class --user $user"); print F "$subj\n$1\n"; close(F); } elsif (/(X-DSPAM-Signature: [a-f0-9]+)/) { open(F, "|/usr/bin/dspam --source=error --class=$class --user $user"); print F "$subj\n$1\n"; close(F); } } </nowiki></pre> Don't forget to add execution permission to the file: <pre><nowiki> chmod +x /etc/dspam/dspam-retrain </nowiki></pre> == Service management == To start, stop or restart the service, use: <pre><nowiki> invoke-rc.d dspam start invoke-rc.d dspam stop invoke-rc.d dspam restart </nowiki></pre> Also after starting Dspam daemon, don't forget to restart Postfix: <pre><nowiki> invoke-rc.d postfix restart </nowiki></pre> == Debugging == Use <code><nowiki>dspam_stats -H</nowiki></code> for stats monitoring. Also, your emails should now contain dspam header signatures. Something like: <pre><nowiki> X-DSPAM-Result: Innocent X-DSPAM-Processed: Tue Jun 16 20:25:03 2009 X-DSPAM-Confidence: 1.0000 X-DSPAM-Probability: 0.0023 X-DSPAM-Signature: 4a37d56f12661069814937 </nowiki></pre> That's all. [[category:UbuntuHelp]]
该页面使用的模板:
模板:From
(
查看源代码
)
模板:Languages
(
查看源代码
)(受保护)
模板:Languages/Lang
(
查看源代码
)(受保护)
返回至
UbuntuHelp:Postfix/Dspam
。