Debian

將 linode 從 Debian 8 更新到穩定版後出現“無法寫入隊列目錄”錯誤和其他 sendmail 問題

  • July 25, 2019

我按照本教程將我的 linode 實例從 Debian 8 升級到了穩定版。在那次升級之後,我在 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 me@address.com我收到以下錯誤:

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 的儲存庫,這就是為什麼我對這些問題有點困惑……我認為安裝過程會處理所需的任何配置。

編輯:的輸出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:<username@major-productions.com> SIZE=20 AUTH=username@major-productions.com
250 2.1.0 <username@major-productions.com>... Sender ok
>>> RCPT To:<username@major-productions.com>
>>> DATA
250 2.1.5 <username@major-productions.com>... 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]

編輯 3:(echo subject: test; echo ; echo test) | /usr/sbin/sendmail -Am -d44.4 -i -v username以 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. $ which sendmail不返回任何東西。

sendmail 安裝在非特權使用者中PATH=> 您觀察到預期/正常結果。 sendmail預計將由mail使用完整/絕對路徑的其他程序執行。

  1. 無法寫入隊列目錄 /var/spool/mqueue-client/ (RunAsGid=115, required=0): Permission denied

修復/var/spool/mqueue-client權限和所有權

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

現代發送郵件不需要設置為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

引用自:https://serverfault.com/questions/975662