postfix/smtp:致命:未知服务:smtp/tcp – 但 /var/spool/postfix/etc/services 存在

Odi*_*ger 5 linux debian postfix chroot debian-jessie

我正在运行带有 Postfix 2.11.3-1 作为 MTA 的 Debian GNU/Linux 8.7 机器。突然之间,也就是没有更改 MTA 设置,邮件停止发送,并且以下错误开始出现在/var/log/mail.err

root@schroeder:~# tail /var/log/mail.err
Mar 21 12:51:01 schroeder postfix/smtp[25421]: fatal: unknown service: smtp/tcp
Mar 21 12:54:11 schroeder postfix/smtp[26397]: fatal: unknown service: smtp/tcp
Mar 21 12:54:12 schroeder postfix/smtp[26398]: fatal: unknown service: smtp/tcp
Mar 21 12:59:26 schroeder postfix/smtp[26553]: fatal: unknown service: smtp/tcp
Mar 21 12:59:26 schroeder postfix/smtp[26554]: fatal: unknown service: smtp/tcp
Mar 21 12:59:26 schroeder postfix/smtp[26555]: fatal: unknown service: smtp/tcp
Mar 21 12:59:26 schroeder postfix/smtp[26556]: fatal: unknown service: smtp/tcp
Mar 21 13:04:30 schroeder postfix/smtp[27797]: fatal: unknown service: smtp/tcp
Run Code Online (Sandbox Code Playgroud)

根据Postfix 文档和ServerFault 上的其他两个 类似问题,这是因为 postfix 以 chroot 运行,但在其 spool 目录中缺少必要的文件,大概是./etc/services/var/spool/postfix

我查了一下,的确,/etc/services 从失踪/var/spool/postfix。所以我复制(不是符号链接)/etc/services/var/spool/postfix/etc. 唉,无济于事。

然后/etc/postfix/master.cf我尝试禁用postfix 的 smtp 二进制文件的 chroot jail ,发现当我禁用 unix 服务类型的 chrooting 时,邮件会正常发送。也就是说,以下/etc/postfix/master.cf工作正常:

root@schroeder:~# grep -v ^# /etc/postfix/master.cf
smtp      inet  n       -       -       -       -       smtpd
pickup    unix  n       -       -       60      1       pickup
cleanup   unix  n       -       -       -       0       cleanup
qmgr      unix  n       -       n       300     1       qmgr
tlsmgr    unix  -       -       -       1000?   1       tlsmgr
rewrite   unix  -       -       -       -       -       trivial-rewrite
bounce    unix  -       -       -       -       0       bounce
defer     unix  -       -       -       -       0       bounce
trace     unix  -       -       -       -       0       bounce
verify    unix  -       -       -       -       1       verify
flush     unix  n       -       -       1000?   0       flush
proxymap  unix  -       -       n       -       -       proxymap
proxywrite unix -       -       n       -       1       proxymap
# The setting below is the one that I've changed.
# The vendor default is a dash in the fifth column.
smtp      unix  -       -       n       -       -       smtp
relay     unix  -       -       -       -       -       smtp
showq     unix  n       -       -       -       -       showq
error     unix  -       -       -       -       -       error
retry     unix  -       -       -       -       -       error
discard   unix  -       -       -       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       -       -       -       lmtp
anvil     unix  -       -       -       -       1       anvil
scache    unix  -       -       -       -       1       scache
maildrop  unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
uucp      unix  -       n       n       -       -       pipe
  flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
ifmail    unix  -       n       n       -       -       pipe
  flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp     unix  -       n       n       -       -       pipe
  flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix  -       n       n       -       2       pipe
  flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}
Run Code Online (Sandbox Code Playgroud)

我想,除了/etc/services没有出现在 chroot jail 中之外/var/spool/services,我的 chroot 设置肯定有问题。

因此,我重新启用了 chrooting,下载了 Postfix 源代码,检查了 Postfix 源代码分发版附带的 Linux chroot 安装脚本并运行它:

root@schroeder:~# cd /usr/local/src/
root@schroeder:/usr/local/src# curl https://fourdots.com/mirror/postfix/postfix-release/official/postfix-3.2.0.tar.gz | tar -xz 
root@schroeder:/usr/local/src# sh postfix-3.2.0/examples/chroot-setup/LINUX2
postfix/postfix-script: refreshing the Postfix mail system
Run Code Online (Sandbox Code Playgroud)

然而,这并没有修复我的设置。

我还尝试在 smtp 配置中添加“-v” /etc/postfix/master.cf,但错误报告并没有变得更详细。

在这一点上,我在我的智慧尽头。我还能检查什么?如何修复我的设置,以便我可以为 postfix 的 smtp 二进制文件重新启用 chroot?

作为参考,我的设置:

root@schroeder:~# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = 127.0.0.1 ::1
mailbox_size_limit = 0
mydestination = schroeder.phl.univie.ac.at, localhost.phl.univie.ac.at, localhost
myhostname = schroeder.phl.univie.ac.at
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/phl.univie.ac.at.pem
smtpd_tls_key_file = /etc/ssl/private/phl.univie.ac.at.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes
Run Code Online (Sandbox Code Playgroud)

后缀是不是(还)通过的AppArmor保护:

root@schroeder:~# apparmor_status
apparmor module is loaded.
apparmor filesystem is not mounted.
Run Code Online (Sandbox Code Playgroud)

我在 Postfix 的主页和 Debian 的 postfix 包的错误跟踪器上检查了这是否是一个已知错误。

我还搜索了 Postfix 主页和邮件列表上链接的资源,但我找到的唯一“解决方案”是从源代码构建 Postfix。我也试了一下,但错误仍然存​​在。

Odi*_*ger 0

我还没有\xe2\x80\x99t找到错误的实际来源,但是\xe2\x80\x94让我惊讶(和沮丧)\xe2\x80\x94我可以通过以下方式修复它:

\n\n
apt remove --purge postfix\napt install postfix postfix-doc\n
Run Code Online (Sandbox Code Playgroud)\n\n

更重要的是,据我所知,这并没有改变任何相关设置。我将预清除配置的备份保存在/etc/postfix.backup,并且与 没有/etc/postfix/main.cf相关区别:/etc/postfix.backup/main.cf

\n\n
root@schroeder:/etc/postfix# diff main.cf ../postfix.backup/main.cf\n18c18\n< readme_directory = /usr/share/doc/postfix\n---\n> readme_directory = no\n21c21\n< smtpd_tls_cert_file=/etc/ssl/certs/phl.univie.ac.at.crt\n---\n> smtpd_tls_cert_file=/etc/ssl/certs/phl.univie.ac.at.pem\n38d37\n< mailbox_command = procmail -a "$EXTENSION"\n42d40\n< html_directory = /usr/share/doc/postfix/html\n
Run Code Online (Sandbox Code Playgroud)\n\n

并且与仅在再次启用 chrooting(并且有效)方面/etc/postfix/master.cf有所不同:/etc/postfix.backup/master.cf

\n\n
root@schroeder:/etc/postfix# diff master.cf ../postfix.backup/master.cf\n53c53\n< smtp      unix  -       -       -       -       -       smtp\n---\n> smtp      unix  -       -       n       -       -       smtp\n
Run Code Online (Sandbox Code Playgroud)\n\n

中的其他文件/etc/postfix与相应的副本/etc/postfix/backup完全不同。

\n\n

出于好奇,我检查了当我恢复使用旧配置文件时会发生什么:

\n\n
root@schroeder:/etc/postfix# cp main.cf main.cf.backup\nroot@schroeder:/etc/postfix# cp ../postfix.backup/main.cf .\nroot@schroeder:/etc/postfix# postfix reload\npostfix/postfix-script: refreshing the Postfix mail system\necho \'A test.\' | mail -s Test <censored>\n
Run Code Online (Sandbox Code Playgroud)\n\n

测试邮件到达。/etc/postfix因此,显然,中的配置文件一开始并没有导致问题。

\n\n

我仍然不知道做了什么。

\n