CentOS 7
Ads

SELinux : Use SETroubleShoot
2016/04/05
 
To use SETroubleShoot, it's possible to generate additional logs for solving some troubles.
[1]
Messages from SETroubleShoot are sent by Audit Event Dispatcher to /var/log/messages.
So it needs to run Auditd, refer to here.
[2] Install setroubleshoot-server. And Configure some settings for using sealert command.
[root@dlp ~]#
yum -y install setroubleshoot-server
[root@dlp ~]#
vi /etc/tmpfiles.d/setroubleshoot.conf
# create new

D /var/run/setroubleshoot 0755 setroubleshoot root -
[root@dlp ~]#
mkdir --context=system_u:object_r:setroubleshoot_var_run_t:s0 /var/run/setroubleshoot

[root@dlp ~]#
chown setroubleshoot:root /var/run/setroubleshoot

[root@dlp ~]#
chmod 755 /var/run/setroubleshoot

[root@dlp ~]#
service auditd restart

[root@dlp ~]#
systemctl restart dbus

[3] It's OK all, additional logs for AVC denial are output to /var/log/messages like follows.
[root@dlp ~]#
grep -E 'setroubleshoot|preventing' /var/log/messages

Apr  3 19:33:41 dlp setroubleshoot: failed to retrieve rpm info for /var/www/html/index.html
Apr  3 19:33:41 dlp setroubleshoot: SELinux is preventing /usr/sbin/httpd from getattr access 
                on the file /var/www/html/index.html. For complete SELinux messages. 
                run sealert -l 84495686-3c5c-411f-9fb7-bb396ac49c1d
Apr  3 19:33:41 dlp python: SELinux is preventing /usr/sbin/httpd from getattr access on the file /var/www/html/index.html.
                #012#012*****  Plugin restorecon (99.5 confidence) suggests   ************************#012#012
                If you want to fix the label. #012/var/www/html/index.html default label should be httpd_sys_content_t.
                #012Then you can run restorecon.#012Do#012# /sbin/restorecon -v /var/www/html/index.html#012#012*****  
                Plugin catchall (1.49 confidence) suggests   **************************#012#012If you believe that 
                httpd should be allowed getattr access on the index.html file by default.#012Then you should report 
                this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access 
                for now by executing:#012# grep httpd /var/log/audit/audit.log | audit2allow -M mypol#012# 
                semodule -i mypol.pp#012
[4] For 4the line on the example above, a command is given to see more details and it displays logs like follows.
[root@dlp ~]#
sealert -l 84495686-3c5c-411f-9fb7-bb396ac49c1d

SELinux is preventing /usr/sbin/httpd from getattr access on the file /var/www/html/index.html.

*****  Plugin restorecon (99.5 confidence) suggests   ************************

If you want to fix the label.
/var/www/html/index.html default label should be httpd_sys_content_t.
Then you can run restorecon.
Do
# /sbin/restorecon -v /var/www/html/index.html

*****  Plugin catchall (1.49 confidence) suggests   **************************

If you believe that httpd should be allowed getattr access on the index.html file 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:
# grep httpd /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp


Additional Information:
Source Context            system_u:system_r:httpd_t:s0
Target Context            unconfined_u:object_r:admin_home_t:s0
Target Objects            /var/www/html/index.html [ file ]
Source                    httpd
Source Path               /usr/sbin/httpd
Port                      <Unknown>
Host                      dlp.srv.world
Source RPM Packages       httpd-2.4.6-40.el7.centos.x86_64
Target RPM Packages
Policy RPM                selinux-policy-3.13.1-60.el7_2.3.noarch
Selinux Enabled           True
Policy Type               targeted
Enforcing Mode            Enforcing
Host Name                 dlp.srv.world
Platform                  Linux dlp.srv.world 3.10.0-327.10.1.el7.x86_64
                          #1 SMP Tue Feb 16 17:03:50 UTC 2016 x86_64 x86_64
Alert Count               3
First Seen                2016-04-03 19:11:23 JST
Last Seen                 2016-04-03 19:33:40 JST
Local ID                  84495686-3c5c-411f-9fb7-bb396ac49c1d

Raw Audit Messages
type=AVC msg=audit(1459845220.621:57): avc:  denied  { getattr } for  pid=847 comm="httpd" 
    path="/var/www/html/index.html" dev="dm-0" ino=101186198 scontext=system_u:system_r:httpd_t:s0 
    tcontext=unconfined_u:object_r:admin_home_t:s0 tclass=file


type=SYSCALL msg=audit(1459845220.621:57): arch=x86_64 syscall=lstat success=no exit=EACCES a0=7fb4dab46f70 
    a1=7fff43babe90 a2=7fff43babe90 a3=0 items=0 ppid=822 pid=847 auid=4294967295 uid=48 gid=48 euid=48 
    suid=48 fsuid=48 egid=48 sgid=48 fsgid=48 tty=(none) ses=4294967295 comm=httpd exe=/usr/sbin/httpd 
    subj=system_u:system_r:httpd_t:s0 key=(null)

Hash: httpd,httpd_t,admin_home_t,file,getattr
 
Tweet