exim:根据经过身份验证的用户验证别名?

exim:根据经过身份验证的用户验证别名?

是否有可能根据经过身份验证的用户验证发件人别名,而无需重写发件人字段?例如,给定一个(简化很多的)别名文件,如:

[email protected]:       [email protected]
[email protected]: [email protected]
[email protected]: [email protected]
[email protected]:       [email protected]

[email protected]:       [email protected]

我希望经过身份验证的用户 1 能够以 a1、a2、a3 或[电子邮件保护], 但不是[电子邮件保护],我只希望经过身份验证的用户2能够发送[电子邮件保护] 我希望他们能够在他们发送的电子邮件的“发件人:”字段中使用别名(即,我不希望 Exim 重写“发件人/发件人”字段,如“control=submission”)。

从功能上讲,这需要 Exim 将发件人别名缩减为最终可路由地址,然后允许我在 acl 中访问该值,以便将其与经过身份验证的用户进行比较。我以为 verify=sender 会这样做,但测试表明情况并非如此。

在我的 acl_check_rcpt 中,我尝试了以下操作但没有效果,因为任何经过身份验证的用户仍然可以作为任何有效别名或其他本地用户发送,并且 $sender_address 是别名而不是底层真实帐户:

  accept
    authenticated = *
    verify = sender
    logwrite = authenticated user '$authenticated_id' sending as '$sender_address' which \
        is '$sender_address_data' or '$address_data', if error: '$sender_verify_failure'

根据Exim 文档(第 26 节),$sender_address_data 应该包含 verify=sender 之后发件人查找的结果,但日志显示该变量始终为空:

authenticated user 'user1' sending as '[email protected]' which is '' or '', if error: ''

(请注意,除了重写 From/Sender 标头之外,control=submission 对此几乎没有影响。)

我是不是做错了?有没有办法验证经过身份验证的用户是否可以有效发送他们要发送的别名?

答案1

我让它工作了,这就是我所做的。

首先,在处理本地用户的所有路由器中,将 exim 变量 address_data 设置为 ${local_part}:

real_local:
  driver              = accept
  domains             = +local_domains
  local_part_prefix   = real-
  check_local_user
  transport           = LOCAL_DELIVERY
  # Set this so acl can use it
  address_data        = ${local_part}

然后设置一个 acl 来检查发件人与经过身份验证的用户:

acl_smtp_mail = acl_check_sender_vs_auth

并让新的 acl 将经过身份验证的用户与 address_data 变量的值进行比较,并确保其相同:

# Ensure that the MAIL FROM: address matches what the authenticated
# user is, if authentiation is used
acl_check_sender_vs_auth:
    accept
       authenticated = *
       # verify MUST be above condition to resolve $sender_address_data
       verify = sender
       condition = ${if eqi{$authenticated_id}{$sender_address_data}{yes}{no}}
       endpass
       logwrite = AUTH OK - authenticated user '$authenticated_id' sending email from '$sender_address', which belongs to '$sender_address_data'

    deny
       authenticated = *
       # verify MUST be above condition to resolve $sender_address_data
       verify = sender
       !condition = ${if eqi{$authenticated_id}{$sender_address_data}{yes}{no}}
       message = User '$authenticated_id' tried to send mail from '$sender_address', but that email address belongs to someone else
       logwrite = AUTH ERROR - authenticated user '$authenticated_id' tried sending from '$sender_address', but that address belongs to '$sender_address_data'

    accept

相关内容