升級系統後又遇到一樣的問題,給AI教了一個簡單的檢查方式和修正。
8月 02 18:08:26 spamd[301829]: razor2: razor2 check failed: Permission denied razor2: Can’t read conf file: /etc/spamassassin/razor/razor-agent.conf at /usr/share/perl5/Mail/SpamAssassin/Plugin/Razor2.pm line 350.
#nano -l /usr/share/perl5/Mail/SpamAssassin/Plugin/Razor2.pm
339
340 if ($err) {
341 chomp $err;
342 if ($err =~ /(?:could not connect|network is unreachable)/) {
343 # make this a dbg(); SpamAssassin will still continue,
344 # but without Razor checking. otherwise there may be
345 # DSNs and errors in syslog etc., yuck
346 dbg("$debug: razor2 $type could not connect to any servers");
347 } elsif ($err =~ /timeout/i) {
348 dbg("$debug: razor2 $type timed out connecting to servers");
349 } else {
350 warn("$debug: razor2 $type failed: $! $err");
351 }
352 }
353
354 # razor also debugs to stdout. argh. fix it to stderr...
355 if (would_log('dbg', $debug)) {
356 open(STDOUT, ">&OLDOUT");
357 close OLDOUT;
358 }
檢查這裡:
# ps aux | grep spamd
root 301824 1.5 0.9 197716 148708 ? Ss 18:08 0:01 /usr/bin/perl -T -w /usr/sbin/spamd –pidfile=/run/spamd.pid –create-prefs –max-children 5 –helper-home-dir
root 301843 0.0 0.8 197716 136216 ? S 18:08 0:00 spamd child
root 301844 0.0 0.8 197716 136216 ? S 18:08 0:00 spamd child
# ls -l /etc/spamassassin/razor/razor-agent.conf
-rw-r—– 1 root root 706 2月 17 20:33 /etc/spamassassin/razor/razor-agent.conf
spamd 是由 root 使用者啟動,root 理論上擁有對所有檔案的最高權限,但這通常是啟動程序的方式。SpamAssassin 服務為了安全考量,在啟動後會自動降級到一個較低權限的使用者來執行子程序(spamd child)。
這個使用者可能叫做 spamd、debian-spamd 或其他名稱。在您的日誌中,錯誤訊息來自於子程序,這表示子程序嘗試讀取設定檔時被拒絕了(檔案是706狀態)。
# 讓所有使用者都可以進入這個目錄
sudo chmod 755 /etc/spamassassin/razor/
# 讓所有使用者都可以讀取 razor-agent.conf 檔案
sudo chmod 644 /etc/spamassassin/razor/razor-agent.conf
#讓 spamd 服務重新載入設定。
sudo systemctl restart spamd.service
#重新啟動後,再檢查日誌。這次應該就不會再看到 Permission denied 的錯誤訊息了。
sudo journalctl -u spamd.service –since “1 minute ago”