遇到问题
在Android项目上,写了一个bash脚本,内置在/vendor/bin,在init.rc配置了service catlog_sh,
# add cat log
service catlog_sh /vendor/bin/cat_log.sh
class main
user root
group root system
disabled
oneshot
使用ctl.start catlog_sh提示执行失败:
evt:/ # setprop ctl.start catlog_sh
Failed to set property 'ctl.start' to 'catlog_sh'.
See dmesg for error reason.
dmesg查看日志:
init: Control message: Could not ctl.start for 'catlog_sh' from pid: 2933 (setprop ctl.start catlog_sh): File /vendor/bin/sh(labeled "u:object_r:vendor_shell_exec:s0") has incorrect label or no domain transition from u:r:init:s0 to another SELinux domain defined.
解决方案
init.rc service 无法启动_has incorrect label or no domain transition from u-CSDN博客
文章里面说是需要定义domain,我已经定义过了:
cat_log.te
type cat_log, domain;
type cat_log_exec, exec_type, vendor_file_type, file_type;
init_daemon_domain(cat_log)
经过排查发现是shell定义问题
#!/system/bin/sh //原先的,导致domain异常
#!/bin/sh //调整后,自动适配域,解决问题