使用查询程序重定向的路由器-exim4

使用查询程序重定向的路由器-exim4

我们正在Exim4使用 配置路由器driver = queryprogram,目的是执行脚本并根据脚本的逻辑重定向某些地址。

问题是,当调试 exim 如何路由地址时,我们收到错误 my_router router: command returned non-zero code 127

为什么 exim 会得到command returned non-zero code 127?我们该如何解决这个问题?

谢谢!

以下是一些希望有用的信息:

# exim -d -bt [email protected]

...

--------> my_router router <--------
local_part=anaddress domain=mylocaldomain
checking local_parts
anaddress in "! root"? yes (end of list)
R: my debug message
calling my_router router
my_router router called for [email protected]: domain = mylocaldomain.com
requires uid=1001 gid=1001 current_directory=/tmp
direct command:
  argv[0] = /tmp/myscript.sh
direct command after expansion:
  argv[0] = /tmp/myscript.sh
my_router router: defer for [email protected]
  message: my_router router: command returned non-zero code 127
[email protected] cannot be resolved at this time: my_router router: command returned non-zero code 127
search_tidyup called
>>>>>>>>>>>>>>>> Exim pid=8094 terminating with rc=1 >>>>>>>>>>>>>>>>

处理邮件的脚本(/tmp/myscript.sh)只是

#/usr/bin/php

echo 'redirect another_address@another_domain.com';
exit;

脚本有权限

$ ls /tmp
total 196K
4.0K -rwxrwxr-x 1 someuser somegroup         58 Oct  5 20:48 myscript.sh

路由器配置exim4.conf.template如下:

...

my_router:
  debug_print = "R: my debug message"
  driver = queryprogram
  command = /tmp/myscript.sh
  current_directory = /tmp
  command_user = myuser
#  domains = +local_domains
  local_parts = ! root
  cannot_route_message = Unknown Special user

答案1

脚本中有一个拼写错误:井号后面省略了 bang。

#!/usr/bin/php

echo 'redirect another_address@another_domain.com';
exit;

退出代码 127 意味着由于 shebang 行格式不正确,所以未找到适当的解释器。

另外,我不确定您是否真的希望您的脚本由 PHP 解释。因此,您可能需要将第一行替换为#!/bin/sh

相关内容