📄 1412.html
字号:
<TR>
<TD vAlign=top width="80%">
<DIV align=center>
<FORM action="search.html" tppabs="http://www.linuxhero.com/docs/search.html" method=get>
</FORM>
<TABLE cellSpacing=0 cellPadding=0 width="95%"
border=0><TBODY>
<TR>
<TD background="images/bgi.gif" tppabs="http://www.linuxhero.com/docs/images/bgi.gif"
height=30></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=3 width="95%"
align=center border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%"
border=0>
<TBODY>
<TR>
<TD vAlign=top>
<p><FONT class=normalfont><B><font color=blue>qmailadmin+vpopmail+sqwebmail+mysql的filter的配置方法</font></B></FONT><BR><FONT class=smallfont color=#ff9900>2004-04-23 15:18 pm</FONT><BR><FONT class=normalfont>作者:gadfly<br>来自:Linux知识宝库<br>联系方式:无名<br><br>这两天和peng老大研究了一下在qmailadmin+vpopmail+sqwebmail+mysql下,如何将webmail定义的过滤器
作用于qmail-local(即MDA)的方法。
这里有几个问题,需要解决。
1.如何在建用户的时候自动的初始化用户的初始filter文件.
2.webmail定义的filter如何起作用。
3.还有一些是解决这些问题的过程中遇到的问题。
针对第一个问题,研究了一下qmailadmin,看了代码之后才发现,
qmailadmin支持插件似的配置文件,在操作用户后,
运行在插件配置文件中定义的脚本。脚本是针对每个域的,即放在域的目录下面。
呵呵,网上都没有介绍哦,估计是inter7 unleased.
域的目录通过/var/qmail/users/assign来定位。例如,assign的内容如下:
+foo.com-:foo.com:515:511:/home/vpopmail/domains/foo.com:-::
.
则在/home/vpopmail/domains/foo.com下定义一个配置文件.qmailadmin-hooks。注意属
主和属性,这个配置文件格式如下:
#....
op: cmd
其中到qmailadmin-1.06,op支持以下一些操作
"adduser",
"deluser",
"moduser",
"addmaillist",
"delmaillist",
"modmaillist",
"listadduser",
"listdeluser"
例如:你想在增加用户以后干些事情,就以增加filter为例,.qmailadmin-hooks
就可以这么配:
adduser: /home/vpopmail/bin/inituser.sh
inituser.sh脚本如下:
[code]
#!/bin/bash
Domain=$1
User=$3
Passwd=$2
DomainPath=/home/vpopmail/domains/$Domain
umask 0177
exec 1> /tmp/adduser.log
exec 2> /tmp/adduser.log
echo $DomainPath
cat>$DomainPath/.qmail-$User <<EOF
|maildrop $DomainPath/$User/.mailfilter
EOF
cat>$DomainPath/$User/.mailfilter <<EOF
include $User/.userfilter
to "$DomainPath/$User/Maildir/."
EOF
cat>$DomainPath/$User/.userfilter <<EOF
#MFMAILDROP=2
#
# DO NOT EDIT THIS FILE. This is an automatically generated filter.
FROM='$User@$Domain'
import SENDER
if ($SENDER ne "")
{
FROM=$SENDER
}
to "$DomainPath/$User/Maildir/."
EOF
cat>$DomainPath/$User/Maildir/maildirfilterconfig <<EOF
MAILDIRFILTER=../.userfilter
MAILDIR=$DomainPath/$User/Maildir
EOF
[/code]
针对第二个问题,实际上上面inituser.sh已经提供了解决方法,也就是sqwebmail通过
maildirfilterconfig来查找filter文件,这里定义的是../.userfilter,它有包含在.mailfiter中,
而点.mailfilter则是maildrop调用的规则文件。
这里有几个地方需要解释,
1..userfilter中的前几行comment是起作用的,是sqwebmail的标记,不能去掉,否则sqwebmail会报错
2.MAILDIRFILTER为什么不指向.mailfiter,而是.userfilter,一句话方便扩充。可以在.mailfilter中加入
其它的filter rule, 而这些rule并不需要用户编辑。
3..qmailadmin-hook中的脚本是qmailadmin fork出的子进程执行的,qmailadmin由于是以http的用户运行
所以建立这些文件的时候会有错误。因此,我们改了一点源代码,位置在源码包的qmailadmin*/user.c的
函数call_hooks的fork之前, 如下:
+ setuid(0);
+ setgid(VPOPMAILGID);
+ setuid(VPOPMAILUID);
pid = fork();
编译之后qmailadmin后,并替换cgi目录下的文件,注意属主是root和setuid位.
4.为什么不在inituser.sh中用su来执行,这样就不用改代码了?首先,apache重定向了stdin,而su是检查
stdin是不是tty,如果不是,就不会执行。其次,fork出来的子进程是exec的方式执行配置中指定的命令,
而exec是不复制euid和egid的,所以如果不用su,就需要用自己编一个suid的程序。这又麻烦了.
呵呵,
这几天太忙,也许过年都回不了家,我苦,,没时间去搞了,就用个省力的方法了。
欢迎各位简化这些过程。
【发表回复】【查看CU论坛原帖】【关闭】
gadfly 回复于:2003-01-15 12:31:49
呵呵,好人做到底,增加deluser的配置方式:
.qmailadmin-hooks如下:
adduser: /home/vpopmail/bin/inituser.sh
deluser: /home/vpopmail/bin/deluser.sh
/var/vpopmail/bin/deluser.sh如下
#!/bin/bash
Domain=$1
User=$3
Passwd=$2
DomainPath=/home/vpopmail/domains/$Domain
rm -f $DomainPath/.qmail-$User
bingbing 回复于:2003-01-15 12:40:17
好东东,收藏^_^
gadfly 回复于:2003-01-15 17:41:42
今天又试了试deluser的脚本,不起作用。
又研究了一把,呵呵,原来qmailadmin有bug.
在源码包的qmailadmin*/user.c的函数call_hooks的这行
error = execl(cmd, Newu, Domain, Password1, Gecos, NULL);
这里明显有问题,execl的第二个参数是arg0,实际上不起作用。而Gecos是用户的真实
用户名,只有在新建的时候才有值,不填就是Newu,所以我以为用户名是$3.
但是moduser和deluser的时候,操作的用户名都不在Newu里面,而是在ActionUser里面。
所以hook中定义的deluser和moduser脚本取不到用户名.
所以需要将这行改为
if (Newu && *Newu) {
error = execl(cmd, cmd, Newu, Domain, Password1, Gecos, NULL);
} else {
error = execl(cmd, cmd, ActionUser, Domain, Password1, Gecos, NULL);
}
而且,如果要方便扩展的话,可以将op也放在execl的参数中,这样,hook中定义的
脚本就可以用一个。根据op类型来操作。就不像我这样分成好多脚本了。
所以user.c最终该过后,如下,call_hooks函数的fork附近:
setuid(0);
setgid(VPOPMAILGID);
setuid(VPOPMAILUID);
pid = fork();
#ifdef DEBUG
fprintf(actout,"Where the parameters are: %s, "%s", %s, %s, %s, %s, NULL);",
cmd, hooks[hook_type], Newu, Domain, Password1, Gecos);
#endif
if (pid == 0) {
// error = execl(cmd, Newu, Domain, Password1, Gecos, NULL);
if (Newu && *Newu) {
error = execl(cmd, cmd, Newu, Domain, Password1, Gecos, NULL);
} else {
error = execl(cmd, cmd, ActionUser, Domain, Password1, Gecos, NULL);
}
而inituser.sh和deluser也需要相应的改参数位置,我只贴上修改的头几行如下:
#!/bin/sh
User=$1
Domain=$2
Passwd=$3
RealName=$4
呵呵,看来unlease是有道理的亚
</FONT><br>
</TD>
</TR>
<TR>
<TD colSpan=2><FONT
class=middlefont></FONT><BR>
<FONT
class=normalfont>全文结束</FONT> </TD>
</TR>
<TR>
<TD background="images/dot.gif" tppabs="http://www.linuxhero.com/docs/images/dot.gif" colSpan=2
height=10></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></DIV></TD>
<TD vAlign=top width="20%"
background="images/line.gif" tppabs="http://www.linuxhero.com/docs/images/line.gif" rowSpan=2>
<DIV align=center>
<table class=tableoutline cellspacing=1 cellpadding=4
width="100%" align=center border=0>
<tr class=firstalt>
<td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colspan=2 height=21>
<font class=normalfont><b>所有分类</b></font></td>
</tr>
<tr class=secondalt> <td noWrap width=27%> <font class=normalfont>1:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type1.html" tppabs="http://www.linuxhero.com/docs/type1.html">非技术类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>2:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type2.html" tppabs="http://www.linuxhero.com/docs/type2.html">基础知识</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>3:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type3.html" tppabs="http://www.linuxhero.com/docs/type3.html">指令大全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>4:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type4.html" tppabs="http://www.linuxhero.com/docs/type4.html">shell</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>5:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type5.html" tppabs="http://www.linuxhero.com/docs/type5.html">安装启动</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>6:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type6.html" tppabs="http://www.linuxhero.com/docs/type6.html">xwindow</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>7:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type7.html" tppabs="http://www.linuxhero.com/docs/type7.html">kde</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>8:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type8.html" tppabs="http://www.linuxhero.com/docs/type8.html">gnome</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>9:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type9.html" tppabs="http://www.linuxhero.com/docs/type9.html">输入法类</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>10:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type10.html" tppabs="http://www.linuxhero.com/docs/type10.html">美化汉化</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>11:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type11.html" tppabs="http://www.linuxhero.com/docs/type11.html">网络配置</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>12:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type12.html" tppabs="http://www.linuxhero.com/docs/type12.html">存储备份</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>13:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type13.html" tppabs="http://www.linuxhero.com/docs/type13.html">杂项工具</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>14:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type14.html" tppabs="http://www.linuxhero.com/docs/type14.html">编程技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>15:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>16:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type16.html" tppabs="http://www.linuxhero.com/docs/type16.html">内核技术</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>17:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>18:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type18.html" tppabs="http://www.linuxhero.com/docs/type18.html">apache</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>19:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type19.html" tppabs="http://www.linuxhero.com/docs/type19.html">email</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>20:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type20.html" tppabs="http://www.linuxhero.com/docs/type20.html">ftp服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>21:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type21.html" tppabs="http://www.linuxhero.com/docs/type21.html">cvs服务</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>22:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type22.html" tppabs="http://www.linuxhero.com/docs/type22.html">代理服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>23:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type23.html" tppabs="http://www.linuxhero.com/docs/type23.html">samba</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>24:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type24.html" tppabs="http://www.linuxhero.com/docs/type24.html">域名服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>25:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type25.html" tppabs="http://www.linuxhero.com/docs/type25.html">网络过滤</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>26:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type26.html" tppabs="http://www.linuxhero.com/docs/type26.html">其他服务</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>27:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type27.html" tppabs="http://www.linuxhero.com/docs/type27.html">nfs</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>28:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type28.html" tppabs="http://www.linuxhero.com/docs/type28.html">oracle</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>29:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type29.html" tppabs="http://www.linuxhero.com/docs/type29.html">dhcp</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>30:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type30.html" tppabs="http://www.linuxhero.com/docs/type30.html">mysql</a></font></td> </tr> </table></td></tr><tr class=secondalt> <td noWrap width=27%> <font class=normalfont>31:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type31.html" tppabs="http://www.linuxhero.com/docs/type31.html">php</a></font></td> </tr> </table></td></tr><tr class=firstalt> <td noWrap width=27%> <font class=normalfont>32:</font> </td><td noWrap width=73%> <table width=100% border=0> <tr> <td><font class=normalfont><a href="type32.html" tppabs="http://www.linuxhero.com/docs/type32.html">ldap</a></font></td> </tr> </table></td></tr> </table>
</DIV></TD></TR>
<TR vAlign=top>
<TD width="80%">
<DIV align=center><BR>
</DIV>
</TD></TR></TBODY></TABLE></TD></TR>
</TABLE></TD></TR>
</TABLE>
<TABLE cellSpacing=0 cellPadding=4 width="100%" bgColor=#eeeeee
border=0><TBODY>
<TR>
<TD width="50%">
<P><FONT class=middlefont>版权所有 © 2004 <A
href="mailto:bjchenxu@sina.com">linux知识宝库</A><BR>
违者必究. </FONT></P>
</TD>
<TD width="50%">
<DIV align=right><FONT class=middlefont>Powered by: <A
href="mailto:bjchenxu@sina.com">Linux知识宝库</A> Version 0.9.0 </FONT></DIV>
</TD></TR></TBODY></TABLE>
<CENTER></CENTER></TD></TR>
</TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -