我有一個 CentOS 7 系統,其中我使用 postfix 作為 MTA。某些使用者.forward
在其主目錄中使用 procmail via:
# cat .forward
"|exec /usr/bin/procmail -f- || exit 75"
在這種情況下,我很難弄清楚為什麼 SELinux 不允許 procmail 從以下位置執行 dspam .procmailrc
:
:0fw: dspam.lock
| /usr/bin/dspam --client --stdout --deliver=spam,innocent
在 procmail 日誌中我得到:
procmail: Locking "dspam.lock"
procmail: Executing "/usr/bin/dspam,--client,--stdout,--deliver=spam,innocent"
/bin/sh: /usr/bin/dspam: Permission denied
procmail: Program failure (126) of "/usr/bin/dspam"
procmail: Rescue of unfiltered data succeeded
procmail: Unlocking "dspam.lock"
但是,如果我將 SELinux 設定為寬容模式,它就可以正常工作。
問題是它沒有記錄任何有關被拒絕的 AVC 訊息。當我第一次設定時,我透過 和 發現了一些差距audit2why
並ausearch
修復了它們。現在我什麼也沒得到,儘管顯然是 SELinux 阻止了它的工作。
編輯:這是 dspam 二進位:
# ls -lZ /usr/bin/dspam
-r-x--s--x. dspam mail system_u:object_r:dspam_exec_t:s0 /usr/bin/dspam
答案1
我有一個非常相似的問題。就我而言,selinux 悄悄地阻止 .procmailbin 資料夾中的程式碼執行(我已經將 .procmailbin 的預設上下文設為 procmail_exec_t)。
我還沒有完全解決這個問題,但我相信答案的方法是指示 selinux 報告全部否認,確實如此不是預設執行。
若要啟用所有拒絕的完整報告,請使用以下命令:
semodule --disable_dontaudit --build
查看audit.log並根據需要使用sealert來確定發生了什麼。
然後使用完成後恢復正常:
semodule --build
祝你好運!就我而言,我正處於 sealert 向我顯示之前未出現過的訊息的位置:
SELinux is preventing sh from search access on the directory /home/chris/.procmailbin.
***** Plugin catchall (100. confidence) suggests **************************
If you believe that sh should be allowed search access on the .procmailbin directory by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'sh' --raw | audit2allow -M my-sh
# semodule -X 300 -i my-sh.pp
……但我仍然需要檢查這是否是實際問題以及最佳解決方案是什麼。
更新:所以,事實證明這為我解決了這個問題。
以下是我建立的自訂模組的內容:
# more procmailbin-sh-search.te
module my-sh 1.0;
require {
type dmesg_t;
type procmail_t;
type procmail_exec_t;
type abrt_t;
class dir search;
class process noatsecure;
}
#============= abrt_t ==============
allow abrt_t dmesg_t:process noatsecure;
#============= procmail_t ==============
allow procmail_t procmail_exec_t:dir search;
在我看來,這應該是預設行為,所以我想我會看看是否能找出向誰報告這個「錯誤」。
答案2
因此,在查看克里斯貝內特的答案後,我使用semodule --disable_dontaudit
並能夠弄清楚我需要什麼。這是我最終使 postfix+procmail+dspam 工作的結果:
require {
type dspam_rw_content_t;
type dspam_t;
type dspam_exec_t;
type procmail_t;
class dir { open read write getattr add_name search };
class file { append getattr lock open read write setgid };
class unix_stream_socket connectto;
}
#============= dspam_t ==============
allow dspam_t dspam_rw_content_t:dir { open read write getattr add_name search };
allow dspam_t dspam_rw_content_t:file { append getattr lock open write };
#============= procmail_t ==============
allow procmail_t dspam_exec_t:file { open read setgid };
allow procmail_t dspam_t:unix_stream_socket connectto;