0

I have an init service that is not starting in user build. When running a userdebug build it works fine but not in user build. Can't seem to figure out why it's not running. I don't see any errors about it in logcat either.

on property:myprop=1
    start mysvc

service mysvc /system/bin/mybinary myargs
    user system
    group system
    oneshot

My app sets this property when I want the service to start.

Any help here is appreciated.

8
  • Is /data/logs/ accessible to system UID for writing? What's the SELinux context of the service? Can it access /data/logs/? See kernel log for init services. – Irfan Latif Dec 2 '20 at 22:50
  • Yes, system UID has access to the folder, which is why it works in userdebug build. I'm not worried about SELinux just yet; my build is running under permissive mode. – Chef Pharaoh Dec 2 '20 at 22:53
  • 2
    Which Android version you are on? Set seclabel and try again. – Irfan Latif Dec 2 '20 at 23:02
  • 2
    Can't remember exactly why, need to look into code. But this is the behavior in recent Android releases. – Irfan Latif Dec 3 '20 at 0:05
  • 1
    Ok, I see it now, the default context doesn't have enough permission. I'll have make sure I give it enough permission then, but not over do it. Thanks! – Chef Pharaoh Dec 3 '20 at 0:11
0

The problem was the SELinux context that the process was running under. I was able to fix it by marking the seclabel of my init service.

on property:myprop=1
    start mysvc

service mysvc /system/bin/mybinary myargs
    user system
    group system
    oneshot
    seclabel u:r:su:s0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.