美文网首页
SEAndroid 一些默认定义

SEAndroid 一些默认定义

作者: 杰杰_88 | 来源:发表于2020-04-26 17:32 被阅读0次

编写和阅读Android中的SELinux的策略时常常会有许多类似“API”的东西无法理解,其实通过如下目录可以很好的去理解为Android已经写好的Sepolicy,也可以理解为Sepolicy Android下的“标准库”

android/system/sepolicy

例如如下文件定义了很多“全局” attribute

public/attributes

在这里可以找到其定义以及注释说明,比如最常见的 domain 属性:

# All types used for processes.
attribute domain;

例如如下文件定义了很多“宏” 或者可以看做sepolicy中的“函数”

public/te_macros

#####################################
# init_daemon_domain(domain)
# Set up a transition from init to the daemon domain
# upon executing its binary.
define(`init_daemon_domain', `
domain_auto_trans(init, $1_exec, $1)
tmpfs_domain($1)
')


#####################################
# app_domain(domain)
# Allow a base set of permissions required for all apps.
define(`app_domain', `
typeattribute $1 appdomain;
# Label ashmem objects with our own unique type.
tmpfs_domain($1)
# Map with PROT_EXEC.
allow $1 $1_tmpfs:file execute;
')


#####################################
# untrusted_app_domain(domain)
# Allow a base set of permissions required for all untrusted apps.
define(`untrusted_app_domain', `
typeattribute $1 untrusted_app_all;
')


#####################################
# file_type_trans(domain, dir_type, file_type)
# Allow domain to create a file labeled file_type in a
# directory labeled dir_type.
# This only allows the transition; it does not
# cause it to occur automatically - use file_type_auto_trans
# if that is what you want.
#
define(`file_type_trans', `
# Allow the domain to add entries to the directory.
allow $1 $2:dir ra_dir_perms;
# Allow the domain to create the file.
allow $1 $3:notdevfile_class_set create_file_perms;
allow $1 $3:dir create_dir_perms;
')

#####################################
# file_type_auto_trans(domain, dir_type, file_type)
# Automatically label new files with file_type when
# they are created by domain in directories labeled dir_type.
#
define(`file_type_auto_trans', `
# Allow the necessary permissions.
file_type_trans($1, $2, $3)
# Make the transition occur by default.
type_transition $1 $2:dir $3;
type_transition $1 $2:notdevfile_class_set $3;
')

许多相对复杂的操作,比如文件的类型转换,进程的类型转换,都可以在这里找到相应比较完善的宏定义,用起来安全可靠又方便。

对于不同类型可以进行的操作可以到如下文件中查找

private/access_vectors

例如,对文件可以进行的操作的定义:

common file
{
    ioctl
    read
    write
    create
    getattr
    setattr
    lock
    relabelfrom
    relabelto
    append
    map
    unlink
    link
    rename
    execute
    quotaon
    mounton
}

Android中服务标签的定义文件:

private/service_contexts

Android中系统属性标签的定义文件:

private/property_contexts

Android中系统应用标签的定义文件:

private/seapp_contexts

Android中文件标签的定义:

private/file_contexts

Hal 服务bin文件的定义:

private/hwservice_contexts

其他以.te结尾的文件都是Android自带的策略文件,可以作为学习SELinux策略很好的例子。

相关文章

  • SEAndroid 一些默认定义

    编写和阅读Android中的SELinux的策略时常常会有许多类似“API”的东西无法理解,其实通过如下目录可以很...

  • 深入理解SELinux SEAndroid

    深入理解SELinux SEAndroid SEAndroid是Google在Android 4.4上正式推出的一...

  • 深入理解SELinux SEAndroid

    深入理解SELinux SEAndroid(第一部分) 深入理解SELinux SEAndroid之二

  • SEAndroid

    SEAndroid安全机制所要保护的对象是系统中的资源,这些资源分布在各个子系统中,例如我们经常接触的文件就是分布...

  • SEAndroid

    SEAndroid是在Android系统中基于SELinux推出的强制访问控制模型,来完善自主访问模型中只要取得r...

  • SEAndroid安全机制简要介绍和学习计划

    SEAndroid安全机制简要介绍和学习计划

  • SEAndroid安全机制(二)

    前一篇文章介绍了SEAndroid安全机制的框架,以及代码中各个文件的作用,接下来总结下遇到SEAndroid问题...

  • 接口

    接口中定义的方法和变量都包含一些默认修饰符。方法的默认修饰符是public abstract;变量是默认用publ...

  • iview控件绑定事件的时候,传递多个参数

    iview控件有时候使用的时候,默认不写就会绑定默认参数,但是有时候除了默认参数外,还想传递一些自己自定义的参数,...

  • Scala入门与进阶(三)- 函数

    1.函数的定义和使用 函数/方法的定义: 2.默认参数 默认参数:在函数定义时,允许指定参数的默认值$SPARK_...

网友评论

      本文标题:SEAndroid 一些默认定义

      本文链接:https://www.haomeiwen.com/subject/gzfkqhtx.html