2011-04-20 125 views
0

我遇到了一个奇怪的问题,即运行脚本(perl和ruby失败)从procmail本地提供的传入邮件。procmail不能正确执行脚本

该系统是CentOS 5.5,后缀为我的邮件程序,然后设置为发送电子邮件到procmail。 .procmailrc和脚本与Ubuntu服务器上的工作设置完全相同。

这里的.procmailrc文件:

PATH= /usr/local/bin:/usr/bin:${PATH} 
SHELL=/bin/bash 
MAILDIR=$HOME/Maildir 
DEFAULT=${MAILDIR}/ 
LOGABSTRACT=yes 
LOGFILE=$HOME/Maildir/proclog 
VERBOSE=YES 

:0 wc 
* ^To.*[email protected] 
| /home/web/perltest.pl 

这里的Perl脚本:

#!/usr/bin/env perl 

system("touch /home/web/touchedfile"); 

然后在接收邮件日志中的失败:

procmail: Executing "/home/web/perltest.pl" 
/home/web/perltest.pl: line 3: syntax error near unexpected token `"touch /home/web/touchedfile"' 
/home/web/perltest.pl: line 3: `system("touch /home/web/touchedfile");' 

该行结束所有的UNIX。该脚本从命令行运行良好。

整个设置工作正常,如果我直接从命令行管道到procmail,但是当它作为本地交付过程的一部分被调用时,#!似乎在脚本中被忽略。

我可以得到的Perl脚本来运行,如果我明确地在管道中执行Perl,就像这样:

:0 wc 
* ^To.*[email protected] 
| perl /home/web/perltest.pl 

...但我真的不想认输,并做到这一点。

回答

1

问题是selinux,如果你把它关掉它应该工作。我不确定如何使用selinux启用它。

这里有一个方法来解决它,仍然有selinux运行。在您的perl或ruby脚本上运行chcon system_u:object_r:procmail_exec_t。我已经证实这是一个修复,但我对selinux不够熟悉,以确保它是“正确的”修复程序。

+0

SELinux确实是罪魁祸首!谢谢! – Chris 2011-04-22 18:41:39