SELinux는 procmail이 dspam을 실행하지 못하도록 차단하지만 AVC 메시지는 없습니다.

SELinux는 procmail이 dspam을 실행하지 못하도록 차단하지만 AVC 메시지는 없습니다.

MTA로 postfix를 사용하는 CentOS 7 시스템이 있습니다. 특정 사용자는 .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를 허용 모드로 설정하면 제대로 작동합니다.

문제는 거부되는 항목에 대한 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;

관련 정보