dovecot imapc Proxy mit Selinux unter Centos 7

Alex JOST jost+lists at dimejo.at
Fr Dez 1 11:01:07 CET 2017


Am 30.11.2017 um 13:05 schrieb tom:
> Hi,
> 
> habe auf einem Centos 7 nach dem HowTo von
> https://wiki.dovecot.org/HowTo/ImapcProxy den imapc Proxy
> eingerichtet. Soweit geht auch alles, aber nur mit deaktivierten
> selinux. Weis nicht, ob das hier jetzt jemand schon mal ans Laufen
> gebracht hat, weil nach dem empfohlenen "setsebool -P nis_enabled 1"
> habe ich keine Einträge mehr im audit.log mit dem ich am selinux
> weitersuchen kann.
> 
> 
> # dovecot start mit out-of-the-box Centos standard selinux:
> 
> # dazu im maillog:
> Nov 30 12:37:10 testclient dovecot: master: Error: bind(0.0.0.0,
> 12345) failed: Permission denied
> Nov 30 12:37:10 testclient dovecot: master: Error: service(auth):
> listen(*, 12345) failed: Permission denied
> Nov 30 12:37:10 testclient dovecot: master: Error: bind(::, 12345)
> failed: Permission denied
> Nov 30 12:37:10 testclient dovecot: master: Error: service(auth):
> listen(::, 12345) failed: Permission denied
> Nov 30 12:37:10 testclient dovecot: master: Fatal: Failed to start listeners
> 
> # im audit.log
> type=SERVICE_START msg=audit(1512042125.795:252): pid=1 uid=0
> auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0
> msg='unit=dovecot comm="systemd" exe="/usr/lib/systemd/systemd"
> hostname=? addr=? terminal=? res=success'
> type=AVC msg=audit(1512042125.813:253): avc:  denied  { name_bind }
> for  pid=2111 comm="dovecot" src=12345
> scontext=system_u:system_r:dovecot_t:s0
> tcontext=system_u:object_r:unreserved_port_t:s0 tclass=tcp_socket
> type=SYSCALL msg=audit(1512042125.813:253): arch=c000003e syscall=49
> success=no exit=-13 a0=2e a1=7ffc0113aae0 a2=10 a3=7ffc0113aad8
> items=0 ppid=1 pid=2111 auid=4294967295 uid=0 gid=0 euid=0 suid=0
> fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="dovecot"
> exe="/usr/sbin/dovecot" subj=system_u:system_r:dovecot_t:s0 key=(null)
> type=PROCTITLE msg=audit(1512042125.813:253):
> proctitle=2F7573722F7362696E2F646F7665636F74002D46
> type=AVC msg=audit(1512042125.813:254): avc:  denied  { name_bind }
> for  pid=2111 comm="dovecot" src=12345
> scontext=system_u:system_r:dovecot_t:s0
> tcontext=system_u:object_r:unreserved_port_t:s0 tclass=tcp_socket
> type=SYSCALL msg=audit(1512042125.813:254): arch=c000003e syscall=49
> success=no exit=-13 a0=2e a1=7ffc0113aae0 a2=1c a3=7ffc0113aad8
> items=0 ppid=1 pid=2111 auid=4294967295 uid=0 gid=0 euid=0 suid=0
> fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="dovecot"
> exe="/usr/sbin/dovecot" subj=system_u:system_r:dovecot_t:s0 key=(null)
> type=PROCTITLE msg=audit(1512042125.813:254):
> proctitle=2F7573722F7362696E2F646F7665636F74002D46
> type=SERVICE_STOP msg=audit(1512042125.823:255): pid=1 uid=0
> auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0
> msg='unit=dovecot comm="systemd" exe="/usr/lib/systemd/systemd"
> hostname=? addr=? terminal=? res=failed'
> 
> 
> [root at testclient ~]# audit2allow -w -a
> type=AVC msg=audit(1512041830.570:105): avc:  denied  { name_bind }
> for  pid=1212 comm="dovecot" src=12345
> scontext=system_u:system_r:dovecot_t:s0
> tcontext=system_u:object_r:unreserved_port_t:s0 tclass=tcp_socket
>          Was caused by:
>          The boolean nis_enabled was set incorrectly.
>          Description:
>          Allow nis to enabled
> 
>          Allow access by executing:
>          # setsebool -P nis_enabled 1
> 
> 
> # der Empfehlung folgend nis_enabled = 1 setzen:
> [root at testclient ~]# setsebool -P nis_enabled 1
> [root at testclient ~]#
> 
> 
> # dovecot start nach "nis_enabled 1", die Meldungen sind weg und Port
> wird gebunden:
> 
> [root at testclient ~]# netstat -anp|grep 12345
> tcp        0      0 0.0.0.0:12345           0.0.0.0:*
> LISTEN      2202/dovecot
> tcp6       0      0 :::12345                :::*
> LISTEN      2202/dovecot
> 
> # maillog - alles bestens:
> Nov 30 12:47:00 testclient dovecot: master: Dovecot v2.2.10 starting
> up for imap (core dumps disabled)
> 
> # audit.log sieht auch OK aus:
> type=SERVICE_START msg=audit(1512042420.304:260): pid=1 uid=0
> auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0
> msg='unit=dovecot comm="systemd" exe="/usr/lib/systemd/systemd"
> hostname=? addr=? terminal=? res=success'
> 
> 
> # 1. loginversuch scheitert sofort:
> openssl s_client -connect 10.100.102.173:143 -starttls imap
> 
> CONNECTED(00000003)
> didn't found STARTTLS in server response, try anyway...
> 140151224759952:error:140790E5:SSL routines:ssl23_write:ssl handshake
> failure:s23_lib.c:177:
> 
> # dazu im maillog:
> Nov 30 12:47:00 testclient dovecot: master: Dovecot v2.2.10 starting
> up for imap (core dumps disabled)
> Nov 30 12:47:46 testclient dovecot: auth: Fatal: epoll_ctl(add, 13)
> failed: Operation not permitted (fd doesn't support epoll)
> Nov 30 12:47:46 testclient dovecot: master: Error: service(auth):
> command startup failed, throttling for 2 secs
> Nov 30 12:47:46 testclient dovecot: imap-login: Disconnected: Auth
> process broken (disconnected before auth was ready, waited 0 secs):
> user=<>, rip=10.100.105.2, lip=10.100.102.173,
> session=<eQcb0jFfqgAKZGkC>
> 
> 
> # im audit.log wird beim 1. Login Versuch nichts protokolliert!!!!!
> 
> # selinux in permissive Modus setzen:
> [root at testclient ~]# setenforce 0
> 
> # liefert sofort im audit.log:
> type=AVC msg=audit(1512042724.363:271): avc:  denied  { getattr } for
> pid=2281 comm="auth" lport=12345
> scontext=system_u:system_r:dovecot_auth_t:s0
> tcontext=system_u:system_r:dovecot_t:s0 tclass=tcp_socket
> type=SYSCALL msg=audit(1512042724.363:271): arch=c000003e syscall=51
> success=yes exit=0 a0=d a1=7ffcd4468e40 a2=7ffcd4468e3c a3=3 items=0
> ppid=2202 pid=2281 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0
> egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="auth"
> exe="/usr/libexec/dovecot/auth"
> subj=system_u:system_r:dovecot_auth_t:s0 key=(null)
> type=PROCTITLE msg=audit(1512042724.363:271): proctitle="dovecot/auth"
> 
> 
> 
> # 2. Loginversuch:
> openssl s_client -connect 10.100.102.173:143 -starttls imap
> CONNECTED(00000003)
> 01 LOGIN foo at bar.com xxxxxx
> * CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE
> SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT
> MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS
> LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES
> WITHIN CONTEXT=SEARCH LIST-STATUS SPECIAL-USE BINARY MOVE
> 01 OK Logged in
> 
> # maillog
> Nov 30 12:53:56 testclient dovecot: imap-login: Login:
> user=<foo at bar.com>, method=PLAIN, rip=10.100.105.2,
> lip=10.100.102.173, mpid=2306, TLS, session=<ZZsl6DFfAAAKZGkC>
> Nov 30 12:54:03 testclient dovecot: imap(foo at bar.com): Connection
> closed in=5 out=405
> 
> 
> 
> Ich komme irgendwie gerade nicht mehr weiter und bin für jeden Tipp dankbar!

Wahrscheinlich ist für die Regel ein 'dontaudit' gesetzt, wodurch es 
nicht im Log auf scheint. Vielleicht hilft Dir dieser Link weiter:

 
https://wiki.gentoo.org/wiki/SELinux/Tutorials/Where_to_find_SELinux_permission_denial_details#Hidden_denials

-- 
Alex JOST


Mehr Informationen über die Mailingliste Dovecot