CPC中文印刷社区

返回   CPC中文印刷社区 > Blog > 我这慢慢的一生何求?
注册账号 招聘 FTP Blog 论坛帮助 会员列表 日历事件 搜索 今日新帖 标记讨论区已读

为这篇文章评分

SELinux 的 audit2allow 工具程式

发表于 2007-10-13 15:14 作者: wangyu1314
wangyu1314 更新于 2007-10-13 17:09
http://blog.candyz.org/20060509/1168

The command audit2allow can receive input via three methods. Default is from standard input (STDIN). Using the -i option reads input from /var/log/messages, and the -d option reads input from dmesg output.
也就是說 audit2allow 有三種接收輸入的方法:
1.預設是由標準輸入 STDIN 接收
2.使用 -i 選項,如 -i /var/log/messages or -i /var/log/audit/audit.log (若有啟動 auditd 時)
3.使用 -d 選項,可以接收 dmesg 的訊息
例如:
[root@candyz:/var/log] audit2allow -i /var/log/messages
allow getty_t var_log_t:file write;
[root@candyz:/var/log] audit2allow -d
allow getty_t var_log_t:file write;
當看到一堆如下的 avc denied 之類的訊息時,要怎麼解決?
audit(1146842928.277:2): avc: denied { getattr } for pid=3357 comm="httpd"
name="test.php" dev=hda6 ino=137349 scontext=root:system_r:httpd_t
tcontext=root:object_r:var_t tclass=file
* 在 RHEL4 或 FC3 上的解決方式:
$ cd /etc/selinux/targeted/src/policy/
使用 -d 從 dmesg 讀取 avc messages
$ audit2allow -d -o domain/misc/local.te
or 使用 -l -i /var/log/messages 讀取 /var/log/messages 的 avc messages
# 若有啟動 auditd 則要改讀 /var/log/audit/audit.log
$ audit2allow -l -i /var/log/messages -o domain/misc/local.te
or 直接從 STDIN 讀取 avc messages, 如 /tmp/avcs 裡面放的就是儲存好的 avc messages
$ audit2allow -o domain/misc/local.te < /tmp/avcs
最後再執行 make load 即可
$ make load
然後就會看到如 avc granted 之類的訊息了
* 在 FC5 上的解決方式:
[root@candyz:~] cd /etc/selinux/targeted/modules/
[root@candyz:/etc/selinux/targeted/modules] audit2allow -M local -d
Generating type enforcment file: local.te
Compiling policy
checkmodule -M -m -o local.mod local.te
semodule_package -o local.pp -m local.mod

******************** IMPORTANT ***********************

In order to load this newly created policy package into the kernel,
you are required to execute

semodule -i local.pp
同樣的,除了用 audit2allow -M local -d 從 dmesg 讀取訊息外
也可以用 audit2allow -M local -l -i /var/log/messages
或是 audit2allow -M local -i /var/log/audit/audit.log
或是 audit2allow -M local < /tmp/avcs
最後記得要執行 semodule -i local.pp 來 load new policy to kernel,這點很重要
[root@candyz:/etc/selinux/targeted/modules] semodule -i local.pp

另外也可以用 audit2allow 來產生 local.te 檔案,然後可以去編輯或修改 local.te
[root@candyz:~] cd /etc/selinux/targeted/modules/
[root@candyz:/etc/selinux/targeted/modules] audit2allow -m local -l -i /var/log/messages > local.te

# 然後再執行 checkmodule 指令來產生 local.mod

[root@candyz:/etc/selinux/targeted/modules] checkmodule -M -m -o local.mod local.te

# 然後再執行 semodule_package 指令來產生 local.pp

[root@candyz:/etc/selinux/targeted/modules] semodule_package -o local.pp -m local.mod

同樣的,最後記得要執行 semodule -i local.pp 來 load new policy to kernel,這點很重要

[root@candyz:/etc/selinux/targeted/modules] semodule -i local.pp

或是產生 local.te 檔後,直接執行:

[root@candyz:/etc/selinux/targeted/modules] make -f /usr/share/selinux/devel/Makefile

這樣等於是執行 checkmodule + semodule_package

最後記得再 semodule -i local.pp 即可
发表在 Linux
评论 0 Email文章
评论总数 0

评论

 

所有时间均为北京时间。现在的时间是 2009-07-03 07:00

[感谢所有支持CPC的朋友们和CPC的历任版主,点击此处查看版主名单]
本站所有资源均由网友自由上传发布,不代表中文印刷社区支持或认可其态度。如果出现侵犯版权资源,请权利人与我们联系,确认后我们将删除相关内容。
渝ICP备05004292号  渝公网备500105015-00104

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
CPC中文印刷社区全体会员拥有版权,欢迎转载,转载请注明出处!