简体   繁体   English

procmail没有正确执行脚本

[英]procmail is not executing scripts correctly

I'm having a strange issue with running scripts (perl and ruby failing) from incoming mail locally delivered by procmail. 我在procmail本地传递的传入邮件中运行脚本(perl和ruby失败)时遇到了一个奇怪的问题。

The system is CentOS 5.5 with postfix as my mailer, then a .forward set up to send email on to procmail. 系统是CentOS 5.5,将postfix作为我的邮件程序,然后将.forward设置为将电子邮件发送到procmail。 The .procmailrc and scripts are identical to a working setup on an Ubuntu server. .procmailrc和脚本与Ubuntu服务器上的工作设置相同。

Here's the .procmailrc: 这是.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.*web@mydomain.com
| /home/web/perltest.pl

Here's the perl script: 这是perl脚本:

#!/usr/bin/env perl

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

And then the failure in the log upon receiving email: 然后在收到电子邮件后日志中失败:

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");'

The line endings are all UNIX. 行尾均为UNIX。 The script runs fine from the command line. 该脚本可以从命令行正常运行。

The whole setup works fine if I pipe to procmail directly from the command line, but when it's invoked as part of the local delivery process, the #! 如果我直接从命令行通过管道传递到procmail,则整个设置工作正常,但是在本地传递过程中调用它时,请使用#!。 line seems to be ignored in the script. 脚本中似乎忽略了该行。

I can get the perl script to run if I explicitly execute perl in the pipe, like so: 如果我在管道中显式执行perl,则可以运行perl脚本,如下所示:

:0 wc
* ^To.*web@mydomain.com
| perl /home/web/perltest.pl

... but I really don't want to admit defeat and do that. ...但是我真的不想承认失败并这样做。

The problem is selinux, if you turn that off it should work. 问题是selinux,如果您将其关闭,它应该可以工作。 I'm not sure how to fix it with selinux enabled. 我不确定如何在启用selinux的情况下进行修复。

Here's a way to fix it and still have selinux running. 这是一种修复方法,仍然可以运行selinux。 Run chcon system_u:object_r:procmail_exec_t on your perl or ruby scripts. 在perl或ruby脚本上运行chcon system_u:object_r:procmail_exec_t I've verified that is a fix, but I'm not familiar enough with selinux to be sure it's the "correct" fix. 我已经证实这是一个修复程序,但是我对selinux不够熟悉,无法确定它是“正确的”修复程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM