Permissions Postfix管道电子邮件到php,权限错误

Permissions Postfix管道电子邮件到php,权限错误,permissions,ssh,pipe,postfix-mta,permission-denied,Permissions,Ssh,Pipe,Postfix Mta,Permission Denied,我正试图通过我的Postfix邮件服务器通过管道将电子邮件发送到PHP,并遇到以下错误 Mar 16 22:52:52 s15438530 postfix/pipe[9259]: AD1632E84C63: to=<php@[myserver].com>, relay=plesk_virtual, delay=0.61, delays=0.59/0/0/0.02, dsn=4.3.0, status=deferred (temporary failure. Command outpu

我正试图通过我的Postfix邮件服务器通过管道将电子邮件发送到PHP,并遇到以下错误

Mar 16 22:52:52 s15438530 postfix/pipe[9259]: AD1632E84C63: to=<php@[myserver].com>, relay=plesk_virtual, delay=0.61, delays=0.59/0/0/0.02, dsn=4.3.0, status=deferred (temporary failure. Command output: /bin/sh: /var/www/vhosts/[myserver].com/httpdocs/clients/emailpipe/email2php.php: Permission denied 4.2.1 Message can not be delivered at this time )
Mar 16 22:52:52 s15438530后缀/pipe[9259]:AD1632E84C63:to=,relay=plesk_virtual,delay=0.61,delays=0.59/0/0/0.02,dsn=4.3.0,status=deferred(临时故障。命令输出:/bin/sh:/var/www/vhosts/[myserver]。com/httpdocs/clients/emailpipe/email2ppp.php:权限被拒绝4.2.1消息此时无法发送)
如果有人能为我解释一下这个问题,我将不胜感激。我试过777'ing emailpipe目录,但没有用。我哪里做错了


非常感谢。

要解决此问题,您需要将chown或chmod
/var/www/vhosts/[myserver].com/httpdocs/clients/emailpipe/email2ppp.php
转换为postfix用户可执行的文件。或者,您需要重新定义此用户以成功执行该文件

仅仅更改目录的权限(除非您使用了
-R
)是不够的

来说明为什么这样做,考虑下面的玩具例子:

<me>@harley:~$ touch test
<me>@harley:~$ ls -al test
-rw-r--r-- 1 <me> <me> 0 2012-03-26 23:44 test
<me>@harley:~$ sh test
<me>@harley:~$
<me>@harley:~$ ./test
bash: ./test: Permission denied
<me>@harley:~$ chmod 755 test
<me>@harley:~$ ./test
<me>@harley:~$ 
@harley:~$touch-test
@哈雷:~$ls-al测试
-rw-r--r--10 2012-03-26 23:44测试
@哈雷:~$sh测试
@哈雷:~$
@哈雷:~$/测试
bash:./test:权限被拒绝
@哈雷:~$CHMOD755测试
@哈雷:~$/测试
@哈雷:~$
为了通过运行的shell直接执行文件,需要将其设置为可执行文件。其他调用(例如,
sh email2ppp.php
php email2ppp.php
)只需要读取访问权限,因为它们将执行链接到完全不同的文件


有关首先可能导致问题的原因,请参阅。

来自postfix文档

出于安全原因,将使用alias数据库所有者的权限执行到命令和文件目标的传递。默认用户标识default_privs用于以root拥有的别名传递到命令/文件

因此,您有两个选项,或者在main.cf中设置默认\u privs,以匹配Email2HP文件的所有权


或者,应该有一种方法来创建由用户而不是postfix/nobody拥有的别名数据库。我以前没有试过,所以我无法提供建议。

请确保您已经尝试过

#!/usr/bin/php
<?php
另外,请确保可以从命令行测试脚本:

cat some_rfc822_email.txt | /var/.../email2php.php

并获得您想要的结果

我已通过禁用SELINUX解决了此问题

您是否查看了emailpipe目录父目录(以及目录结构中更高的所有目录)的权限?顺便说一句,不要用chmod 777;将其设置为755是完全足够的。我使用了-R标志,amcnabb提供的答案允许我取得进展,但是,我仍然遇到保存附件的问题。谢谢你的建议。这很可能是导致perm问题的实际问题。第一个选项的缺点是,我们只能为默认用户指定一个用户。所以,我尝试了你的替代方案,并得到了积极的结果。请参阅。我能够使用该命令生成一个策略,该策略允许SELinux保持运行,但允许我的脚本处理从Postfix传送到它的传入电子邮件。
cat some_rfc822_email.txt | /var/.../email2php.php