ログ監視の権限が同じなのに「取得不可」となる
いつもお世話になっております。
ログ監視を行いたいのですが監視を行っている1つのサーバ(約20台中)で特定のファイルが監視できません。
【状況】
・「/etc/passwd」は取得できるが「/etc/shadow」が取得できない(権限は同じである)
・約20台監視していて1つのサーバだけで起こっている
【アイテム設定】
アイテムキー:vfs.file.cksum[/etc/shadow]
タイプ:Zabbixエージェント
【ファイル権限】
①取得できない(/etc/shadow)
-rw-r--r--. 1 root root 1360 6月 7 11:39 shadow
-rw-r--r--. 1 root root 1360 6月 7 11:39 shadow-
②取得できる(/etc/passwd)
-rw-r--r--. 1 root root 2476 6月 7 11:39 passwd
-rw-r--r--. 1 root root 2476 6月 7 11:39 passwd-
【エラー内容】
Webインターフェース内のエラー文
Cannot open file: [13] Permission denied
※zabbix-agentd.logにエラー文は確認できていません
同じ権限で片方のファイルだけが取得不可となっているため原因がわかっていません。
アドバイスを御願いいたします。
-------------サーバー情報(zabbix共通)-------------
zabbixバージョン2.4.7
サーバーOSCentOS release 6.7 (Final)
----------------------------------------------------
TNK - 投稿数: 4753
SELinuxの設定や/var/log/audit/audit.logなども確認してみてください。
RYT - 投稿数: 52
TNK様
すぐに確認ができない環境なので返答が遅くなりました。
申し訳ございません。
確認をとった結果は以下となります。
「/etc/shadow」監視ができないサーバ
①# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 28
②# cat /etc/selinux/config
SELINUX=enforcing
SELINUXTYPE=targeted
③# cat audit.log | grep shadow
type=AVC msg=audit(1465792280.056:341309): avc: denied { read } for pid=27359 comm="zabbix_agentd" name="shadow" dev="dm-0" ino=140274689 scontext=system_u:system_r:zabbix_agent_t:s0 tcontext=system_u:object_r:shadow_t:s0 tclass=file
「/etc/shadow」監視ができるサーバ
①# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
②# cat cat /etc/selinux/config
SELINUX=enforcing
SELINUXTYPE=targeted
③# cat audit.log | grep shadow
type=EXECVE msg=audit(1465792711.604:6529975): argc=2 a0="grep" a1="shadow"
また、この対象サーバで「/etc/secure」と「/etc/messages」も監視できないことがわかりました。
以上、ご教授よろしく御願いいたします。
TNK - 投稿数: 4753
ログに、
と出力されている通り、SELinuxでアクセスを制限されているので
監視できないのでしょう。
監視できているサーバと同様に、SELinuxの設定を調整してくださ
い。
/var/log/secure と /var/log/messages ですよね?
こちらも同様に/var/log/audit/audit.logにdeniedと記録されてい
ませんか?
RYT - 投稿数: 52
>と出力されている通り、SELinuxでアクセスを制限されているので
>監視できないのでしょう。
>監視できているサーバと同様に、SELinuxの設定を調整してくださ
>い。
了解いたしました。
SELinuxの設定を調整いたします。
>/var/log/secure と /var/log/messages ですよね?
>こちらも同様に/var/log/audit/audit.logにdeniedと記録されてい
>ませんか?
失礼いたしました。
TNK様のご指摘通りです。
おっしゃるとおり「denied」と出力されていました。
SELinuxの設定を調整いたします。
調整がうまくいったら報告いたします。
RYT - 投稿数: 52
確認したところ監視ができるできないサーバどちらもSELinuxはデフォルトの設定だそうです。
SELinux権限の設定をどのように設定しておけばZabbixで監視できるでしょうか?
ご教授御願いいたします。
TNK - 投稿数: 4753
特に設定を追加や変更していないのに監視できたりできなかったり
するのであれば、利用しているSELinuxのポリシーのバージョンが
異なるのだと思います。
RYTさんが利用されている環境のセキュリティポリシーや運用ルー
ルなどがわからないので、どのように設定すべきかは、これまでの
SELinuxなどのセキュリティポリシーなどを決められ運用されてき
た方々にご確認ください。
これまでのセキュリティポリシーとはまったく関係なく動けばいい
というレベルでよいのであれば、audit2allowなどを利用して、独
自のポリシーファイルを生成して読み込ませれば動かすことはでき
ると思います。
ご参考:
Zabbixでsyslog監視(CentOS 7編)
http://qiita.com/atanaka7/items/9c8736553262f64c03f6
Zabbix 3.0をCentOS 6上で動かす(インストール編)
http://qiita.com/atanaka7/items/389f796b221cc0609379
RYT - 投稿数: 52
TNK様
ご教示いただきありがとうございます。
まだ対応はできていませんが教えていただいた参考URLの情報で対応できそうです。
結果が出ましたら報告いたします。
RYT - 投稿数: 52
TNK様
ご教示いただきありがとうございます。
まだ対応はできていませんが教えていただいた参考URLの情報で対応できそうです。
結果が出ましたら報告いたします。
RYT - 投稿数: 52
お世話になっております。
遅くなりましたが、本件対応が完了しましたのでお知らせいたします。
以下が対応内容です。
①messagesログ内 エラー文確認
# cat messages | grep shadow
Jul 5 15:01:20 dsm501 audispd: node=dsm501.payment.itc.local type=AVC msg=audit(1467698480.157:15774): avc: denied { open } for pid=2756 comm="zabbix_agentd" path="/etc/shadow" dev="dm-0" ino=140274689 scontext=system_u:system_r:zabbix_agent_t:s0 tcontext=system_u:object_r:shadow_t:s0 tclass=file
Jul 5 15:01:26 dsm501 setroubleshoot: SELinux is preventing /usr/sbin/zabbix_agentd from open access on the file /etc/shadow. For complete SELinux messages. run sealert -l 13ec58cc-73f6-4edb-a3a9-3b15d97a29d9
Jul 5 15:01:26 dsm501 python: SELinux is preventing /usr/sbin/zabbix_agentd from open access on the file /etc/shadow.#012#012***** Plugin catchall (100. confidence) suggests **************************#012#012If you believe that zabbix_agentd should be allowed open access on the shadow 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 zabbix_agentd /var/log/audit/audit.log | audit2allow -M mypol#012# semodule -i mypol.pp#01
②コマンド対応(①内に記載されているコマンド)
# sealert -l 13ec58cc-73f6-4edb-a3a9-3b15d97a29d9
SELinux is preventing /usr/sbin/zabbix_agentd from open access on the file /etc/
***** Plugin catchall (100. confidence) suggests **************************
If zabbix_agentd に、 shadow file の open アクセスがデフォルトで許可されるべきで
Then バグとして報告してください。
ローカルのポリシーモジュールを生成すると、
このアクセスを許可することができます。
Do
このアクセスを一時的に許可するには、以下を実行してください。
# grep zabbix_agentd /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp
Additional Information:
Source Context system_u:system_r:zabbix_agent_t:s0
Target Context system_u:object_r:shadow_t:s0
Target Objects /etc/shadow [ file ]
Source zabbix_agentd
Source Path /usr/sbin/zabbix_agentd
Port
Host dsm501.payment.itc.local
Source RPM Packages zabbix-agent-2.4.7-1.el7.x86_64
Target RPM Packages setup-2.8.71-6.el7.noarch
Policy RPM selinux-policy-3.13.1-60.el7_2.3.noarch
Selinux Enabled True
Policy Type targeted
Enforcing Mode Enforcing
Host Name dsm501.payment.itc.local
Platform Linux dsm501.payment.itc.local
3.10.0-327.13.1.el7.x86_64 #1 SMP Thu Mar 31
16:04:38 UTC 2016 x86_64 x86_64
Alert Count 727
First Seen 2016-06-27 14:11:20 JST
Last Seen 2016-07-07 16:21:20 JST
Local ID 13ec58cc-73f6-4edb-a3a9-3b15d97a29d9
Raw Audit Messages
type=AVC msg=audit(1467876080.684:42354): avc: denied { open } for pid=2754 cm-0" ino=140274689 scontext=system_u:system_r:zabbix_agent_t:s0 tcontext=system_
type=SYSCALL msg=audit(1467876080.684:42354): arch=x86_64 syscall=open success=n items=0 ppid=2750 pid=2754 auid=4294967295 uid=987 gid=982 euid=987 suid=987 fs) ses=4294967295 comm=zabbix_agentd exe=/usr/sbin/zabbix_agentd subj=system_u:sy
Hash: zabbix_agentd,zabbix_agent_t,shadow_t,file,open
③コマンド対応(②に記載されているコマンド)
# grep zabbix_agentd /var/log/audit/audit.log | audit2allow -M
******************** IMPORTANT ***********************
To make this policy package active, execute:
semodule -i mypol.pp
# semodule -i mypol.pp
ご教示ありがとうございました。