1. 程式人生 > >【Android O】 Service AAA does not have a SELinux domain defined

【Android O】 Service AAA does not have a SELinux domain defined

point devices pan led 啟動 nes contex pos 一個

在init.AAA.rc裏面添加了一個腳本啟動的服務:

service AAA /vendor/bin/sh /vendor/etc/AAA_spec.sh
user root
group root
disabled
oneshot

on post-fs-data
start AAA

在系統啟動時通過dmesg | grep init查看發現出現:Service AAA does not have a SELinux domain defined

解決方法:

1.在devices/vendorxxx/sepolicy/common/目錄下新增AAA.te文件,內容如下:

type AAA, domain;

type AAA_exec, exec_type, vendor_file_type,file_type;

init_daemon_domain(AAA)

allow AAA vendor_shell_exec:file { entrypoint };

2.在devices/vendorxxx/sepolicy/Android.mk文件中添加:

BOARD_SEPOLICY_DIRS += devices/vendorxxx/sepolicy/common/

3.在devices/vendorxxx/sepolicy/common/file_contexts中添加:

##add for AAA file permission##
/(vendor|system/vendor)/etc/AAA_spec\.sh u:object_r:AAA_exec:s0

4.在init.AAA.rc裏面對應的service裏面添加:

service AAA /vendor/bin/sh /vendor/etc/AAA_spec.sh
user root
group root
disabled
oneshot
seclabel u:r:carrier_switcher:s0

5.編譯並燒錄bootimage,若編譯報錯註意解決neverallow沖突

6.系統起來時如發現avc則逐一添加allow策略語句

【Android O】 Service AAA does not have a SELinux domain defined