Service xxx does not have a SELinux domain defined

需要添加一个服务xxx,并且设置成开机自启动。于是我在 init.rc 中添加了如下代码行:

--- a/conf/init.rc
+++ b/conf/init.rc
@@ -6,6 +6,8 @@ on early-init
 
 on init
 
+    start watchdogd
+
     # See storage config details at http://source.android.com/tech/storage/
     mkdir /storage/sdcard 0000 root root
     mkdir /storage/usb1 0000 root root
@@ -584,6 +586,10 @@ on property:meizu.wifi.test=stop
     stop wifi_test_mode
 ####wifi test end
 
+# Set watchdog timer to 30 seconds and pet it every 10 seconds to get a 20 second margin
+service watchdogd /sbin/watchdogd 10 20
+    class core
+
 # on userdebug and eng builds, enable kgdb on the serial console
 on property:ro.debuggable=1
     write /sys/module/kgdboc/parameters/kgdboc ttyFIQ1
 
 
  • 1
  • 2
  • 3

编译 boot.img 后烧到手机,发现服务 watchdogd 无法启动,logcat 未发现异常,kernel log 中有如下提示:   

   1] init: Service watchdogd does not have a SELinux domain defined.   

该提示说明没有定义 SELinux domain,导致服务 watchdogd 无法自启动。为了解决这个问题我们按如下方式修改或添加 sepolicy 文件:

  • 修改 system/seplicy/file_contexts 文件,添加以下内容:

    /sbin/watchdogd     u:object_r:watchdogd_exec:s0
      
      
    • 1

  • 新增 watchdogd.te 文件(本来就有),并在其中添加如下内容:

    需要为新增的进程增加域、执行权限
    type watchdogd, domain;
    type watchdogd_exec, exec_type, file_type;
    然后启用这个域
    init_daemon_domain(watchdogd)
      
      
    • 1
    • 2
    • 3
    • 4
    • 5

  • 验证,原则上修改 SELinux的 问题需要全编译。
  • 发现还是不行。需要加上:
  • seclabel u:r:watchdogd:s0

  • # Set watchdog timer to 30 seconds and pet it every 10 seconds to get a 20 second margin
    service watchdogd /sbin/watchdogd 10 20
        class core
        seclabel u:r:watchdogd:s0

    watchdogd 只是代名词,原生 android 本来就支持。
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值