SELinux が procmail による dspam の実行をブロックしているが、AVC メッセージは表示されない

SELinux が procmail による dspam の実行をブロックしているが、AVC メッセージは表示されない

私は CentOS 7 システムを使用しており、MTA として postfix を使用しています。一部のユーザーは、.forwardホーム ディレクトリで procmail を使用しています。

# 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 を permissive モードに設定すると正常に動作します。

問題は、拒否されている内容に関する 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

そこで、Chris Bennett の回答を見て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;

関連情報