SELinux : SETroubleShootを利用する2016/07/26 |
|
SELinux による AVC 拒否のログは リンク先のように、ログファイルの直接参照
または ツール経由でのレポート出力により確認可能ですが、SETroubleShoot
を利用すると、問題解決に有用なログを追加出力することができます。
|
|
| [1] |
SETroubleShoot のメッセージは Audit イベント ディスパッチャーによって /var/log/messages に送信されます。
よって、こちらを参考に Auditd を起動しておく必要があります。 |
| [2] | setroubleshoot-server パッケージをインストールしておきます。 |
|
[root@dlp ~]#
[root@dlp ~]# yum -y install setroubleshoot-server service auditd restart [root@dlp ~]# service messagebus restart |
| [3] |
以上により AVC 拒否が発生した場合は /var/log/messages に以下のようなログが記録されます。
下例の場合、5行目から推測される原因と対策が 2パターン記載されており、可能性のより高いとされている方は、/var/www/html/index.html
にデフォルトのラベルである httpd_sys_content_t を割り当てれば問題解決するのでは?
その解決方法であれば「/sbin/restorecon -v /var/www/html/index.html」とコマンド投入すれば
OK です、といった旨が記載されています。ちなみにこの例の場合は、この可能性が高いとされている方の提案通りの対策で解決します。
|
|
[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] | なお、上記ログの例 4行目には、より詳細な情報を出力可能なコマンドが記載されているため、コピペしてその通りにコマンドを投入すると以下のように内容が確認できます。 原因と対策の内容については /var/log/messages に記載してある内容と同じですが、より詳細により読みやすく表示されます。 |
|
[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
|
| Sponsored Link |
|
|