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

我正在运行一个Debian GNU / Linux 8.7的盒子,并将Postfix 2.11.3-1作为MTA。 突然之间,也就是说,没有改变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 

根据Postfix的文档以及ServerFault上的其他 两个类似的问题,这是因为postfix运行了chroot,但是它的假脱机目录(即/var/spool/postfix缺less必要的文件(可能是/etc/services

我检查了/var/spool/postfix /etc/services 。 所以我复制( 符号链接) /etc/services/var/spool/postfix/etc 唉,无济于事。

然后,我玩弄了在/etc/postfix/master.cf为postfix'smtp binary禁用chroot jail,发现当我禁用unix服务types的chroot时,邮件正常交付。 也就是说,下面的/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 - nn - - local virtual unix - nn - - virtual lmtp unix - - - - - lmtp anvil unix - - - - 1 anvil scache unix - - - - 1 scache maildrop unix - nn - - pipe flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient} uucp unix - nn - - pipe flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient) ifmail unix - nn - - pipe flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient) bsmtp unix - nn - - pipe flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient scalemail-backend unix - nn - 2 pipe flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension} mailman unix - nn - - pipe flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user} 

我想,除了/etc/services之外的东西,在/var/spool/services的chroot jail中不存在,必须在我的chroot设置中出​​错。

所以我重新启用了chroot,下载了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 

但是,这又一次解决了我的设置问题。

我也尝试在/etc/postfix/master.cf的smtpconfiguration中join“-v”,但是错误报告没有得到更详细的说明。

在这一点上,我在我的智慧结束。 我还能检查什么? 我怎样才能修复我的设置,以便我可以重新启用后缀'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 

Postfix尚未被AppArmor保护:

 root@schroeder:~# apparmor_status apparmor module is loaded. apparmor filesystem is not mounted. 

我检查了这是否是Postfix主页上的一个已知错误,以及Debian的后缀包的bug跟踪器。

我也search了Postfix主页和邮件列表上链接的资源,但是唯一find的解决scheme是从源代码构buildPostfix。 我也试了一下,但错误仍然存​​在。

我还没有find错误的实际来源,但令我惊讶的(和沮丧)我可以通过以下方式解决:

 apt remove --purge postfix apt install postfix postfix-doc 

而且,据我所知,这并没有改变任何相关的设置。 我在/etc/postfix.backup保留了预清除configuration的备份,而/etc/postfix/main.cf/etc/postfix/main.cf没有什么不同。

 root@schroeder:/etc/postfix# diff main.cf ../postfix.backup/main.cf 18c18 < readme_directory = /usr/share/doc/postfix --- > readme_directory = no 21c21 < smtpd_tls_cert_file=/etc/ssl/certs/phl.univie.ac.at.crt --- > smtpd_tls_cert_file=/etc/ssl/certs/phl.univie.ac.at.pem 38d37 < mailbox_command = procmail -a "$EXTENSION" 42d40 < html_directory = /usr/share/doc/postfix/html 

/etc/postfix/master.cf/etc/postfix/master.cf不同之处在于,chrooting被再次启用(和工作):

 root@schroeder:/etc/postfix# diff master.cf ../postfix.backup/master.cf 53c53 < smtp unix - - - - - smtp --- > smtp unix - - n - - smtp 

/etc/postfix其他文件根本不同于/etc/postfix/backup中相应的拷贝。

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

 root@schroeder:/etc/postfix# cp main.cf main.cf.backup root@schroeder:/etc/postfix# cp ../postfix.backup/main.cf . root@schroeder:/etc/postfix# postfix reload postfix/postfix-script: refreshing the Postfix mail system echo 'A test.' | mail -s Test <censored> 

testing邮件到达。 所以, /etc/postfix的configuration文件显然并没有引起问题。

我仍然不知道做了什么。