语言入口:简体中文 | English | 北亚博客
 
    
 
北亚Linux数据恢复

首席工程师:张宇

手机:18600440055

座机:4006505646-801

传真:4006505646-809

Email:zy@datahf.net

地址:北京市海淀区永丰基地丰慧中路7号新材料创业大厦B座205室
QQ:点击这里给我发消息
当前位置:首页>>Linux修复知识>>Linux文件系统修复>>正文
Linux修复知识

spamassassin 的统计分数用mysql数据库来存

standalone3.0.tar
必须改掉require("../common/admin_layout.php

参考
http://wiki.apache.org/spamassassin/UsingSQL
Install awl
1、
auto_whitelist_factory Mail::SpamAssassin::SQLBasedAddrList
2、
user_awl_dsn                 DBI: mysql:awl:localhost
user_awl_sql_username        spam
user_awl_sql_password        spamd
3、
mysql –uroot –p
create database awl;
grant select,delete,update,insert,drop,create ON awl.* to
[email=spam@localhost]spam@localhost[/email]
identified by ‘spamd’;
msyql –uroot –p

install bayes_mysql.sql
1、
bayes_store_module               Mail::SpamAssassin::BayesStore::MySQL
bayes_sql_dsn           DBI:mysql:bayes:localhost
bayes_sql_username      spam
bayes_sql_password      spamd
3、
mysql –uroot –p
create database bayes;
grant select,delete,update,insert,drop,create ON bayes.* to
[email=spam@localhost]spam@localhost[/email]
identified by ‘spamd’;
mysql –uroot –p

install userpref_mysql.sql
user_scores_dsn                    DBI:mysql:spamd:localhost
user_scores_sql_username        spam
user_scores_sql_password         spamd
user_scores_sql_custom_query        SELECT preference, value FROM _TABLE_ WHERE username = _USERNAME_ OR username =
[email='@GLOBAL']'@GLOBAL'[/email]
  OR username = CONCAT('%',_DOMAIN_)  ORDER BY username ASC
mysql –uroot –p
create database spamd;
grant select,delete,update,insert,drop,create ON spamd.* to
[email=spam@localhost]spam@localhost[/email]
identified by ‘spamd’;
mysql –uroot –p


UsingSQL
Using SQL
spamd can use SQL user_prefs by calling it with the -q or -Q flags. the following configuration options will be required in local.cf to point to the correct database.
These configuration options below are specific to SA 3.0. 2.63 does not use user_scores_sql_custom_query but does have other items to reference table names and such.
[root@mailgw /]# cd /etc/mail/spamassassin/
[root@mailgw spamassassin]# cat sql.cf
user_scores_dsn                  DBI:mysql:logs:localhost:3306
user_scores_sql_password         password
user_scores_sql_username         username
user_scores_sql_custom_query     SELECT preference, value FROM _TABLE_ WHERE username = _USERNAME_ OR
                                 username = '$GLOBAL' OR username = CONCAT('%',_DOMAIN_) ORDER BY username ASC
Make sure your user_scores_sql_custom_query is ALL ON ONE LINE! I wrapped it for display purposes only.
See  sql/README in your SpamAssassin tarball for more information on SQL configuration options.
SQL Table Structure for User Prefs
Personally, I use the following table structure for my user prefs... This allows my web interface to add additional information to the items via the des cript field, and also has added, added_by, and modified fields.
CREATE TABLE `userpref` (
  `id` int(8) unsigned NOT NULL auto_increment,
  `username` varchar(128) NOT NULL default '',
  `preference` varchar(64) NOT NULL default '',
  `value` varchar(128) default NULL,
  `des cript` varchar(128) default NULL,
  `added` datetime NOT NULL default '2003-01-01 00:00:00',
  `added_by` varchar(128) NOT NULL default '',
  `modified` timestamp(14) NOT NULL,
  UNIQUE KEY `id` (`id`),
  KEY `type` (`preference`),
  KEY `added_by` (`added_by`),
  KEY `preference` (`preference`),
  KEY `username` (`username`)
) TYPE=MyISAM COMMENT='Spamassassin Preferences';
The userpref table as recommended by sql/userpref_mysql.sql in your SA tarball is..
CREATE TABLE userpref (
  username varchar(100) NOT NULL default '',
  preference varchar(30) NOT NULL default '',
  value varchar(100) NOT NULL default '',
  prefid int(11) NOT NULL auto_increment,
  PRIMARY KEY  (prefid),
  KEY username (username)
) TYPE=MyISAM;
Not alot of difference... use whatever you want. If you are planning on having 1000's of user prefs via SQL, i would scale it back and not have all the extra fields.
To get this table active in your mysql database, save the syntax above to a file named userpref.sql and run
# cat userpref.sql | mysql
where  is the database you want to store this table. If you have not already created it, you will want to run something like..
# mysql
> CREATE DATABASE spamassassin;
> exit;
and then
# cat userpref.sql | mysql spamassassin
Once you have the table active, you need to assign access to it. All SpamAssassin needs is SELECT access to the userpref table. Running
# mysql spamassassin
> GRANT SELECT ON spamassassin.userpref TO username IDENTIFIED BY 'password';
> exit;
will allow connections from spamd to connect to the database as user username and a password of password... please change those to something SANE!
Global, Per-Domain, and Per-User Preferences via SQL
SpamAssassin 3.0 supports the config option user_scores_sql_custom_query - Using this feature, one can accomplish any number of custom configuration for supporting tiered user preferences.
However, for proper sorting of userpref when using Per-Domain settings, one must be careful on how SQL sorts the results. To make this work properly, you may be required to change how you reference your GLOBAL and PER-DOMAIN config preferences. To acheive proper sorting of SQL prefs, I use the following custom_query:
user_scores_sql_custom_query     SELECT preference, value FROM _TABLE_ WHERE username = _USERNAME_ OR
                                 username = '$GLOBAL' OR username = CONCAT('%',_DOMAIN_) ORDER BY username ASC
Please avoid line wrapping on user_scores_sql_custom_query.. copying and pasting the above line into a .cf will not work.
The reason I do it this way, as opposed to the standard vpopmail way (@GLOBAL), is so the preferences in my user_pref database order correctly...
Here is what the query produces...
mysql> select username,preference,value from userpref WHERE
(username='$GLOBAL' OR username='%nmgi.com' OR
[email=username='dallase@nmgi.com']username='dallase@nmgi.com'[/email]
) ORDER by username ASC;
+------------------+-------------------------+------------------------+
| username         | preference              | value                  |
+------------------+-------------------------+------------------------+
| $GLOBAL          | required_hits           | 4.00                   |
| $GLOBAL          | subject_tag             | [SPAM-_HITS_]-         |
| $GLOBAL          | score USER_IN_WHITELIST | -10                    |
| $GLOBAL          | whitelist_from          |
[email=*@sonicwall.com]*@sonicwall.com[/email]
        |
| $GLOBAL          | score USER_IN_BLACKLIST | 10                     |
| $GLOBAL          | report_safe             | 0                      |
| $GLOBAL          | use_razor2              | 1                      |
| $GLOBAL          | use_pyzor               | 1                      |
| $GLOBAL          | use_dcc                 | 1                      |
| $GLOBAL          | skip_rbl_checks         | 1                      |
| $GLOBAL          | use_bayes               | 1                      |
| $GLOBAL          | ok_locales              | en                     |
| $GLOBAL          | ok_languages            | en                     |
| $GLOBAL          | whitelist_from          |
[email=*@nai.com]*@nai.com[/email]
              |
| $GLOBAL          | use_auto_whitelist      | 1                      |
| $GLOBAL          | rewrite_header Subject  | [SPAM-_HITS_]-         |
| %nmgi.com        | use_bayes               | 1                      |
| %nmgi.com        | whitelist_from          |
[email=*@hp.com]*@hp.com[/email]
               |
| %nmgi.com        | score USER_IN_WHITELIST | -10                    |
| %nmgi.com        | score USER_IN_BLACKLIST | 10                     |
| %nmgi.com        | ok_locales              | en                     |
| %nmgi.com        | ok_languages            | en                     |
| %nmgi.com        | use_razor2              | 1                      |
| %nmgi.com        | use_pyzor               | 1                      |
| %nmgi.com        | use_dcc                 | 1                      |
| %nmgi.com        | skip_rbl_checks         | 1                      |
| %nmgi.com        | report_safe             | 0                      |
| %nmgi.com        | required_hits           | 5                      |
|
dallase@nmgi.com
| use_razor2              | 1                      |
|
dallase@nmgi.com
| use_bayes               | 1                      |
|
dallase@nmgi.com
| use_pyzor               | 1                      |

本新闻共2页,当前在第1页  1  2  

上一篇:MYSQL基础及MYSQL远程登陆的解决办法
下一篇:解决Oracle XDB的8080端口的冲突
JFS文件系统简介
XFS文件系统简介
Reiserfs文件系统简介
EXT3文件系统简介
常见Linux文件系统简介
GRUB简介与配置
LILO的使用和配置
Linux单用户模式维护系统
引导加载程序简介
重置Linux用户口令
  版权所有@北京北亚时代科技有限公司   京ICP备09039053号    
  总部电话:(010)82488636  中国·北京·海淀区中关村E世界C座8层879室               站点地图   联系我们  RSS阅读