Quiero ejecutar un Android init
servicio. Tengo un dispositivo que tiene shell rooteado (comprado de la fabricación como rooteado). Este dispositivo no tiene Magisk u otro gestor de su pero adb shell
tiene root y tiene userdebug
ROM instalada en él.
He seguido los siguientes pasos para configurar init
servicio:
-
Creado
/etc/init/custom.rc
con el siguiente contenido:/etc/init/custom.rc
define service, use executable here if script not needed
service custom /system/bin/custom.sh
# don't start unless explicitly asked to disabled # run with unrestricted SELinux context to avoid avc denials # can also use "u:r:su:s0" on userdebug / eng builds if no Magisk # it's required if SELinux is enforcing and service needs access # to some system resources not allowed by default sepolicy # seclabel u:r:magisk:s0 seclabel u:r:su:s0
start the service when boot is completed
on property:sys.boot_completed=1 start custom
-
Creado
/system/bin/custom.sh
con los siguientes contenidos:!/system/bin/sh
execute the binary, should run in foreground, otherwise get in loop
echo "$(date): Starting program..." exec /system/bin/executable
-
Colocó mi ejecutable en
/system/bin/executable
. -
Se han dado permisos a todos los archivos de la siguiente manera:
Give rights to the executable
chown 0.0 /system/bin/executable chmod 554 /system/bin/executable chcon u:object_r:system_file:s0 /system/bin/executable
Give rights to the custom.sh
chown 0.0 /system/bin/custom.sh chmod 554 /system/bin/custom.sh chcon u:object_r:system_file:s0 /system/bin/custom.sh
Give rights to the custom.rc
chown 0.0 /etc/init/custom.rc chmod 644 /etc/init/custom.rc chcon u:object_r:system_file:s0 /etc/init/custom.rc
-
Reinicie el sistema.
Tengo el siguiente error:
[ 55.829099 / 06-09 23:51:09.279][0] init: cannot execve('/system/bin/custom.sh'): Permission denied
[ 55.850172 / 06-09 23:51:09.309][6] init: Service 'custom' (pid 7729)
[ 55.850224 / 06-09 23:51:09.309][6] init: Service 'custom' (pid 7729) exited with status 127
[ 55.850243 / 06-09 23:51:09.309][6] init: Sending signal 9 to service 'custom' (pid 7729) process group...
[ 60.830224 / 06-09 23:51:14.289][6] init: starting service 'custom'...
[ 60.832073 / 06-09 23:51:14.289][1] init: cannot execve('/system/bin/custom.sh'): Permission denied
[ 60.832153 / 06-09 23:51:14.289][3] audit: type=1400 audit(1560142274.289:131): avc: denied { transition } for pid=8035 comm="init" path="/system/bin/custom.sh" dev="sda24" ino=8146 scontext=u:r:init:s0 tcontext=u:r:su:s0 tclass=process permissive=0
Tengo muy poca experiencia con las políticas de SELinux. Por favor, guíeme cómo puedo arreglar esto.