[转] AppArmor

时间:2014-07-03 11:03:07   收藏:0   阅读:303

AppArmor

https://help.ubuntu.com/14.04/serverguide/apparmor.html

AppArmor 是一个实施了基于名称强制存取控制的Linux安全模组。AppArmor 界定了单个程序进入一组文件列表的权限并遵循posix 1003.1e 草稿的能力。

默认情况下AppArmor已安装并载入。它使用每个程序的profiles来确定这个程序需要什么文件和权限。有些包会安装它们自己的profiles,额外的profiles可以在apparmor-profiles包里找到。

要安装apparmor-profiles软件包,在终端输入:

sudo apt-get install apparmor-profiles

AppArmor配置文件有两种执行模式:

使用 AppArmor

apparmor-utils软件包包含一些命令行工具,使用它们您可以更改AppArmor的执行模式、查看配置文件的状态、创建新的配置文件等等。

用你操作的profile名称来替代profile.name。再有,用实际的执行文件的路径来代替/path/to/bin/。例如,使用/bin/ping来替代ping

配置文件

AppArmor profiles are simple text files located in /etc/apparmor.d/. The files are named after the full path to the executable they profile replacing the "/" with ".". For example /etc/apparmor.d/bin.ping is the AppArmor profile for the /bin/ping command.

在配置文件中,主要有两种类型的规则

作为一个例子来看看/etc/apparmor.d/bin.ping:

#include <tunables/global>
/bin/ping flags=(complain) {
  #include <abstractions/base>
  #include <abstractions/consoles>
  #include <abstractions/nameservice>

  capability net_raw,
  capability setuid,
  network inet raw,
  
  /bin/ping mixr,
  /etc/modules.conf r,
}

编辑配置文件后必须重新载入配置文件。参看使用 AppArmor 获取详情

创建配置文件
更新配置文件

When the program is misbehaving, audit messages are sent to the log files. The program aa-logprof can be used to scan log files for AppArmor audit messages, review them and update the profiles. From a terminal:

sudo aa-logprof

参考资料

[转] AppArmor,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!