Service xxx does not have a SELinux domain defined
生活随笔
收集整理的這篇文章主要介紹了
Service xxx does not have a SELinux domain defined
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
點擊打開鏈接
為了完成公司項目的一個需求,需要添加一個binder服務xxx,并且設置成開機自啟動。于是我在init.rc中添加了如下代碼行:
service xxx /system/bin/xxxclass mainuser root- 1
- 2
- 3
編譯boot后燒到手機,發現服務xxx無法啟動,kernel log中有如下提示:
[ 20.076354s][pid:1,cpu7,init]init: Service xxx does not have a SELinux domain defined.- 1
該提示說明沒有定義SELinux domain,導致服務xxx無法自啟動。為了解決這個問題我們按如下方式修改或添加sepolicy文件:
- 修改seplicy/file_contexts文件,添加以下內容:
-
/system/bin/xxx u:object_r:xxx_exec:s0
- 1
- 新增xxx.te文件,并在其中添加如下內容:
-
需要為新增的進程增加域、執行權限
type xxx, domain;
type xxx_exec, exec_type, file_type;
然后啟用這個域
init_daemon_domain(xxx)
- 1
- 2
- 3
- 4
- 5
- 驗證,原則上修改SELinux的問題需要全編譯,為了節省時間可以使用以下方法調試
- 編譯bootimage
- 燒錄bootimage
- 執行adb remount
- 執行adb shell restorecon system/bin/xxx
- 重啟手機,查看kernel log中是否成功啟動xxx服務
總結
以上是生活随笔為你收集整理的Service xxx does not have a SELinux domain defined的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android 5.x 权限问题解决方法
- 下一篇: msm8937+android7.1系统