file contexts and .te files
selinux-implementation
good-question-SO
visual_guide_to_sepolicy
formate to understand sepolicy:
1.
file_contexts
/dev/foo u:object_r:source_type:s0
policy.te
allow source_type target_type: target_class permission(s)
So this means
"allow source_type to do permitted actions on target_class of target_type "
2.
file_context
/dev/catfile u:object_r:cat_chow:s0
cat.te
type cat, domain
allow cat cat_chow:food eat
"allow cat to eat food of type cat_chow "
3.
file_contexts
/dev/mma8x5x u:object_r:sensors_device:s0
sensors.te
type sensors, domain
allow sensors sensors_device:chr_file rw_file_perms
"allow sensors to do rw on chr_file of type sensors_device"
good-question-SO
visual_guide_to_sepolicy
Policy files
Files that end with*.te
are SELinux policy source files, which
define domains and their labels. You may need to create new policy files in
/device/manufacturer/device-name/sepolicy
,
but you should try to update existing files where possible. Context files
Context files are where you specify labels for your objects.file_contexts
assigns labels to files and is used by various userspace components. As you create new policies, create or update this file to assign new labels to files. To apply newfile_contexts
, rebuild the filesystem image or runrestorecon
on the file to be relabeled. On upgrades, changes tofile_contexts
are automatically applied to the system and userdata partitions as part of the upgrade. Changes can also be automatically applied on upgrade to other partitions by addingrestorecon_recursive
calls to your init.board.rc file after the partition has been mounted read-write.seapp_contexts
assigns labels to app processes and/data/data
directories. This configuration is read by thezygote
process on each app launch and byinstalld
during startup.mac_permissions.xml
assigns aseinfo
tag to apps based on their signature and optionally their package name. Theseinfo
tag can then be used as a key in theseapp_contexts
file to assign a specific label to all apps with thatseinfo
tag. This configuration is read bysystem_server
during startup.
formate to understand sepolicy:
1.
file_contexts
/dev/foo u:object_r:source_type:s0
policy.te
allow source_type target_type: target_class permission(s)
So this means
"allow source_type to do permitted actions on target_class of target_type "
2.
file_context
/dev/catfile u:object_r:cat_chow:s0
cat.te
type cat, domain
allow cat cat_chow:food eat
"allow cat to eat food of type cat_chow "
3.
file_contexts
/dev/mma8x5x u:object_r:sensors_device:s0
sensors.te
type sensors, domain
allow sensors sensors_device:chr_file rw_file_perms
"allow sensors to do rw on chr_file of type sensors_device"
Comments
Post a Comment