当前位置:   article > 正文

[SeLinux]audit2allow安装与使用

audit2allow安装

audit2allow的安装

sudo apt install policycoreutils

或者

将Android 源码目录下external/selinux/python/audit2allow/audit2allow copy到/usr/bin/

audit2allow的用法

1.抓log并保存至文件:

adb logcat -b all  > error_log.txt

2.分析SeLinux问题的log:

audit2allow -i error_log.txt

有些系统在执行audit2allow时会出现错误“unable to open (null):  Bad address”

有两个方法可以规避这个问题:

2.1 sudo vim  /usr/bin/audit2allow

        注释掉如下4行代码,这个错误是因为执行audit2why.init()导致的,具体原因不详。

  1. def main(self):
  2. try:
  3. self.__parse_options()
  4. # if self.__options.policy:
  5. # audit2why.init(self.__options.policy)
  6. # else:
  7. # audit2why.init()

2.2 加-p参数  从audit2allow的help信息看 , -p需要指定一个policy文件

  1. Usage: audit2allow [options]
  2. Options:
  3. --version show program's version number and exit
  4. -h, --help show this help message and exit
  5. -b, --boot audit messages since last boot conflicts with -i
  6. -a, --all read input from audit log - conflicts with -i
  7. -p POLICY, --policy=POLICY
  8. Policy file to use for analysis
  9. -d, --dmesg read input from dmesg - conflicts with --all and
  10. --input
  11. -i INPUT, --input=INPUT
  12. read input from <input> - conflicts with -a
  13. -l, --lastreload read input only after the last reload
  14. -r, --requires generate require statements for rules
  15. -m MODULE, --module=MODULE
  16. set the module name - implies --requires
  17. -M MODULE_PACKAGE, --module-package=MODULE_PACKAGE
  18. generate a module package - conflicts with -o and -m
  19. -o OUTPUT, --output=OUTPUT
  20. append output to <filename>, conflicts with -M
  21. -D, --dontaudit generate policy with dontaudit rules
  22. -R, --reference generate refpolicy style output
  23. -N, --noreference do not generate refpolicy style output
  24. -v, --verbose explain generated output
  25. -e, --explain fully explain generated output
  26. -t TYPE, --type=TYPE only process messages with a type that matches this
  27. regex
  28. --perm-map=PERM_MAP file name of perm map
  29. --interface-info=INTERFACE_INFO
  30. file name of interface information
  31. --debug leave generated modules for -M
  32. -w, --why Translates SELinux audit messages into a description
  33. of why the access was denied

Android代码一般会在out中生成,可以在out目录下find一下,例如:

  1. R4250-dev$ find out/target/product/ -name sepolicy
  2. out/target/product/<project_name>/recovery/root/sepolicy

综合来看,如果不常用audit2why这个功能的话,方案2.1比较方便些,一劳永逸。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/49557?site
推荐阅读
相关标签
  

闽ICP备14008679号