SELinux 的 audit2allow 工具程式
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 即可
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 即可
评论总数 0
评论
作者为 wangyu1314 的最新文章
- vBSEO.v3.2.0.PHP.NULL-Draxofavalon (2008-07-17)
- rhel 5.2 安装码 (2008-06-04)
- RHEL5.2 32位,64位,原码,扩展盘下载 (2008-05-25)
- Mssql 2005 集成SP2的简体中文企业版本 (2008-04-24)
- RHEL 5.1 DVD 、RHEL 4.6 DVD 下载地址 (2008-04-10)




