Selinux篇3 -TE规则

allow vold device:dir write

这句的意思是:允许 type 为 vold 的主体 对 type 为 device的客体 拥有 客体类别为 dir 的write 权限。根据 SELinux 规范,规则定义的格式为:

rule_name source_type target_type : class perm_set;

可以看到规则中只用到了主体和客体的 type,而动作是以操作类别与具体操作的组合体现的。

所有 rule_name 如下:

allow 表示允许主体对客体执行允许的操作;

auditallow 表示即便允许操作也要记录访问决策信息(仍然需要有 allow 规则才允许);

dontaudit 表示违反规则的决策信息也不记录(便于定位问题,已知此操作会被拒绝但不会引起真正问题);

neverallow 表示不允许主体对客体执行指定的操作;同时还有其他 dontaudit allowaudit。

 

常见class 定义

# file-related classes

class filesystem

class file  #代表普通文件

class dir   #代表目录

class fd    #代表文件描述符

class lnk_file  #代表链接文件

class chr_file  #代表字符设备文件

 ......

# network-related classes

class socket   #socket

class tcp_socket

class udp_socket

......

class binder   #Android平台特有的binder

class zygote   #Android平台特有的zygote

常见动作定义:

 

一个规则demo:

 关键字attribute

属性关键字,适用于规则批量管理。

 系统文件位置/system/sepolicy/public/attribute

此文件增加我们自己定义的属性

attribute display_service_server;

attribute wifi_keystore_service_server;

+attribute attribute_test;

此处test_service具有和domain一样的作用,作为一个属性存在,一个进程域。

然后通过对此属性进行定义。

#定义两个type,分别是A_t和B_t,它们都管理到attribute_test

type A_t attribute_test;

type B_t attribute_test;

#写一个allow语句,直接针对attribute_test

allow attribute_test C_t:file {read write};

#上面这个allow语句在编译后的安全策略文件中会被如下两条语句替代:

allow A_t C_t:file {read write};

allow B_t C_t:file {read write};

关键字type_transition

类型转换宏

 

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值