linode 从 Debian 8 升级到 Stable 后出现“无法写入队列目录”错误和其他 sendmail 问题

linode 从 Debian 8 升级到 Stable 后出现“无法写入队列目录”错误和其他 sendmail 问题

我跟着本教程将我的 linode 实例从 Debian 8 升级到 Stable。升级后,我遇到了一些 sendmail 错误/问题。

  1. $ which sendmail不返回任何内容。我已安装 sendmail。其位于/usr/sbin/sendmail

  2. Sendmail的权限如下:

    $ ls -la /usr/sbin/sendmail lrwxrwxrwx 1 root root 26 Jul 17 12:41 /usr/sbin/sendmail -> /etc/alternatives/sendmail

    链接(/etc/alternatives/sendmail)以红色突出显示。

  3. 当我尝试发送测试电子邮件时出现以下错误:sudo echo "Subject: sendmail test" | /usr/sbin/sendmail -v [email protected]

    can not write to queue directory /var/spool/mqueue-client/ (RunAsGid=115, required=0): Permission denied

    目录的权限为:

    $ ls -la /var/spool/mqueue-client drwxrwxr-x 2 root root 4096 Sep 15 2018 mqueue-client

因此,我显然存在某种权限/所有权问题,但考虑到第 1 项和第 2 项,我还认为还有其他问题。我需要能够从系统的 OSSEC 和 Fail2ban 接收电子邮件,因此如果没有可用的电子邮件客户端/服务器,我真的无法生存。我只是不确定如何解决这些问题。

我的 sendmail 只是用 进行安装$ sudo apt-get install sendmail sendmail-bin,所以它直接来自 Debian 的 repos,这就是为什么我对这些问题感到有点困惑......我认为所需的任何配置都将由安装过程处理。

编辑:输出ls -l /etc/alternatives/sendmail*

lrwxrwxrwx 1 root root 24 Jul 17 12:41 /etc/alternatives/sendmail -> /usr/lib/sm.bin/sendmail
lrwxrwxrwx 1 root root 42 Jul 17 12:41 /etc/alternatives/sendmail.8.gz -> /usr/share/man/man8/sendmail.sendmail.8.gz

lrwxrwxrwx 1 root root 24 Jul 17 12:41 /etc/alternatives/sendmail-msp -> /usr/lib/sm.bin/sendmail
lrwxrwxrwx 1 root root 42 Jul 17 12:41 /etc/alternatives/sendmail-msp.8.gz -> /usr/share/man/man8/sendmail.sendmail.8.gz

lrwxrwxrwx 1 root root 24 Jul 17 12:41 /etc/alternatives/sendmail-mta -> /usr/lib/sm.bin/sendmail
lrwxrwxrwx 1 root root 42 Jul 17 12:41 /etc/alternatives/sendmail-mta.8.gz -> /usr/share/man/man8/sendmail.sendmail.8.gz

每对都以不同的颜色结尾,例如/usr/lib/sm.bin/sendmail以琥珀色突出显示,而/usr/share/man/man8/sendmail.sendmail.8.gz以红色突出显示。每对的颜色相同 - 琥珀色和红色。

EDIT2:输出(echo subject: test; echo ; echo test) | /usr/sbin/sendmail -d44.4 -i -v username(我使用了我的真实用户名,但为了安全起见调整了结果输出):

$ (echo subject: test; echo ; echo test) | /usr/sbin/sendmail -d44.4 -i -v username
safefile(/etc/mail/submit.cf, uid=1000, gid=0, flags=6000, mode=400):
safedirpath(/etc/mail, uid=1000, gid=0, flags=6000, level=0, offset=0):
    [dir /etc/mail] OK
    [uid 0, nlink 1, stat 100644, mode 4]   OK
safefile(/etc/mail/relay-domains, uid=1000, gid=0, flags=6580, mode=400):
safedirpath(/etc/mail, uid=1000, gid=0, flags=6580, level=0, offset=0):
    [dir /etc/mail] OK
    No such file or directory
safefile(/etc/mail/service.switch, uid=1000, gid=115, flags=6480, mode=400):
safedirpath(/etc/mail, uid=1000, gid=115, flags=6580, level=0, offset=0):
    [dir /etc/mail] OK
    [uid 0, nlink 1, stat 100644, mode 4]   OK
safefile(/etc/mail/service.switch, uid=1000, gid=115, flags=6480, mode=400):
safedirpath(/etc/mail, uid=1000, gid=115, flags=6580, level=0, offset=0):
    [dir /etc/mail] OK
    [uid 0, nlink 1, stat 100644, mode 4]   OK
safefile( , uid=1000, gid=115, flags=40, mode=660):
safedirpath(., uid=1000, gid=115, flags=40, level=0, offset=0):
    [dir .] OK
    No such file or directory
    [final dir . uid 111 mode 42770] Success
safedirpath(/var/spool/mqueue-client, uid=1000, gid=115, flags=0, level=0, offset=0):
    [dir /var/spool/mqueue-client] OK
safefile(./dfx6MIGnM5005502, uid=1000, gid=115, flags=2040, mode=600):
safedirpath(., uid=1000, gid=115, flags=2040, level=0, offset=0):
    [dir .] OK
    No such file or directory
    [final dir . uid 111 mode 42770] Success
username... Connecting to [127.0.0.1] via relay...
220 major-productions.com ESMTP Sendmail 8.15.2/8.15.2/Debian-12; Mon, 22 Jul 2019 14:16:49 -0400; (No UCE/UBE) logging access from: localhost(OK)-localhost [127.0.0.1]
>>> EHLO major-productions.com
250-major-productions.com Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> VERB
250 2.0.0 Verbose mode
>>> MAIL From:<[email protected]> SIZE=20 [email protected]
250 2.1.0 <[email protected]>... Sender ok
>>> RCPT To:<[email protected]>
>>> DATA
250 2.1.5 <[email protected]>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
421 4.3.0 collect: Cannot write ./dfx6MIGnHm005503 (bfcommit, uid=0, gid=115): No such file or directory
>>> QUIT
username... Deferred: 421 4.3.0 collect: Cannot write ./dfx6MIGnHm005503 (bfcommit, uid=0, gid=115): No such file or directory
safefile(/var/lib/sendmail/sm-client.st, uid=1000, gid=115, flags=2282, mode=600):
safedirpath(/var/lib/sendmail, uid=1000, gid=115, flags=2282, level=0, offset=0):
    [dir /var/lib/sendmail] OK
    No such file or directory
safefile(/var/lib/sendmail/sm-client.st, uid=1000, gid=115, flags=2282, mode=600):
safedirpath(/var/lib/sendmail, uid=1000, gid=115, flags=2282, level=0, offset=0):
    [dir /var/lib/sendmail] OK
    No such file or directory
Closing connection to [127.0.0.1]

(echo subject: test; echo ; echo test) | /usr/sbin/sendmail -Am -d44.4 -i -v username编辑3:以root身份登录时的输出(用户名与之前一样模糊):

# (echo subject: test; echo ; echo test) | /usr/sbin/sendmail -Am -d44.4 -i -v username
safefile(/etc/mail/sendmail.cf, uid=0, gid=0, flags=6000, mode=400):
safedirpath(/etc/mail, uid=0, gid=0, flags=6000, level=0, offset=0):
    [dir /etc/mail] OK
    [uid 0, nlink 1, stat 100644, mode 400]     OK
safefile(/etc/mail/local-host-names, uid=0, gid=0, flags=6580, mode=400):
safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
    [dir /etc/mail] OK
    [uid 0, nlink 1, stat 100644, mode 400]     OK
safefile(/etc/mail/relay-domains, uid=0, gid=0, flags=6580, mode=400):
safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
    [dir /etc/mail] OK
    No such file or directory
safefile(/etc/mail/service.switch, uid=0, gid=0, flags=6480, mode=400):
safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
    [dir /etc/mail] OK
    [uid 0, nlink 1, stat 100644, mode 400]     OK
safefile(/etc/mail/service.switch, uid=0, gid=0, flags=6480, mode=400):
safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
    [dir /etc/mail] OK
    [uid 0, nlink 1, stat 100644, mode 400]     OK
safedirpath(/var/spool/mqueue, uid=0, gid=0, flags=4, level=0, offset=0):
    [dir /var/spool/mqueue] OK
safefile(/etc/mail/service.switch, uid=0, gid=0, flags=6480, mode=400):
safedirpath(/etc/mail, uid=0, gid=0, flags=6580, level=0, offset=0):
    [dir /etc/mail] OK
    [uid 0, nlink 1, stat 100644, mode 400]     OK
safefile(/etc/mail/aliases.db, uid=0, gid=0, flags=584, mode=400):
safedirpath(/etc/mail, uid=0, gid=0, flags=584, level=0, offset=0):
    [dir /etc/mail] OK
    [uid 110, nlink 1, stat 100640, mode 400]   OK
safedirpath(/home/username, uid=1000, gid=1000, flags=1985, level=0, offset=0):
    [dir /home/username] OK
safefile(/home/username/.forward.major-productions, uid=1000, gid=1000, flags=1895, mode=400):
    No such file or directory
safedirpath(/home/username, uid=1000, gid=1000, flags=1985, level=0, offset=0):
    [dir /home/username] OK
safefile(/home/username/.forward, uid=1000, gid=1000, flags=1895, mode=400):
    No such file or directory
safefile(./dfx6MKLN6r006080, uid=0, gid=0, flags=2040, mode=600):
safedirpath(., uid=0, gid=0, flags=2040, level=0, offset=0):
    [dir .] OK
    No such file or directory
    [final dir . uid 0 mode 40700] Success
username... Connecting to local...
safefile(/usr/sbin/sensible-mda, uid=0, gid=0, flags=41904, mode=0):
safedirpath(/usr/sbin, uid=0, gid=0, flags=41904, level=0, offset=0):
    [dir /usr/sbin] OK
    [uid 0, nlink 1, stat 104755, mode 0]   OK
username... Sent
safefile(/var/lib/sendmail/sendmail.st, uid=0, gid=0, flags=2282, mode=600):
safedirpath(/var/lib/sendmail, uid=0, gid=0, flags=2282, level=0, offset=0):
    [dir /var/lib/sendmail] OK
    No such file or directory
safefile(/var/lib/sendmail/sendmail.st, uid=0, gid=0, flags=2282, mode=600):
safedirpath(/var/lib/sendmail, uid=0, gid=0, flags=2282, level=0, offset=0):
    [dir /var/lib/sendmail] OK
    No such file or directory

答案1

  1. $ which sendmail不返回任何内容。

sendmail 不是安装在非特权用户' PATH=> 您观察到预期/正常的结果。 sendmail预计将由mail使用完整/绝对路径的其他程序执行。

  1. 无法写入队列目录 /var/spool/mqueue-client/ (RunAsGid=115, required=0): 权限被拒绝

修复/var/spool/mqueue-client权限和所有权

chown smmsp:smmsp /var/spool/mqueue-client`   
chmod 02770 /var/spool/mqueue-client`

现代 SENDMAIL 不需要设置安装SET ROOT ID

ls -l --dereference /usr/sbin/sendmail查看问题评论中的结果:
-r-sr-sr-t 1 root smmsp 860672 Sep 15 2018 /usr/sbin/sendmail

更改 Debian 中的最终目标/usr/sbin/sendmail/etc/alternatives链接的权限:

chmod u-s /usr/lib/sm.bin/sendmail

答案2

如果你运行这个,它会起作用吗:

echo "Subject: sendmail test" | sudo sendmail /usr/sbin/sendmail -v [email protected]

区别在于您以 root 身份运行 echo,而不是运行 sendmail。

因此出现以下消息:“(RunAsGid=115,required=0):权限被拒绝”

“115” 是用户的组 ID,其预期值为“0”(即根)

相关内容