android-te文件语法

te文件语法

type: 用于定义一个 SELinux 类型,语法为 type <typename>, <sensitivity>;
typeattribute: 用于定义类型属性,语法为 typeattribute <typename> <attribute1,attribute2...>;
typealias: 用于定义类型别名,语法为 typealias <aliasname>, <realname>;
common: 用于定义共享属性,语法为 common <typename>;
allow: 用于定义允许访问的规则,语法为 allow <sourcetype> <targettype>:<class> { permissions };
	根据selinux提示的权限报错,添加对应权限,log格式:
		avc: denied  { 操作权限  }  for pid=7201  comm=“进程名”  scontext=u:r:源类型:s0  tcontext=u:r:目标类型:s0  tclass=访问类型 permissive=0
	规则格式:
		allow  源类型 目标类型:访问类型 {操作权限};
auditallow: 用于定义审核允许的规则,语法为 auditallow <sourcetype> <targettype>:<class> { permissions };
neverallow: 用于定义永远不允许的规则,语法为 neverallow <sourcetype> <targettype>:<class> { permissions };
dontaudit: 用于定义不进行审核的规则,语法为 dontaudit <sourcetype> <targettype>:<class> { permissions };
type_transition: 用于定义类型转换规则,语法为 type_transition <sourcetype> <targettype>:<class>;

myshell.te例程

type myshell, domain;
type myshell_exec, exec_type, vendor_file_type, file_type;
init_daemon_domain(myshell)

allow myshell vendor_shell_exec:file { rx_file_perms };
allow myshell vendor_toolbox_exec:file { rx_file_perms };
allow myshell console_device:chr_file { open write };
allow myshell myshell:capability { sys_module };
allow myshell vendor_file:system { module_load };

//myshell.te 定义了 myshell 服务的 SELinux 上下文类型。
//type 命令用于为服务定义一个新的 SELinux 上下文类型,并指定该服务所属的域(domain)。在该命令中,myshell 是服务的名称,domain 是服务的 SELinux 域名。
//type myshell_exec 定义了 myshell 服务的执行上下文类型。exec_type 表示该上下文类型是可执行文件类型,vendor_file_type 和 file_type 表示该上下文类型是厂商文件类型和普通文件类型。
//init_daemon_domain(myshell) 命令用于将 myshell 服务的 SELinux 域名与 init 进程绑定。这意味着当系统启动时,init 进程将会启动 myshell 服务,并将其置于 myshell 域中。

audit2allow工具

sudo apt install policycoreutils
adb shell logcat | grep avc > avc_log.txt
audit2allow -i avc_log.txt
  • 7
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Paper_Love

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值