我刚刚将系统从 14.04 升级到 16.04,除了其他问题之外,opendkim 无法正常启动。我遇到以下问题/var/log/syslog
:
Sep 19 18:27:58 aurora systemd[1]: Starting DomainKeys Identified Mail (DKIM) Milter...
Sep 19 18:27:59 aurora opendkim[28496]: opendkim: usage: opendkim -p socketfile [options]
Sep 19 18:27:59 aurora opendkim[28496]: #011-A #011auto-restart
Sep 19 18:27:59 aurora opendkim[28496]: #011-b modes #011select operating modes
Sep 19 18:27:59 aurora opendkim[28496]: #011-c canon #011canonicalization to use when signing
Sep 19 18:27:59 aurora opendkim[28496]: #011-d domlist #011domains to sign
Sep 19 18:27:59 aurora opendkim[28496]: #011-D #011also sign subdomains
Sep 19 18:27:59 aurora opendkim[28496]: #011-e name #011extract configuration value and exit
Sep 19 18:27:59 aurora opendkim[28496]: #011-f #011don't fork-and-exit
Sep 19 18:27:59 aurora opendkim[28496]: #011-F time #011fixed timestamp to use when signing (test mode only)
Sep 19 18:27:59 aurora opendkim[28496]: #011-k keyfile #011location of secret key file
Sep 19 18:27:59 aurora opendkim[28496]: #011-l #011log activity to system log
Sep 19 18:27:59 aurora opendkim[28496]: #011-L limit #011signature limit requirements
Sep 19 18:27:59 aurora opendkim[28496]: #011-n #011check configuration and exit
Sep 19 18:27:59 aurora opendkim[28496]: #011-o hdrlist #011list of headers to omit from signing
Sep 19 18:27:59 aurora opendkim[28496]: #011-P pidfile #011file into which to write process ID
Sep 19 18:27:59 aurora opendkim[28496]: #011-q #011quarantine messages that fail to verify
Sep 19 18:27:59 aurora opendkim[28496]: #011-Q #011query test mode
Sep 19 18:27:59 aurora opendkim[28496]: #011-r #011require basic RFC5322 header compliance
Sep 19 18:27:59 aurora opendkim[28496]: #011-s selector #011selector to use when signing
Sep 19 18:27:59 aurora opendkim[28496]: #011-S signalg #011signature algorithm to use when signing
Sep 19 18:27:59 aurora opendkim[28496]: #011-t testfile #011evaluate RFC5322 message in "testfile"
Sep 19 18:27:59 aurora opendkim[28496]: #011-T timeout #011DNS timeout (seconds)
Sep 19 18:27:59 aurora opendkim[28496]: #011-u userid #011change to specified userid
Sep 19 18:27:59 aurora opendkim[28496]: #011-v #011increase verbosity during testing
Sep 19 18:27:59 aurora opendkim[28496]: #011-V #011print version number and terminate
Sep 19 18:27:59 aurora opendkim[28496]: #011-W #011"why?!" mode (log sign/verify decision logic)
Sep 19 18:27:59 aurora opendkim[28496]: #011-x conffile #011read configuration from conffile
Sep 19 18:27:59 aurora systemd[1]: opendkim.service: Control process exited, code=exited status=64
Sep 19 18:27:59 aurora systemd[1]: Failed to start DomainKeys Identified Mail (DKIM) Milter.
Sep 19 18:27:59 aurora systemd[1]: opendkim.service: Unit entered failed state.
Sep 19 18:27:59 aurora systemd[1]: opendkim.service: Failed with result 'exit-code'.
似乎opendkim
获取了无效的命令行参数。如何找出正在使用的命令行以及它是如何构造的?
跟踪/etc/init.d/opendkim start
没有帮助,因为这只是调用 /bin/systemctl --no-pager start opendkim.service
。环顾四周,我发现/lib/systemd/system/opendkim.service
其中包含以下行
ExecStart=/usr/sbin/opendkim -x /etc/opendkim.conf -u opendkim -P /var/run/opendkim/opendkim.pid -p $SOCKET $DAEMON_OPTS
在 中/etc/default/opendkim
,我们保留SOCKET="inet:8891@localhost"
和DAEMON_OPTS
未设置。但是,如果我手动运行
/usr/sbin/opendkim -x /etc/opendkim.conf -u opendkim -P /var/run/opendkim/opendkim.pid -p inet:8891@localhost
它成功了。所以显然这不是正在使用的命令行。
根据 muru 的评论,以下是 的输出systemctl -l status opendkim.service
。
● opendkim.service - DomainKeys Identified Mail (DKIM) Milter
Loaded: loaded (/lib/systemd/system/opendkim.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2016-09-19 18:27:59 UTC; 23min ago
Docs: man:opendkim(8)
man:opendkim.conf(5)
man:opendkim-genkey(8)
man:opendkim-genzone(8)
man:opendkim-testadsp(8)
man:opendkim-testkey
http://www.opendkim.org/docs.html
Process: 28496 ExecStart=/usr/sbin/opendkim -x /etc/opendkim.conf -u opendkim -P /var/run/opendkim/opendkim.pid -p $SOCKET $DAEMON_OPTS (code=exited, status=64)
Process: 28488 ExecStartPre=/bin/chown opendkim.opendkim /var/run/opendkim (code=exited, status=0/SUCCESS)
Process: 28485 ExecStartPre=/bin/mkdir -p /var/run/opendkim (code=exited, status=0/SUCCESS)
Sep 19 18:27:59 aurora opendkim[28496]: -T timeout DNS timeout (seconds)
Sep 19 18:27:59 aurora opendkim[28496]: -u userid change to specified userid
Sep 19 18:27:59 aurora opendkim[28496]: -v increase verbosity during testing
Sep 19 18:27:59 aurora opendkim[28496]: -V print version number and terminate
Sep 19 18:27:59 aurora opendkim[28496]: -W "why?!" mode (log sign/verify decision logic)
Sep 19 18:27:59 aurora opendkim[28496]: -x conffile read configuration from conffile
Sep 19 18:27:59 aurora systemd[1]: opendkim.service: Control process exited, code=exited status=64
Sep 19 18:27:59 aurora systemd[1]: Failed to start DomainKeys Identified Mail (DKIM) Milter.
Sep 19 18:27:59 aurora systemd[1]: opendkim.service: Unit entered failed state.
Sep 19 18:27:59 aurora systemd[1]: opendkim.service: Failed with result 'exit-code'.
该ExecStart
行与文件中的一样。是否有可能它实际上是在传递字符串,$SOCKET
而不是传递此变量的内容?
答案1
我找到了答案。我尝试/usr/sbin/opendkim
用一个记录命令行的脚本替换它,发现它正在
-x /etc/opendkim.conf -u opendkim -P /var/run/opendkim/opendkim.pid -p inet:8891@localhost# listen on loopback on port 12345
该行末尾有一个注释,/etc/default/opendkim
显然没有得到正确解析。
我把该评论移到了它自己的行上,现在它可以正常工作了。
答案2
我用文件中的实际套接字值替换了“$SOCKET” /lib/systemd/system/opendkim.service
,但仍然出现同样的问题。
答案3
我不知怎的就有 2 个SOCKET
def /etc/default/opendkim
:
这个:
# default:
#SOCKET="local:/var/run/opendkim/opendkim.sock"
以及新添加的:
# listen on loopback on port 8891
SOCKET="inet:8891@localhost"
这可能是一个非常烦人的问题,所以这是我的/lib/systemd/system/opendkim.service
文件ExecStart
ExecStart=/usr/sbin/opendkim -x /etc/opendkim.conf -u opendkim -P /var/run/opendkim/opendkim.pid -p $SOCKET $DAEMON_OPTS
同样ExecStart
/etc/systemd/system/multi-user.target.wants/opendkim.service
并且它工作得很好。
希望这对某些人有帮助。