1*e4a36f41SAndroid Build Coastguard Worker# Any toolbox command run by init. 2*e4a36f41SAndroid Build Coastguard Worker# Do NOT use this domain for toolbox when run by any other domain. 3*e4a36f41SAndroid Build Coastguard Workertype toolbox, domain; 4*e4a36f41SAndroid Build Coastguard Workertype toolbox_exec, system_file_type, exec_type, file_type; 5*e4a36f41SAndroid Build Coastguard Worker 6*e4a36f41SAndroid Build Coastguard Worker# /dev/__null__ created by init prior to policy load, 7*e4a36f41SAndroid Build Coastguard Worker# open fd inherited by fsck. 8*e4a36f41SAndroid Build Coastguard Workerallow toolbox tmpfs:chr_file { read write ioctl }; 9*e4a36f41SAndroid Build Coastguard Worker 10*e4a36f41SAndroid Build Coastguard Worker# Inherit and use pty created by android_fork_execvp_ext(). 11*e4a36f41SAndroid Build Coastguard Workerallow toolbox devpts:chr_file { read write getattr ioctl }; 12*e4a36f41SAndroid Build Coastguard Worker 13*e4a36f41SAndroid Build Coastguard Worker# mkswap-specific. 14*e4a36f41SAndroid Build Coastguard Worker# Read/write block devices used for swap partitions. 15*e4a36f41SAndroid Build Coastguard Worker# Assign swap_block_device type any such partition in your 16*e4a36f41SAndroid Build Coastguard Worker# device/<vendor>/<product>/sepolicy/file_contexts file. 17*e4a36f41SAndroid Build Coastguard Workerallow toolbox block_device:dir search; 18*e4a36f41SAndroid Build Coastguard Workerallow toolbox swap_block_device:blk_file rw_file_perms; 19*e4a36f41SAndroid Build Coastguard Worker 20*e4a36f41SAndroid Build Coastguard Worker# Only allow entry from init via the toolbox binary. 21*e4a36f41SAndroid Build Coastguard Workerneverallow { domain -init } toolbox:process transition; 22*e4a36f41SAndroid Build Coastguard Workerneverallow * toolbox:process dyntransition; 23*e4a36f41SAndroid Build Coastguard Workerneverallow toolbox { file_type fs_type -toolbox_exec}:file entrypoint; 24*e4a36f41SAndroid Build Coastguard Worker 25*e4a36f41SAndroid Build Coastguard Worker# rm -rf /data/per_boot 26*e4a36f41SAndroid Build Coastguard Workerallow toolbox system_data_root_file:dir { remove_name write }; 27*e4a36f41SAndroid Build Coastguard Workerallow toolbox system_data_file:dir { rmdir rw_dir_perms }; 28*e4a36f41SAndroid Build Coastguard Workerallow toolbox system_data_file:file { getattr unlink }; 29*e4a36f41SAndroid Build Coastguard Worker 30*e4a36f41SAndroid Build Coastguard Worker# chattr +F /data/media in init 31*e4a36f41SAndroid Build Coastguard Workerallow toolbox media_userdir_file:dir { r_dir_perms setattr }; 32*e4a36f41SAndroid Build Coastguard Workerallowxperm toolbox media_userdir_file:dir ioctl { FS_IOC_SETFLAGS FS_IOC_GETFLAGS }; 33